Allows AI agents to manage Outlook mail and calendar events and read Microsoft Teams message history using Microsoft Graph.
Also known as timfurlong/msgraph-mcp, msgraph-mcp, msgraph-mcp-server
- Stars
- 1
- Tools
- —
- Downloads, 30 days
- 400
- Latest version
- 0.5.2
- Last commit
- Nov 13, 2026
- License
- MIT
What is MSGraph MCP?
MSGraph allows AI agents to manage Outlook mail and calendar events and read Microsoft Teams message history using Microsoft Graph.
Summary generated from the project's README
About MSGraph MCP server
Managing Outlook communications and Microsoft Teams history through an AI agent is possible with MSGraph MCP. This server connects to the Microsoft Graph SDK to provide tools for reading and writing emails, managing calendar events, and accessing read-only message history from Teams chats and channels. It operates using delegated permissions via the MSAL device code flow, meaning the AI can only access data that the signed-in user has permission to see.
To use this server, developers must set up an Entra app registration and provide the client and tenant IDs as environment variables. After a one-time sign-in using the msgraph-mcp-login command, a token cache is stored locally to maintain the session. The server is designed to work over stdio with hosts like Claude Code or any other MCP-compatible client. It includes specialized tools for batch processing up to 1000 messages at once and can even download attachments as native image blocks for the agent to view.
What you can do with it
- 1Perform bulk email actionsAn agent can quickly archive, move, or mark large groups of messages as read or unread.
Written from the project's README. Every use case is checked against a quote from it.
How to install MSGraph MCP
Formats verified 10 Nov 2026Add to CursorAdd to GooseInstall MSGraph MCP in Claude Code
$ claude mcp add --env 'MSGRAPH_MCP_CLIENT_ID=<MSGRAPH_MCP_CLIENT_ID>' --env 'MSGRAPH_MCP_TENANT_ID=<MSGRAPH_MCP_TENANT_ID>' msgraph-mcp -- uvx msgraph-mcp-serverInstall MSGraph MCP in Cursor
~/.cursor/mcp.json
{
"mcpServers": {
"msgraph-mcp": {
"command": "uvx",
"args": [
"msgraph-mcp-server"
],
"env": {
"MSGRAPH_MCP_CLIENT_ID": "<MSGRAPH_MCP_CLIENT_ID>",
"MSGRAPH_MCP_TENANT_ID": "<MSGRAPH_MCP_TENANT_ID>"
}
}
}
}Install MSGraph MCP in VS Code
.vscode/mcp.json
{
"servers": {
"msgraph-mcp": {
"type": "stdio",
"command": "uvx",
"args": [
"msgraph-mcp-server"
],
"env": {
"MSGRAPH_MCP_CLIENT_ID": "<MSGRAPH_MCP_CLIENT_ID>",
"MSGRAPH_MCP_TENANT_ID": "<MSGRAPH_MCP_TENANT_ID>"
}
}
}
}Install MSGraph MCP in VS Code CLI
$ code --add-mcp '{"name":"msgraph-mcp","type":"stdio","command":"uvx","args":["msgraph-mcp-server"],"env":{"MSGRAPH_MCP_CLIENT_ID":"<MSGRAPH_MCP_CLIENT_ID>","MSGRAPH_MCP_TENANT_ID":"<MSGRAPH_MCP_TENANT_ID>"}}'Install MSGraph MCP in Claude Desktop
claude_desktop_config.json
{
"mcpServers": {
"msgraph-mcp": {
"command": "uvx",
"args": [
"msgraph-mcp-server"
],
"env": {
"MSGRAPH_MCP_CLIENT_ID": "<MSGRAPH_MCP_CLIENT_ID>",
"MSGRAPH_MCP_TENANT_ID": "<MSGRAPH_MCP_TENANT_ID>"
}
}
}
}Install MSGraph MCP in Codex
$ codex mcp add msgraph-mcp --env 'MSGRAPH_MCP_CLIENT_ID=<MSGRAPH_MCP_CLIENT_ID>' --env 'MSGRAPH_MCP_TENANT_ID=<MSGRAPH_MCP_TENANT_ID>' -- uvx msgraph-mcp-serverInstall MSGraph MCP in Codex config.toml
~/.codex/config.toml
[mcp_servers.msgraph-mcp] command = "uvx" args = ["msgraph-mcp-server"] [mcp_servers.msgraph-mcp.env] MSGRAPH_MCP_CLIENT_ID = "<MSGRAPH_MCP_CLIENT_ID>" MSGRAPH_MCP_TENANT_ID = "<MSGRAPH_MCP_TENANT_ID>"
Install MSGraph MCP in Gemini CLI
$ gemini mcp add -s user -e 'MSGRAPH_MCP_CLIENT_ID=<MSGRAPH_MCP_CLIENT_ID>' -e 'MSGRAPH_MCP_TENANT_ID=<MSGRAPH_MCP_TENANT_ID>' msgraph-mcp uvx -- msgraph-mcp-serverInstall MSGraph MCP in Gemini settings.json
~/.gemini/settings.json
{
"mcpServers": {
"msgraph-mcp": {
"command": "uvx",
"args": [
"msgraph-mcp-server"
],
"env": {
"MSGRAPH_MCP_CLIENT_ID": "<MSGRAPH_MCP_CLIENT_ID>",
"MSGRAPH_MCP_TENANT_ID": "<MSGRAPH_MCP_TENANT_ID>"
}
}
}
}Configuration
MSGRAPH_MCP_CLIENT_IDRequiredClient ID of your Entra (Azure AD) app registration
MSGRAPH_MCP_TENANT_IDRequiredEntra tenant ID (or 'common' / 'organizations' / 'consumers')
MSGRAPH_MCP_TOKEN_CACHE_PATHOverride the token cache location (default ~/.msgraph-mcp/token_cache.bin)
| Name | Description | |
|---|---|---|
| MSGRAPH_MCP_CLIENT_ID | Client ID of your Entra (Azure AD) app registration | Required |
| MSGRAPH_MCP_TENANT_ID | Entra tenant ID (or 'common' / 'organizations' / 'consumers') | Required |
| MSGRAPH_MCP_TOKEN_CACHE_PATH | Override the token cache location (default ~/.msgraph-mcp/token_cache.bin) |
Automated checks
Ran Nov 14, 2026Full report →Passed our automated checks. That is not a security audit: read the code and give the server the narrowest access it needs. How checks work
- Source repository linked and reachabletimfurlong/msgraph-mcp is public and reachablegithub.com/timfurlong/msgraph-mcp ↗Pass
- Package names this repository as its sourcemsgraph-mcp-server names timfurlong/msgraph-mcp as sourcepypi.org/project/msgraph-mcp-server/ ↗Pass
- Build provenance (Sigstore attestation)Sigstore attestation for msgraph-mcp-serverpypi.org/project/msgraph-mcp-server/ ↗Pass
- Open source license (OSI)MITspdx.org/licenses/MIT.html ↗Pass
- Commit or release in the last yearLast commit or release 2026-11-12github.com/timfurlong/msgraph-mcp ↗Pass
- OpenSSF ScorecardNot checked
- Package name not close to a popular packageNo popular package one edit away from msgraph-mcp-serverPass
- No critical advisory in the package or its dependenciesthe package checked; no critical advisoryosv.dev ↗Pass
- No hidden instructions to the model0 tool descriptions and the README read; no override phrases, credential paths or hidden charactersPass
- Destructive tools are labelledNot checked
- Remote endpoint answers the MCP handshakeNot checked
README
View on GitHubMSGraph MCP
A Model Context Protocol (MCP) server for Microsoft Graph. It exposes Microsoft Outlook mail and calendar, plus read-only Microsoft Teams message history, to AI agents via the Microsoft Graph SDK. It acts as the signed-in user, using delegated permissions and MSAL device code flow, so it can only reach what that user can reach.
Install
You need Python ≥ 3.11 and an Entra (Azure AD) app registration. The app registration takes about ten minutes and may need an administrator, so do that first: see the Entra setup section below.
uv tool install msgraph-mcp-server # or: pip install msgraph-mcp-server
The package is msgraph-mcp-server. It installs three commands: msgraph-mcp and its alias msgraph-mcp-server, which both start the stdio server, plus msgraph-mcp-login for the one-time sign-in.
Setup
1. Set your Entra app credentials.
export MSGRAPH_MCP_CLIENT_ID=<your app's client ID>
export MSGRAPH_MCP_TENANT_ID=<your tenant ID> # or: common / organizations / consumers
2. Sign in once. This prints a URL and a code; visit the URL and enter the code. No client secret is involved or stored.
msgraph-mcp-login
# running via uvx instead of installing: uvx --from msgraph-mcp-server msgraph-mcp-login
A token cache is written to ~/.msgraph-mcp/token_cache.bin.
3. Wire the server into your MCP host.
Claude Code:
claude mcp add msgraph \
--env MSGRAPH_MCP_CLIENT_ID=$MSGRAPH_MCP_CLIENT_ID \
--env MSGRAPH_MCP_TENANT_ID=$MSGRAPH_MCP_TENANT_ID \
-- msgraph-mcp
Any other host, over stdio:
{
"mcpServers": {
"msgraph": {
"command": "msgraph-mcp",
"args": [],
"env": {
"MSGRAPH_MCP_CLIENT_ID": "<your app's client ID>",
"MSGRAPH_MCP_TENANT_ID": "<your tenant ID>"
}
}
}
}
To run without installing, use "command": "uvx" with "args": ["msgraph-mcp-server"]. Note that uvx does not put msgraph-mcp-login on your PATH, so sign in with the uvx --from form shown in step 2.
MSGRAPH_MCP_TOKEN_CACHE_PATH optionally overrides the cache location. All three variables can also come from a .env file in the working directory; the process environment wins over it.
Entra setup
The app registration requires:
- Account type: single tenant (multi-tenant works too; set
MSGRAPH_MCP_TENANT_IDtocommon,organizations, orconsumers) - Redirect URI (public client):
https://login.microsoftonline.com/common/oauth2/nativeclient - Allow public client flows: Yes, under Authentication → Advanced settings. Device code flow fails without it.
- Delegated permissions (Microsoft Graph):
- Mail:
Mail.ReadWrite,Mail.ReadWrite.Shared,Mail.Send - Rules:
MailboxSettings.ReadWrite(Graph requires this for themessageRulesendpoints) - Calendar:
Calendars.ReadWrite,Calendars.ReadWrite.Shared - Identity:
User.Read - Teams:
Chat.Read,Team.ReadBasic.All,Channel.ReadBasic.All,ChannelMessage.Read.All
- Mail:
ChannelMessage.Read.All always needs tenant admin consent, and the *.Shared permissions may need it depending on your tenant.
The scope list is all-or-nothing. Sign-in requests every scope at once, so without admin consent for
ChannelMessage.Read.Allthe login fails outright and mail and calendar are unavailable too. For the same reason, adding scopes later means re-runningmsgraph-mcp-login; until you do, every tool fails withNotAuthenticatedError, not just the ones needing the new scope.
Tools
| Group | Tools |
|---|---|
| Util | whoami |
| Mail — read | list_messages, search_messages, get_message, list_attachments, download_attachment |
| Mail — write | send_message, create_draft, reply_message, reply_all_message, forward_message, update_message, delete_message |
| Mail — folders | list_folders, create_folder, update_folder, delete_folder, move_message |
| Mail — actions | archive_message, mark_read, mark_unread, flag_message, unflag_message |
| Mail — batch | batch_archive_messages, batch_move_messages, batch_mark_read, batch_mark_unread, batch_flag_messages, batch_unflag_messages |
| Mail — rules | list_rules, get_rule, create_rule, update_rule, delete_rule |
| Calendar | list_calendars, list_events, get_event, create_event, update_event, delete_event, cancel_event, respond_to_event, find_meeting_times |
| Teams (read) | list_chats, list_chat_messages, list_joined_teams, list_channels, list_channel_messages, list_message_replies, download_hosted_content |
Behavior shared across tools:
- Trimmed responses. Results are reshaped for agents, and message and event bodies are replaced by a short
snippet. Passinclude_body=truetoget_message,list_chat_messages,list_channel_messages, orlist_message_repliesfor the full body, which for Teams is also what surfaces Adaptive Card content. Passinclude_raw=trueto any tool returning a Graph object to get the full payload alongside the trimmed one; thebatch_*tools return per-message status only and do not accept it. - Other mailboxes. Every mail and calendar tool takes an optional
mailbox(email or user ID) to target a shared or delegated mailbox. Omit it for your own. Teams tools are read-only, cover only your own chats, and take nomailbox. - Pagination. List and search tools take
limit(1-100, default 25) andpage_token, exceptlist_channel_messagesandlist_message_replies, which Graph caps at 50.list_folders,list_rules,list_attachments, andlist_calendarsreturn the whole collection and take neither. Onlist_joined_teamsandlist_channels,limitis applied after fetching because Graph rejects$topthere, so it saves tokens rather than round-trips. - Batch actions. The
batch_*tools apply one action to up to 1000 messages via Graph's$batchendpoint, returning a per-message result plus a{total, succeeded, failed}summary. - Downloads.
download_attachmentanddownload_hosted_contentreturn images as native MCP image blocks the agent can view. Passsave_path(a file, or an existing directory) to write bytes to disk and get back a path instead. - Finding mail.
list_messagesdefaults to the inbox; passfolder_idfor another folder,unread_only=true, or a raw ODatafilterfor predicates KQL cannot express.search_messagespasses your query to Graph's$searchas KQL.
Outgoing attachments are capped at 3 MB total per message; chunked upload is not supported. SharePoint-backed Teams file attachments cannot be downloaded, only inline hosted content.
Security
The token cache holds your refresh token, which can mint access tokens for your mail, calendar, and Teams data. Treat the file as a credential. It lives at ~/.msgraph-mcp/token_cache.bin with mode 0600 inside a 0700 directory.
To revoke access, or to switch accounts, delete the cache and sign in again:
rm -f ~/.msgraph-mcp/token_cache.bin ~/.outlook-mcp/token_cache.bin
The second path matters if you ever ran this server under its former name outlook-mcp: that cache is still used as a fallback when the current one is absent, so deleting only the first file leaves a working refresh token on disk. To revoke fully, also remove the app at https://account.microsoft.com or in your organization's identity portal.
Troubleshooting
NotAuthenticatedError: Not authenticated— runmsgraph-mcp-login. If it recurs immediately, a requested scope has not been consented yet; see the note under Entra setup.ConfigError: Missing required env var— set it in your shell, in a.envin the working directory, or in your MCP host's env config.Graph API 403: ErrorAccessDenied— the Entra app is missing a delegated permission, or it needs admin consent. Check the list above, then re-consent and sign in again.Graph API 400: BadRequest — Syntax errorfromsearch_messages— the query goes to Graph's$searchas KQL. Quote literal phrases ("weekly report") or use fielded forms (from:alice). For predicates KQL cannot express, uselist_messageswithfilter=.- The host starts the server but lists no tools — confirm it launches
msgraph-mcp(oruvx) over stdio and can find that binary on itsPATH.
Development
See CONTRIBUTING.md.
MSGraph MCP questions
How do I add MSGraph MCP to Claude Code?
Run claude mcp add --env 'MSGRAPH_MCP_CLIENT_ID=<MSGRAPH_MCP_CLIENT_ID>' --env 'MSGRAPH_MCP_TENANT_ID=<MSGRAPH_MCP_TENANT_ID>' msgraph-mcp -- uvx msgraph-mcp-server in your terminal. Add --scope user to make it available in every project.
How do I add MSGraph MCP to Cursor?
Open ~/.cursor/mcp.json and add the server under mcpServers, using the Cursor config shown in the install section above.
What can the server access in Microsoft Teams?
The server provides read-only access to Microsoft Teams message history, including chats, channels, and message replies.
How do I sign in to the MSGraph MCP server?
You sign in once using the msgraph-mcp-login command, which uses the MSAL device code flow to print a URL and a code for you to visit.
Can the server manage shared mailboxes?
Yes, mail and calendar tools accept an optional mailbox parameter to target shared or delegated mailboxes.
What happens if I add new permissions to my Entra app later?
You must re-run the login command because sign-in requests all scopes at once; otherwise, tools requiring the new scope will fail.