
MSGraph MCP
io.github.timfurlong由 GitHub 帳號 timfurlong 發布v0.5.1更新於 Oct 24, 2026
MCP server for Microsoft Graph: Outlook mail and calendar, plus read-only Microsoft Teams
概覽
讓助理以登入使用者身分透過 Microsoft Graph 讀取與管理 Outlook 郵件、行事曆,以及唯讀的 Teams 訊息。
- 可以做什麼
- 這是一個本機 stdio MCP 伺服器,以 Microsoft Graph 為基礎,提供 Outlook 郵件與行事曆功能,以及唯讀的 Teams 訊息歷史。郵件工具支援列出、搜尋、讀取、傳送、回覆、轉寄、草稿、資料夾、規則、標幟,以及對最多 1000 封郵件執行批次操作。行事曆工具可列出、建立、更新、取消與回覆事件,並尋找會議時間。Teams 工具可列出聊天、已加入的團隊、頻道、頻道訊息、回覆與託管內容。回應會為助理精簡,也可選擇取得完整內文或原始 Graph 資料。
- 適用情境
- 當助理需要處理 Microsoft 365 信箱或行事曆時適用,例如整理與搜尋郵件、撰寫或傳送回覆、管理資料夾與規則、安排或回覆會議,或閱讀 Teams 聊天與頻道歷史。它以登入使用者身分運作,因此只能存取該帳號有權存取的內容。
- 執行需求
- 需要 Python 3.11 或更新版本,可透過 uv tool 或 pip 安裝,也可用 uvx 執行。需要一個 Entra(Azure AD)應用程式註冊,啟用公開用戶端流程、設定 nativeclient 重新導向 URI,並授予郵件、行事曆與 Teams 的委派 Graph 權限;ChannelMessage.Read.All 與部分共用權限需要租用戶系統管理員同意。設定 MSGRAPH_MCP_CLIENT_ID 與 MSGRAPH_MCP_TENANT_ID,執行一次裝置代碼登入,可選設定 MSGRAPH_MCP_TOKEN_CACHE_PATH。僅限桌面,透過 stdio 執行。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 MSGraph MCP,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
MSGraph MCP
[PyPI] [Python versions] [CI] [License: MIT]
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.
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.
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.
A token cache is written to ~/.msgraph-mcp/token_cache.bin.
3. Wire the server into your MCP host.
Claude Code:
Any other host, over stdio:
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
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:
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.
來源:README.md,提交 e541cdb
工具
0版本歷史
2- v0.5.1最新Sep 21, 2026
- v0.3.2Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分

