loading…
Search for a command to run...
loading…
Provides Claude Desktop and Claude Code with access to Microsoft 365 email and calendar services via the Microsoft Graph API. It enables users to manage emails,
Provides Claude Desktop and Claude Code with access to Microsoft 365 email and calendar services via the Microsoft Graph API. It enables users to manage emails, search folders, schedule calendar events, and check availability through natural language commands.
An MCP server that gives Claude Desktop and Claude Code access to your Microsoft 365 email (Outlook) and calendar via Microsoft Graph API.
Setting up this MCP server requires two main steps:
Both are detailed below with step-by-step instructions.
| Tool | Description |
|---|---|
ms365_list_emails |
List emails from any folder (inbox, sent, etc.) |
ms365_read_email |
Read full email content by ID |
ms365_search_emails |
Search emails by keyword |
ms365_send_email |
Send an email |
ms365_create_draft |
Create a draft email without sending |
ms365_reply_email |
Reply to an email |
ms365_list_mail_folders |
List all mail folders with counts |
ms365_list_events |
List calendar events in a date range |
ms365_get_event |
Get full event details |
ms365_list_calendars |
List all calendars |
ms365_find_free_time |
Check free/busy for people |
ms365_get_profile |
Get your Microsoft 365 profile |
Before you can use this MCP server, you need to create an Azure AD App Registration to get your MS_CLIENT_ID and MS_TENANT_ID. This only needs to be done once.
Go to the Azure Portal
Access App Registrations
Create New Registration
MS365 MCP Server (or any name you prefer)http://localhostCopy Your Credentials
MS_CLIENT_IDMS_TENANT_IDNavigate to API Permissions
Add Microsoft Graph Permissions
Add Required Permissions
Grant Admin Consent
Your Azure configuration is complete when you have:
Now you're ready to proceed with the local installation!
Copy the ms365-mcp-server folder to a permanent location on your machine:
# Example: put it in your home directory
cp -r ms365-mcp-server ~/ms365-mcp-server
cd ~/ms365-mcp-server
cd ~/ms365-mcp-server
python3 -m venv .venv
source .venv/bin/activate # macOS/Linux
# .venv\Scripts\activate # Windows
pip install -r requirements.txt
Run the server once manually to complete the interactive Microsoft login:
cd ~/ms365-mcp-server
source .venv/bin/activate
export MS_CLIENT_ID="your-client-id-here"
export MS_TENANT_ID="your-tenant-id-here"
python server.py
This will open your browser for Microsoft login. Sign in and grant permissions.
Once done, a token_cache.json file is created — this stores your refresh token so you won't need to log in again (tokens auto-renew for ~90 days).
Press Ctrl+C to stop the server after the login succeeds.
Open Claude Desktop's configuration file:
IMPORTANT: Use the MS_CLIENT_ID and MS_TENANT_ID you copied from the Azure setup above.
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.jsonAdd the MCP server configuration. Replace the paths and credentials with your own:
{
"mcpServers": {
"ms365": {
"command": "/Users/YOURUSER/ms365-mcp-server/.venv/bin/python",
"args": [
"/Users/YOURUSER/ms365-mcp-server/server.py"
],
"env": {
"MS_CLIENT_ID": "your-client-id-here",
"MS_TENANT_ID": "your-tenant-id-here"
}
}
}
}
Important: Use the FULL path to the Python binary inside your virtual environment, not just
python3.
Finding your Python path:
# macOS/Linux
source ~/ms365-mcp-server/.venv/bin/activate
which python
# Outputs something like: /Users/youruser/ms365-mcp-server/.venv/bin/python
# Windows
# Usually: C:\Users\YOURUSER\ms365-mcp-server\.venv\Scripts\python.exe
Quit Claude Desktop completely and reopen it. You should see a 🔌 icon or the MCP tools available when you start a conversation.
If you're using Claude Code (the command-line tool), follow these steps:
Follow Steps 1-3 from the Claude Desktop setup above (clone, create venv, first-time auth).
Open or create the Claude Code MCP configuration file:
IMPORTANT: Use the MS_CLIENT_ID and MS_TENANT_ID you copied from the Azure setup above.
~/.claude/mcp_settings.json%USERPROFILE%\.claude\mcp_settings.jsonAdd the MCP server configuration:
{
"mcpServers": {
"ms365": {
"command": "/Users/YOURUSER/ms365_mcp_server/.venv/bin/python",
"args": [
"/Users/YOURUSER/ms365_mcp_server/server.py"
],
"env": {
"MS_CLIENT_ID": "your-client-id-here",
"MS_TENANT_ID": "your-tenant-id-here"
}
}
}
}
Important: Use the FULL path to the Python binary inside your virtual environment.
Start Claude Code and verify the MCP server is loaded:
claude-code
The ms365 tools should be available in your session.
Once configured, just chat naturally with Claude Desktop:
Delete token_cache.json and run python server.py again to re-authenticate.
Go back to your Azure AD App Registration → API Permissions and make sure Mail.Read, Mail.ReadWrite, Mail.Send, Calendars.Read, and User.Read are all granted with admin consent.
The token_cache.json is saved in the same directory as server.py. Make sure the process has write access to that folder.
ms365-mcp-server/
├── server.py # Main MCP server with all tools
├── auth.py # MSAL authentication (token acquire + cache)
├── graph_client.py # Microsoft Graph API client
├── requirements.txt # Python dependencies
├── token_cache.json # Auto-generated after first login (DO NOT COMMIT)
└── README.md # This file
PublicClientApplication with interactive auth — the Microsoft-recommended approach for desktop/CLI apps.token_cache.json contains your refresh token. Treat it like a password. Do not commit it to version control.Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"microsoft-365-mcp-server": {
"command": "npx",
"args": []
}
}
}