Microsoft 365 remote MCP server

Microsoft 365 remote MCP server

Gives Claude access to Microsoft 365 mail, calendar, files, and Teams chat with per-user identity via On-Behalf-Of flow. Supports reading and drafting content, but sending is deliberately disabled.

Category
访问服务器

README

Microsoft 365 remote MCP server

A remote MCP server that gives Claude access to Microsoft 365 — mail, calendar, files, and Teams chat — with per-user identity. Each person signs in through Microsoft as themselves, and the server exchanges that sign-in for a Graph token via the On-Behalf-Of flow, so every call runs with exactly that person's permissions. It does not hold one app identity with standing access to the whole tenant: if a user cannot see a message, neither can the server acting for them.

Built for and running in production at a small nonprofit.

Design stance

  • Acts as the user, not as the app. Sign-in is a PKCE proxy to Microsoft Entra, and every Graph call goes through On-Behalf-Of exchange of the caller's own token. The server never holds standing access to anyone's mail — no application permissions, no service-account mailbox, nothing to steal that would read a mailbox on its own.
  • Drafts only. Mail.Send is not requested, so it cannot be granted. The model composes; a human opens the draft and presses send. A compromised prompt or a confused model can at worst leave an unwanted draft in your Drafts folder. This is a deliberate boundary, not a missing feature.
  • Tenant-pinned. common and organizations are rejected at startup, and the tenant must parse as a GUID. A wildcard tenant would let Entra accept tokens issued by any organization — the single most damaging misconfiguration available on a public endpoint, so it is made unreachable rather than documented as a caution.

Architecture

User → Claude → /authorize → Microsoft Entra (login + consent)
Claude → /token  (two-leg PKCE proxy → Entra)          ← server holds the confidential client
Claude → /mcp  (Bearer = user token, aud = this app)
   └─ verify.ts: validate JWT (sig/iss/aud/exp + tenant pin + scope)
   └─ obo.ts: exchange for a Graph token (acts as the user)
   └─ tools.ts: call Microsoft Graph

Entra supports neither Dynamic Client Registration nor Client ID Metadata Documents, which is why this server is itself the OAuth authorization server Claude talks to: it exposes /register and brokers every flow down to one pre-registered Entra confidential client.

Setup

This is not a two-minute install, and pretending otherwise would waste your time. Before it will start you need:

  • an Entra app registration in your own tenant, exposing an access_as_user scope, with a client secret;
  • tenant-admin consent on eleven delegated Graph permissions (Mail.Send is not among them, by design);
  • a public HTTPS origin Claude can reach — Claude connects to your server over the internet, so localhost is not enough outside of npm run inspector.

docs/entra-setup.md walks the registration through from scratch, including which permissions to grant and why.

Config

Copy .env.example to .env and fill it in.

Var Required Notes
M365_CLIENT_ID ✅ Client id of your delegated Entra app
M365_CLIENT_SECRET ✅ Confidential-client secret (required by OBO)
M365_TENANT_ID ✅ Tenant GUID. common/organizations are rejected at startup.
M365_PUBLIC_URL ✅ Public HTTPS origin Claude reaches, no trailing slash
M365_ORG_NAME optional Your organization's name, used in the server instructions
M365_EXTRA_INSTRUCTIONS optional House-style notes appended to the server instructions (tone, signatures, place names)
M365_EVENTS_LIBRARY_PATH optional SharePoint library the default file-search scope narrows to; unset searches the whole tenant
M365_READ_ONLY optional true disables every write tool
M365_DEFAULT_TZ optional IANA zone, default America/New_York
M365_REDACT_PII optional true scrubs tokens, secrets, and email addresses from logs
M365_ALLOWED_REDIRECT_URIS optional Comma-separated exact /authorize redirect_uri allowlist. Defaults to https://claude.ai/api/mcp/auth_callback; set this only if a different client connects.
M365_TRUST_PROXY optional Default off. Set to 1 (or an Express hop count) only when running behind a reverse proxy you control, so X-Forwarded-For is trusted. With the port published directly, leaving this off is what keeps the rate limits enforceable.
M365_CORS_ORIGIN optional CORS origin allowed to call this server, default https://claude.ai
M365_GRAPH_TIMEOUT_MS optional Microsoft Graph request timeout in milliseconds, default 30000
PORT optional default 3000

Run

npm install
npm run build
M365_CLIENT_ID=… M365_CLIENT_SECRET=… M365_TENANT_ID=<guid> M365_PUBLIC_URL=https://… npm start

Local tool inspection over stdio, without a public host:

npm run inspector

The included Dockerfile is a plain multi-stage Node build that ships to any container host. No platform deploy configuration is included on purpose — where you run it is your decision, and a checked-in deploy manifest would only encode someone else's.

Tools

Read: search_email, get_email, search_calendar, get_event, find_meeting_times, search_files, get_file, search_teams_chat — with natural-language date parsing and offset pagination. Delegated/shared access via mailboxOwner / calendarOwner is supported by the four mailbox and calendar tools — search_email, get_email, search_calendar, get_event. find_meeting_times, search_files, get_file, and search_teams_chat always act as the signed-in user.

Write (all gated behind M365_READ_ONLY): draft_email, draft_reply, create_event, update_event, cancel_event. Drafts are auto-formatted — agent hard-wraps are healed so prose does not render as a frozen narrow column on mobile — and writes honour the same delegated mailboxOwner / calendarOwner access as the reads.

There is no send tool. See Drafts only, above.

Provenance and security

The auth and transport plumbing is adapted from softeria/ms-365-mcp-server (MIT). Every copied file was reviewed line-by-line before inclusion; the attribution is in NOTICE.md and the file-by-file review in docs/copied-code-audit.md.

Hardening applied over upstream:

  • Tenant-pinned config — the tenant is required and validated as a GUID; upstream defaults to common.
  • Full local JWT validation — signature, issuer, audience, expiry, tenant, and scope are checked against Entra's JWKS with jose before any Graph call. Upstream did an expiry-only pre-check and let the downstream Graph call be the real gate.
  • OBO only — no trust-proxy or token pass-through mode.
  • Curated tool surface — a deliberately chosen set of tools rather than a generated wrapper over the whole Graph API, with no send capability anywhere in it.

Licensed MIT — see LICENSE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选