
Outlook Mail
io.github.Pepebitsv1.0.1更新於 Oct 8, 2026
Read, search, send and clean up Outlook.com / Hotmail mail through Microsoft Graph.
概覽
讓助理透過 Microsoft Graph 讀取、搜尋、寄送與整理 Outlook.com 或 Microsoft 365 郵件。
- 功能
- 以 stdio 在本機執行,透過 OAuth 裝置代碼流程登入 Microsoft Graph。工具涵蓋瀏覽資料夾、列出與用 KQL 搜尋郵件、以純文字讀取內文、列出與下載附件、寄送郵件、建立草稿、回覆、轉寄、移動、標記、標示已讀與刪除郵件,還包括尋找電子報、取消訂閱,以及用收件匣規則封鎖寄件者。批次操作最多接受 50 個郵件 id。
- 適用情境
- 當你希望助理處理 Outlook、Hotmail 或 Microsoft 365 信箱時使用:分類與搜尋郵件、起草或寄送回覆、下載附件,或清理電子報與不需要的寄件者。唯讀模式適合只查看、不做任何變更的情境。
- 執行需求
- 需要 Node.js 24 或更新版本,以及一個 Microsoft 帳戶;個人帳戶可使用共用應用程式,公司或學校帳戶則需自行註冊 Azure 應用程式。選用環境變數包括 OUTLOOK_CLIENT_ID、OUTLOOK_TENANT、OUTLOOK_SCOPES、OUTLOOK_TOKEN_CACHE、OUTLOOK_READ_ONLY、OUTLOOK_DOWNLOAD_DIR 與 OUTLOOK_GRAPH_BASE_URL。登入是互動式的:login 工具會回傳網址與一次性代碼,也可在終端機執行 auth 指令。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Outlook Mail,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
A Model Context Protocol server that lets Claude, Codex and any other MCP client read, search, send and organize your Outlook / Microsoft 365 / Outlook.com mail through the Microsoft Graph API.
🔭 Overview
outlook-mcp runs locally over stdio. It signs in with the OAuth device code flow (no client secret, no redirect URI), stores the refresh token in a local file only you can read, and talks to Microsoft Graph with plain fetch.
✨ Features
- 📂 Browse folders, list and search messages (KQL), read bodies as sanitized plain text
- 📎 List and download attachments safely into a configured directory
- ✉️ Send mail, create drafts, reply, reply-all and forward (local attachments under 3 MB)
- 🗂️ Move, mark read/unread, flag and delete messages, one at a time or in bulk (
ids) - 📰 Find newsletters, unsubscribe from them and block unwanted senders with inbox rules
- 🔒 Read-only mode that removes every mutating tool
- 🔁 Automatic retry with
Retry-After/ exponential backoff for throttling (429/503/504) - 🧾 Logs only to stderr; never logs tokens or message bodies
📋 Requirements
- Node.js 24 (LTS) or newer
- A Microsoft account (personal works out of the box; work or school needs your own Azure app)
🚀 Quick start
No terminal sign-in and no Azure setup needed. You only need Node.js 24+.
Claude Code
Claude Desktop
Add to claude_desktop_config.json and restart Claude Desktop:
Codex (OpenAI)
Or add it to ~/.codex/config.toml (shared by the Codex CLI and IDE extension):
Run /mcp inside Codex to check that it is connected.
Other MCP clients
Any client that can launch a stdio MCP server works: run npx -y @pepebits/outlook-mcp as the server command.
Sign in
Ask your assistant to "log in to Outlook". The login tool returns a URL and a one-time code: open the URL, enter the code and accept. Prefer a terminal? Run npx -y @pepebits/outlook-mcp auth instead.
By default the server uses the shared outlook-mcp Azure app, which supports personal Microsoft accounts (outlook.com, hotmail, live). The consent screen may show an unverified publisher warning. No data passes through any server of ours: the server talks to Microsoft Graph directly from your machine and your tokens stay in the local token cache. For work or school accounts, or to use your own app, see Use your own Azure app.
⚙️ Configuration (.env)
The .env file is optional. Variables are read from .env in the current directory and in the package directory, and real environment variables override it. You can also pass them through your MCP client's env block, e.g. claude mcp add outlook --scope user -e OUTLOOK_TENANT=organizations -e OUTLOOK_CLIENT_ID=your-client-id -- npx -y @pepebits/outlook-mcp.
🔐 Authentication
You can also sign in without a terminal. Just ask your assistant to "log in to Outlook":
- 🔑
loginreturns a URL and a one-time code. Open the URL, enter the code and accept; sign-in finishes in the background. - ✅
auth_statustells you whether you are signed in, still waiting, or signed out. - 🚪
logoutremoves the cached account and the token cache file.
Use login with force: true to sign in again, for example after adding a permission in Azure. If the session is missing or expired, tools return "Not signed in or session expired. Call the login tool ...".
🛠️ Use your own Azure app (optional)
By default outlook-mcp uses the shared outlook-mcp Azure app, which works with personal Microsoft accounts only. Register your own app if you need work or school accounts or simply prefer to use your own. Then set OUTLOOK_CLIENT_ID (and OUTLOOK_TENANT, see below).
Step by step
-
Open portal.azure.com and go to Microsoft Entra ID -> App registrations -> New registration.
-
Give it a name (for example
outlook-mcp). -
Under Supported account types choose:
- Personal Microsoft accounts only (Outlook.com, Hotmail, Live), or
- Accounts in any organizational directory and personal Microsoft accounts (both).
- For work/school only, pick an organizational option.
-
Leave Redirect URI empty and click Register.
-
In the left menu go to Manage -> Authentication -> Settings tab, set Allow public client flows to Yes and save.
-
Go to Manage -> API permissions.
User.Readis already granted by default. Click Add a permission -> Microsoft Graph -> Delegated permissions and add:- 📬 Expand the Mail group and tick
Mail.ReadWriteandMail.Send. - ⚙️ Expand the MailboxSettings group and tick
MailboxSettings.ReadWrite(needed for inbox rules andblock_sender). - 🔑 Expand the OpenId permissions group and tick
offline_access.
Then click Add permissions. No admin consent is needed for personal accounts.
- 📬 Expand the Mail group and tick
💡 If you upgrade from 0.1.0, add
MailboxSettings.ReadWritein Azure and runloginwithforce: true(ornpx -y @pepebits/outlook-mcp auth) again.
💡 The Azure portal may be shown in your language, so labels can differ slightly (e.g. Administrar -> Autenticación -> Configuración, Permisos de OpenId).
- From the Overview page copy the Application (client) ID. This is your
OUTLOOK_CLIENT_ID.
🏢 Work or school accounts: set
OUTLOOK_CLIENT_IDto your app andOUTLOOK_TENANT=organizations(or your tenant GUID). Your organization may require admin consent for the mail permissions.
🧰 Tools reference
Bulk operations: the tools marked "Accepts id or ids" take exactly one of the two. With ids they process up to 50 messages (a few at a time), never stop at the first error and return { results: [{ id, ok, ... | error }], succeeded, failed }. With id the response is unchanged.
Well-known folder names accepted anywhere a folder id is expected: inbox, drafts, sentitems, deleteditems, junkemail, archive.
🧹 Cleaning up your inbox
Ask Claude something like "Find the newsletters cluttering my inbox, unsubscribe from the ones I don't read and block the rest". Behind the scenes:
find_newslettersscans the inbox and lists senders with aList-Unsubscribeheader, most frequent first, each with asampleMessageIdand anunsubscribemethod (one-click,mailtoorlink).unsubscribewithidsset to the chosen sample message ids leaves those lists. Senders that only offer a link come back with the URL to open in a browser.block_senderwithaddressesordomainscreates an inbox rule that sends their future mail to Deleted Items. Usedelete_messagewithidsto clear what is already in the inbox, andlist_rules/delete_ruleto review or undo a block.
Inbox rules need the MailboxSettings.ReadWrite permission (see the Azure steps above). Do not unsubscribe from spam or phishing: it confirms your address is active. Block those senders instead.
👁️ Read-only mode
Set OUTLOOK_READ_ONLY=true to register only the non-mutating tools. The mutating tools do not exist for the client, so they cannot be called at all. Combine it with a token cache created using only User.Read Mail.Read (set OUTLOOK_SCOPES accordingly and re-run npx -y @pepebits/outlook-mcp auth) for defense in depth.
🛡️ Security
- 🔑 The token cache is stored locally with mode
0600in a0700directory, written atomically. - 🙅 No client secret exists: this is a public client using device code flow.
- 🤐 Tokens and message bodies are never logged; MSAL PII logging is disabled.
- 📥 Attachment downloads are confined to
OUTLOOK_DOWNLOAD_DIR; path traversal is rejected. - ⚠️
delete_messagewithpermanent: trueis irreversible, andsend_mail,reply_messageandforward_messagesend immediately. Prefer read-only mode orcreate_draftwhen in doubt. - 🧠 Email content is untrusted input: a malicious message may try to instruct the model (prompt injection). Review actions that send or delete.
🩺 Troubleshooting
🧑💻 Development
Run it from source in your MCP client:
Use npm run inspect to try the tools in the MCP Inspector.
🚢 Releasing (maintainers)
- Move the
[Unreleased]notes inCHANGELOG.mdunder the new version, bump the version inpackage.jsonandserver.json(top level and package), commit and push. - Tag it:
git tag -a vX.Y.Z -m "Short summary" && git push origin vX.Y.Z. The Release workflow runs the tests, stages the version on npm (Trusted Publishing, with provenance) and creates the GitHub release. - Approve the staged version on npmjs.com (or
npm stage approve <stage-id>), which needs your 2FA. - The workflow waits for the approval, lists the version in the MCP Registry and announces the release on Telegram. If you approve more than ~6 hours later, the wait times out: run the Release workflow by hand (Actions → Release → Run workflow) with the tag to announce it.
🗺️ Roadmap
- 📅 Calendar support (
Calendars.ReadWrite) - 📦 Large attachments through upload sessions
- 👥 Contacts
🤝 Contributing
Issues and pull requests are welcome.
Please keep code, comments and docs in English, add tests for new behavior, and never log secrets or message content.
📄 License
來源:README.md,提交 8505169
工具
0版本歷史
1- v1.0.1最新Oct 8, 2026


