ms

ms-365-mcp-server

MCP server that connects to the whole Microsoft 365 suite using Graph API (including mail, files, Excel, calendar)

Publisherms-365-mcp-server
Submitted date4/13/2025

Seamless Microsoft 365 Integration with LLMs: An Expert Guide to the Model Context Protocol Server

This document provides an in-depth guide to the Microsoft 365 MCP Server, a powerful tool that bridges the gap between Large Language Models (LLMs) and the rich ecosystem of Microsoft 365 services. By leveraging the Model Context Protocol (MCP), this server enables developers to build intelligent applications that can seamlessly access and manipulate data within Microsoft 365, unlocking a new realm of possibilities for AI-powered workflows.

Build Status npm version

Core Capabilities: Empowering LLMs with Microsoft 365 Context

The Microsoft 365 MCP Server offers a comprehensive suite of features designed to provide LLMs with the context they need to perform complex tasks within the Microsoft 365 environment. These features include:

  • Secure Authentication: Utilizes the Microsoft Authentication Library (MSAL) to ensure secure and compliant access to Microsoft 365 resources. Supports device code flow for seamless integration with various LLM interfaces.
  • Excel File Mastery: Enables LLMs to interact with Excel files in a sophisticated manner, including:
    • Reading, updating, and formatting cell values.
    • Creating and managing charts and tables.
    • Sorting data and listing worksheets.
  • OneDrive Integration: Provides access to files and folders stored in OneDrive, allowing LLMs to retrieve and manipulate documents, images, and other data.
  • Calendar Management: Empowers LLMs to manage Outlook calendars, including:
    • Listing, creating, updating, and deleting events.
    • Finding available meeting times and managing invitations.
  • Email Interaction: Enables LLMs to interact with Outlook email, including:
    • Listing and retrieving messages.
  • Model Context Protocol (MCP) Compliance: Adheres to the MCP standard, ensuring interoperability with a wide range of LLM platforms and tools.

Installation and Setup: A Streamlined Approach

Installing the Microsoft 365 MCP Server is a straightforward process:

npx @softeria/ms-365-mcp-server

This command will install the server and its dependencies, making it ready for integration with your chosen LLM platform.

Integrating with LLM Platforms: A Practical Guide

The Microsoft 365 MCP Server is designed to be easily integrated with various LLM platforms. Here's a detailed guide for integrating with Claude, a popular LLM platform:

Claude Desktop Integration

  1. Launch Claude Desktop.
  2. Navigate to Settings > MCPs.
  3. Click "Add MCP".
  4. Configure the MCP:
    • Name: Choose a descriptive name (e.g., "ms365").
    • Command: npx @softeria/ms-365-mcp-server
    • Click "Add".

Alternatively, you can directly modify Claude Desktop's configuration file (accessible via Settings > Developer > Edit Config) by adding the following JSON snippet:

{ "mcpServers": { "ms365": { "command": "npx", "args": [ "-y", "@softeria/ms-365-mcp-server" ] } } }

Claude Code CLI Integration

Integration with Claude Code CLI may vary depending on the version. Refer to the official Claude Code documentation for the most up-to-date instructions.

Development and Contribution: Building a Collaborative Ecosystem

The Microsoft 365 MCP Server is an open-source project, and contributions are welcome. To get started with development:

  1. Clone the repository:

    git clone https://github.com/softeria-eu/ms-365-mcp-server.git cd ms-365-mcp-server
  2. Install dependencies:

    npm install
  3. Run tests:

    npm test

The repository utilizes GitHub Actions for continuous integration and deployment, ensuring code quality and automated releases.

Release Management: Ensuring Stability and Innovation

The release process is automated through npm scripts:

  • Patch Release (Default): npm run release (e.g., 0.1.11 -> 0.1.12)
  • Minor Release: npm run release minor (e.g., 0.1.11 -> 0.2.0)
  • Major Release: npm run release major (e.g., 0.1.11 -> 1.0.0)

These scripts handle testing, version bumping, committing changes, pushing to GitHub, creating releases, and triggering the npm publishing workflow.

Usage and Authentication: A Deep Dive

Command-Line Options

