A Model Context Protocol (MCP) server that exposes 20 tools letting Claude Desktop (or any MCP-compatible host) work with your Microsoft 365 data through the Microsoft Graph API — Outlook Mail, Calendar, OneDrive, Teams, and SharePoint.
Authentication uses the MSAL device-code (delegated) flow with a persistent, DPAPI-encrypted token cache, so you sign in once and the server reuses the cached session across restarts.
| Area | Tools |
|---|---|
| Outlook Mail | list messages, get message, send mail, create draft, search messages |
| Calendar | list events, get event, create event, update event, delete event |
| OneDrive | list root, list folder, search files, download file, upload file, create folder |
| SharePoint | list sites, get site details |
| Teams | list chats, send chat message |
- Azure Portal → Microsoft Entra ID → App registrations → New registration.
- Name:
Microsoft Graph MCP Server. - Supported account types: Accounts in this organizational directory only (single-tenant) is recommended for the tightest sign-in surface. Note your Directory (tenant) ID.
- Authentication → Advanced settings → set Allow public client flows to Yes (required for the device-code flow).
- API permissions → add these delegated Microsoft Graph permissions (the least-privilege set matching the 20 tools):
User.ReadMail.ReadWriteMail.SendCalendars.ReadWriteFiles.ReadWriteSites.Read.AllChat.ReadWrite
- Click Grant admin consent —
Sites.Read.AllandChat.ReadWriterequire it. - Copy the Application (client) ID and Directory (tenant) ID.
Create a .env from .env.example:
MICROSOFT_CLIENT_ID=your-application-client-id
MICROSOFT_TENANT_ID=your-directory-tenant-id # your tenant ID (single-tenant) or "common" (multi-tenant/personal)Install and build:
npm install
npm run buildStart the server directly once in a terminal so you can see and complete the device-code prompt:
npm run startThe sign-in instructions print to stderr:
=========================================
MICROSOFT GRAPH AUTHENTICATION REQUIRED
To sign in, use a web browser to open https://microsoft.com/devicelogin and enter the code XXXXXXXXX.
=========================================
Open the link, enter the code, sign in, and consent. The token is then cached (DPAPI-encrypted, under %USERPROFILE%\.microsoft-graph-mcp\), so later runs — including when Claude Desktop launches the server — authenticate silently.
Why a terminal first? Claude Desktop captures the server's stderr into log files, so the device-code prompt is not visible in the chat UI. Completing the first sign-in in a terminal seeds the persistent cache; Claude Desktop then reuses it silently.
Add the server to claude_desktop_config.json (on Windows: %APPDATA%\Claude\claude_desktop_config.json). Use the absolute path to your built build/index.js:
{
"mcpServers": {
"microsoft-graph": {
"command": "node",
"args": ["C:/path/to/microsoft-graph-mcp/build/index.js"],
"env": {
"MICROSOFT_CLIENT_ID": "your-application-client-id",
"MICROSOFT_TENANT_ID": "your-directory-tenant-id"
}
}
}
}Restart Claude Desktop after editing the config.
- Delegated permissions only. The server acts as the signed-in user and requests the least-privilege scope set above. No client secret is used or stored.
- Token cache is DPAPI-encrypted at rest (Windows) and lives in your user profile, never in the repository.
- Your
.envis gitignored — never commit credentials.