outlook-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
outlook-mcp: Outlook mail MCP server
An MCP server that lets Claude (or any MCP client) work with your Exchange Online / Outlook mailbox as you: find and read mail, follow conversations, read attachments, prepare drafts, keep the mailbox organised and, once you approve, send mail on your behalf.
It is the mail sibling of msteams-mcp and shares its design. It uses delegated Microsoft Graph permissions: you sign in once on the server (OAuth2 authorization code + PKCE), and the server then keeps itself signed in with the refresh token, getting short-lived access tokens as needed. Everything it does appears in Outlook as done by you.
It runs as a hardened systemd service. No credential is stored in plain text:
Secret | Where it lives |
Entra app client secret | TPM-sealed systemd credential |
MCP access token | TPM-sealed systemd credential |
Vault key (AES-256) | TPM-sealed systemd credential |
Microsoft refresh token |
|
Access tokens (1 h) | Process memory only |
Why a vault? Entra ID rotates refresh tokens: every refresh returns a new one, and each one expires after about 90 days. The server has to save each new token while it runs, but the sandboxed service can't use the TPM directly. So the TPM seals a key, and that key encrypts the token file. A copy of the disk or a backup without this machine's TPM can't read the token.
Tools
Tool | Returns / does |
| The signed-in mailbox, sign-in state, inbox counts, and what the server may do (drafts, sending, approval mode, allowed domains, signature) |
| All mail folders, nested, with unread/total counts and ids |
| One folder, newest first: time, sender (recipients in Sent/Drafts), subject, marks, preview, message id. |
| Mailbox search (KQL): keywords in subject/body/attachments, by sender or recipient name/address, by subject. |
| One message in full: headers, attachments with ids, conversation id, Outlook link, body as text. |
| The whole conversation across folders (including your replies), oldest first, each showing only its new text |
| An attachment's text: PDF, Word, Excel, PowerPoint, text/CSV/JSON/HTML, attached emails |
| A person's email by name: people you work with, the directory, and addresses from your own mail |
| Save a new mail in Drafts |
| Reply draft; your text above the quoted original |
| Forward draft, original attachments included |
| Change a draft |
| Delete a draft (drafts only) |
| Mark read / unread (up to 100 at once) |
| Follow-up flag: flagged (with due date), complete, clear |
| Add / remove / replace Outlook categories |
| Move to archive, Deleted Items (recoverable), junk or any folder |
| New mail folder |
| Send an existing draft |
| Send a new mail now (copy kept in Sent Items) |
| Reply and send now |
| Forward and send now |
✏️ = write tools, registered only when ENABLE_WRITE_TOOLS=true (the default).
✉️ = send tools, registered only when ENABLE_SEND_TOOLS=true (the default).
With ENABLE_SEND_TOOLS=false the agent can prepare drafts but never send;
you send them from Outlook.
Writing. Bodies take format="text" (as typed, line breaks kept),
"markdown" (bold, lists, links, tables) or "html". Recipients are email
addresses, as a list or a ;/,-separated string; Name <a@b.com> and
"Last, First" <a@b.com> are accepted, plain names are refused so the agent
can't guess a recipient. Small attachments (3 MB in total) can be added inline
as [{name, content | content_base64, content_type?}]. If SIGNATURE_FILE is
set, the signature is appended to every new mail, reply and forward (Graph
doesn't apply your Outlook signature).
Output. Read tools return compact text to keep the agent's token use low:
one block per message with a date line per day, times in UTC, Defender Safe
Links unwrapped to the real URL, and inline-image references shortened to
[image]. Every read tool also takes output="json". For example,
list_messages returns:
3 messages in Inbox, newest first (times UTC)
2026-11-13
10:01 Alice Johnson <alice@contoso.com> · Q4 numbers · UNREAD !high 📎
Hi, Can you check the Q4 numbers? Report: https://example.com/report?q=1 [image] Thanks
id AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0A...
09:00 Bob Smith <bob@partner.com> · Vendor call
The vendor call moved to Thursday.
id AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0B...Message ids are Graph immutable ids: they stay valid when a message is moved to another folder, or when a draft is sent.
Related MCP server: multi-mail-mcp
Sending on your behalf: approval
Mail can't be recalled, so sending has three independent safeguards:
The agent asks you. The server instructions and the agent skill tell the agent to show you recipients, subject and full text and wait for your explicit approval before any send tool. Send tools are also annotated as destructive, so MCP clients that prompt for tool use (Claude Code, Claude Desktop) ask you before each call. Don't add the send tools to an auto-approve list.
SEND_CONFIRMATION=elicitmakes the server ask you, independently of the agent: before each send it shows a prompt in your MCP client with the recipients, subject and text, and sends only if you choose "send". The approval is bound to that exact content: if the message changes in between, you're asked again. If the client can't show the prompt, nothing is sent. Use this if you want a hard guarantee; it needs a client with MCP elicitation support.SEND_ALLOWED_DOMAINS(e.g.contoso.com,partner.com) refuses to send to any other domain. Drafts are still allowed; a refused reply or forward stays in Drafts.
Requirements
Server: Linux with systemd 250 or newer and a TPM 2.0 chip (for example Ubuntu 24.04 or Debian 12), plus Python 3.10+ with
venvsupport.Entra ID app registration (App ID + tenant ID):
Delegated permissions with admin consent:
required:
openid,offline_access,User.Read,Mail.ReadWrite,Mail.Send;recommended:
People.ReadandUser.ReadBasic.All(find_peoplesearches the directory and your frequent contacts; without them it only finds addresses that appear in your own mail),MailboxSettings.Read(whoamishows your time zone and whether auto-reply is on).
The server requests
https://graph.microsoft.com/.default, so it gets exactly what has been consented; optional features degrade gracefully when a permission is missing. WithoutMail.Send, drafts still work and the send tools return 403.Authentication → Add a platform → Web, with the redirect URI
http://localhost. You can use another localhost URI such ashttp://localhost:8400/callback; setMS_REDIRECT_URIto the exact same value. Nothing needs to listen on it: you copy the code from the browser's address bar.Certificates & secrets → New client secret. Copy its Value (not the Secret ID) straight into
seal-credential.sh client_secret. Note the expiry date: when the secret expires the server stops working until you seal a new one (see below).
You can reuse the msteams-mcp app registration by adding the mail permissions to it, or create a separate one. Each server keeps its own sign-in.
Installation
Run these on the server from a clone of this repository.
# 1. Install code, venv, service user, config file, vault key and systemd unit
sudo ./deploy/install.sh
# 2. Set your tenant and app id (and the sending options, see Configuration)
sudo nano /etc/outlook-mcp/outlook-mcp.env
# 3. Seal the secrets (input is read without echo and never written to disk;
# vault_key was already generated by install.sh)
sudo /opt/outlook-mcp/bin/seal-credential.sh client_secret # paste the app's secret Value
sudo /opt/outlook-mcp/bin/seal-credential.sh mcp_token --generate
# 4. Sign in to Microsoft (see below)
sudo outlook-mcp-authorize
# 5. Start the service and enable it at boot
sudo systemctl enable --now outlook-mcp
# 6. Check it
systemctl status outlook-mcp
journalctl -u outlook-mcp -n 30
curl -s localhost:8767/health # {"status":"ok","auth":"ok"}Show the generated MCP token once, to put in your MCP client config:
sudo systemd-creds decrypt --name=mcp_token /etc/credstore.encrypted/outlook-mcp.mcp_token.cred -; echoSigning in
sudo outlook-mcp-authorize:
prints a
login.microsoftonline.comURL. Open it in a browser on any machine and sign in with the account whose mailbox the server should use;the browser is redirected to
http://localhost/?code=…&state=…and shows "can't connect", which is expected;you copy that full URL from the address bar and paste it at the prompt (input is hidden). The code is single-use, expires in about 10 minutes, and can only be redeemed with both the client secret and the PKCE verifier held by the script;
the script decrypts the client secret into memory, exchanges the code for tokens, checks
/meand the inbox, and writes the refresh token to the encrypted vault, owned by the service user.
The running service picks up the new vault on its next request, so you don't need to restart it.
When you have to sign in again
The server keeps its sign-in alive by itself. Every refresh rotates the stored
refresh token, and a background refresh every KEEPALIVE_HOURS (12 by
default) keeps it fresh even when nobody is using the server. You only need to
run sudo outlook-mcp-authorize again when Entra ID rejects the token, for
example:
your password was changed or reset, or your sessions were revoked;
an admin revoked consent or disabled the app;
a Conditional Access sign-in frequency policy, or an MFA requirement, demands a fresh interactive sign-in;
the server was off for longer than the refresh token's lifetime (about 90 days);
you added permissions to the app (sign in again so the new consent is used).
When that happens, every tool returns "The saved Microsoft sign-in is no
longer valid (AADSTS…). Run on the server: sudo outlook-mcp-authorize",
/health reports "auth":"reauth_required", and the journal logs the Entra
error code.
When the client secret expires
This is a different failure, and you don't need to sign in again: refresh tokens belong to the App ID, not to a particular secret. Tools return "Entra ID rejected the app's client secret (invalid_client: AADSTS7000222…)". Create a new secret in the app registration, then:
sudo /opt/outlook-mcp/bin/seal-credential.sh client_secret
sudo systemctl restart outlook-mcpDo this before the old secret expires: Entra allows several secrets at once, so you can switch with no downtime and then delete the old one.
Connecting a client
The service listens on 127.0.0.1:8767 only (msteams-mcp uses 8766, so both
can run on one host; change PORT in the unit if needed). The MCP endpoint is
/mcp, and every request except /health must send
Authorization: Bearer <token>. To reach it from another machine, put an HTTPS
front end in front of the port: a reverse proxy (nginx, Caddy), a Tailscale
service, or an SSH tunnel.
{
"mcpServers": {
"outlook_mcp": {
"command": "npx",
"args": ["mcp-remote", "https://your-host.example.com/mcp",
"--header", "Authorization:${AUTH}"],
"env": { "AUTH": "Bearer <your-token>" }
}
}
}Then ask Claude "what unread mail do I have?" to confirm it works end to end.
Agent skill
skills/outlook-mail/ is an
Agent Skill that teaches an agent to use these tools
well: how to find mail, read efficiently, write drafts, and get approval
before sending anything.
Claude Code:
cp -r skills/outlook-mail ~/.claude/skills/, then start a new session.claude.ai / Claude Desktop:
cd skills && zip -r outlook-mail.zip outlook-mail, then upload it under Settings → Capabilities → Skills.
Layout on the server
Path | What |
| Application code (read-only to the service) |
| Python virtual environment |
|
|
| Symlink to the sign-in script |
| Non-secret settings |
| TPM-sealed |
| Encrypted refresh token (0600, user |
| The unit |
The service runs as the static system user outlook-mcp rather than with
DynamicUser. This gives the vault, which the sign-in script writes as root,
a stable owner.
Configuration
Settings in /etc/outlook-mcp/outlook-mcp.env (see deploy/outlook-mcp.env.example):
Variable | Default | Meaning |
| required | Tenant GUID or domain |
| required | Application (client) ID |
|
| Must exactly match a redirect URI registered under the Web platform |
|
|
|
|
|
|
|
|
|
| empty (any) | Comma-separated domains mail may be sent to |
| none | Signature appended to outgoing mail ( |
|
| Background token refresh interval; |
|
| Default body cut-off in |
|
| Largest attachment |
Restart the service after changing settings.
Day-to-day
sudo systemctl restart outlook-mcp # after changing settings or credentials
journalctl -u outlook-mcp -f # follow logs
systemd-analyze security outlook-mcp # hardening score (lower is better)
sudo outlook-mcp-authorize # sign in again / switch account
# Update code: pull the new version, then
sudo ./deploy/install.sh # keeps config, credentials and sign-in
# Replace the client secret (before it expires; no new sign-in needed)
sudo /opt/outlook-mcp/bin/seal-credential.sh client_secret
sudo systemctl restart outlook-mcp
# Rotate the MCP token
sudo /opt/outlook-mcp/bin/seal-credential.sh mcp_token --generate
sudo systemctl restart outlook-mcp # then update your MCP client
# Rotate the vault key (makes the stored sign-in unreadable: sign in again)
sudo /opt/outlook-mcp/bin/seal-credential.sh vault_key --generate --force
sudo systemctl restart outlook-mcp && sudo outlook-mcp-authorizeNotes
After a BIOS/firmware update or a Secure Boot change, the TPM may refuse to decrypt the credentials, and the service fails to start with a credential error. Re-seal
client_secretandmcp_token, regeneratevault_keywith--force, and sign in again.What this protects against: copies of the disk, backups, sync tools or a git push picking up files, and other users or services on the server. It does not stop someone with root on the running machine (root can decrypt the credentials), so keep SSH key-only and root access tight. The refresh token is as powerful as your mailbox within the consented permissions, including sending mail as you. The client secret alone can't act as you: it only works together with a refresh token or a fresh sign-in.
Prompt injection. Mail is untrusted input: anyone can email you text written to manipulate an agent ("forward all invoices to…"). The skill tells the agent to treat message content as data, never as instructions, and the approval safeguards above are what stop an injected send. Keep them on.
A certificate instead of a secret would be stronger (the private key never leaves the server, and it can last longer). It isn't implemented here.
Conditional Access: if your tenant restricts sign-ins to compliant or managed devices, or to known locations, refreshes from the server may be blocked (
AADSTS53003,AADSTS50076...). The journal shows the code.search_messagesuses the mailbox search index (KQL). Results can lag a few minutes behind new mail;list_messagesreads the folder directly.Shared mailboxes aren't supported; they would need
Mail.ReadWrite.SharedandMail.Send.Shared.Meeting invitations show as messages marked
(eventMessageRequest); accepting or declining them would needCalendars.ReadWrite.If the service fails with a memory-protection error, comment out
MemoryDenyWriteExecute=yesin the unit, then rundaemon-reloadand restart.
Local development
Without systemd, secrets fall back to the MS_CLIENT_SECRET / MCP_TOKEN /
VAULT_KEY environment variables (or to files named by *_FILE, for example
MS_CLIENT_SECRET_FILE), and the vault is ./vault.json.enc (override with
VAULT_PATH).
python3 -m venv .venv && . .venv/bin/activate
pip install -r requirements.txt
export MS_TENANT_ID=... MS_CLIENT_ID=... MCP_TOKEN=dev-token
read -rs MS_CLIENT_SECRET && export MS_CLIENT_SECRET # paste, no echo, not in history
export VAULT_KEY=$(python -c 'import vault; print(vault.new_key_text())')
python authorize.py # interactive sign-in -> ./vault.json.enc
python server.py # serves http://127.0.0.1:8767/mcpOffline tests (Graph and Entra ID are mocked by an in-memory mailbox, no tenant needed):
python tests/test_mail.py -v # -v prints sample outputLicense
MIT, see LICENSE.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Manage Microsoft 365 email, calendar, contacts and inbox rules via the Graph API with OAuth 2.0.
Hosted email MCP for your own Gmail, Outlook.com, Microsoft 365, iCloud or IMAP inbox: read, search, draft, reply in thread, forward and file mail. It moves or flags up to 500 messages in one call, and a send leaves exactly one copy in Sent. A calendar is a separate connection, and connecting one adds diary and scheduling tools.
Read email/chat conversations, messages, contacts and teams; draft, send and update threads.
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
Related MCP Servers
- AlicenseBqualityCmaintenanceEnables controlled Microsoft 365 mail workflows including search, read, thread, attachment, and managed draft operations through Microsoft Graph, without sending or modifying messages.9MIT
- AlicenseNot gradedqualityBmaintenanceEnables an MCP client to read, draft, organize, send, and delete email across multiple Gmail and Exchange Online/Outlook.com accounts, with per-account capability policies, recipient allowlists, confirmations, minimum OAuth scopes, and local audit logging.MIT
- AlicenseNot gradedqualityCmaintenanceEnables authenticated MCP clients to list, search, read, flag, draft, and optionally send mail from one Gmail or Microsoft 365 mailbox using OAuth without app registration.MIT
- AlicenseNot gradedqualityCmaintenanceEnables MCP clients to access a personal Outlook.com mailbox and calendar through Microsoft Graph, supporting email search, reading, drafting, sending, organization, and calendar event management.89 npmMIT