The server provides several command-line options for managing authentication and logging:

  • --login: Forces login using device code flow.
  • --logout: Logs out and clears saved credentials.
  • --test-login: Tests authentication and verifies Graph API access.
  • -v: Enables verbose logging.

Authentication Methods

Authentication is crucial for accessing Microsoft 365 resources. The server supports two primary authentication methods:

  1. Command-Line Login:

    npx @softeria/ms-365-mcp-server --login

    This method displays the login URL and code directly in the terminal.

  2. MCP Tool-Based Login:

    • Use the login tool to retrieve the login URL and code.
    • Visit the URL and enter the code in your browser.
    • Use the verify-login tool to confirm successful login.

Both methods utilize the device code flow, providing a secure and user-friendly authentication experience. The --test-login flag allows you to verify your authentication status and confirm access to Microsoft Graph API:

npx @softeria/ms-365-mcp-server --test-login

Successful authentication will return a JSON response containing user information from Microsoft Graph API. Authentication tokens are securely cached using the system's credential store, with file storage as a fallback.

MCP Tools: Unleashing the Power of Microsoft 365

The server provides a rich set of MCP tools for interacting with Microsoft 365 services. These tools are categorized as follows:

Authentication Tools

  • login: Initiates the login process.
  • verify-login: Verifies login completion and Graph API access.
  • logout: Logs out and clears credentials.
  • test-login: Tests authentication status and Graph API access.

Files/OneDrive Tools

  • list-files: Lists files and folders in a specified path.
  • get-file: Retrieves details of a specific file.
  • create-folder: Creates a new folder.
  • delete-item: Deletes a file or folder.
  • copy-item: Copies a file or folder to a new location.
  • move-item: Moves a file or folder to a new location.
  • rename-item: Renames a file or folder.
  • search-files: Searches for files matching a query.
  • get-shared-items: Retrieves a list of items shared with you.
  • create-sharing-link: Creates a sharing link for a file or folder.
    • get-file-content: Get the content of a file

Excel Tools

All Excel tools require a filePath parameter to specify the target Excel file.

  • update-excel: Updates cell values in an Excel worksheet.
  • create-chart: Creates a chart in an Excel worksheet.
  • format-range: Applies formatting to a range of cells.
  • sort-range: Sorts a range of cells.
  • create-table: Creates a table from a range of cells.
  • get-range: Retrieves values from a range of cells.
  • list-worksheets: Lists all worksheets in the workbook.
  • close-session: Closes the session for a specific Excel file.
  • close-all-sessions: Closes all active Excel sessions.
  • delete-chart: Deletes a chart from a worksheet.
  • get-charts: Get all charts in a worksheet

Calendar Tools

  • list-calendars: Lists all calendars.
  • get-default-calendar: Retrieves information about the default calendar.
  • list-events: Lists events from a calendar with filtering and sorting options.
  • get-detailed-events: Retrieves events with expanded properties.
  • get-event: Retrieves detailed information about a specific event.
  • create-event: Creates a new calendar event with comprehensive options.
  • create-recurring-event: Creates recurring events with flexible recurrence patterns.
  • update-event: Updates an existing calendar event.
  • delete-event: Deletes a calendar event.
  • accept-event: Accepts a calendar meeting invitation.
  • decline-event: Declines a calendar meeting invitation.
  • tentatively-accept-event: Tentatively accepts a calendar meeting invitation.
  • find-meeting-times: Finds available meeting times for a set of attendees.
  • get-schedules: Retrieves availability information for multiple users or resource rooms.

Mail Tools

  • list-messages: Lists emails from any mail folder with filtering, searching, and sorting options.
  • get-message: Retrieves detailed information about a specific email message.

Conclusion: Empowering the Future of AI-Driven Productivity

The Microsoft 365 MCP Server is a critical enabler for building intelligent applications that leverage the power of LLMs and the vast resources of Microsoft 365. By providing a standardized and secure interface, this server empowers developers to create innovative solutions that streamline workflows, automate tasks, and unlock new levels of productivity. As the field of AI continues to evolve, the Microsoft 365 MCP Server will play an increasingly important role in shaping the future of work.

Visit More

View All