Skip to main content
Glama
MS 365-21V MCP Server

MS 365-21V MCP Server

MS 365-21V MCP Server

让支持 MCP 的 AI 客户端,以你的身份使用世纪互联 Microsoft 365。

查询邮件、安排日程、检索 OneDrive 和 SharePoint,连接 Microsoft Graph 中国区;保留用户权限、操作确认和审计边界。

CI License: Apache-2.0 Release

快速上手 · 完整部署 · 使用场景 · 工具目录 · English

一键接入(已有管理员部署)

管理员部署好服务并分配使用权限后,按对应客户端的方式添加 MCP 地址,再完成 OAuth 登录;不需要在客户端手动填写 client id / secret。

Claude Code:在项目根目录的 .mcp.json 中加入以下配置;已有 mcpServers 时合并其中的服务条目:

{
  "mcpServers": {
    "ms365-21v": {
      "type": "http",
      "url": "https://your-mcp-host.example.cn/mcp"
    }
  }
}

把 url 换成管理员给你的地址,启动 Claude Code 后运行 /mcp,按提示登录。Claude Code 官方说明

Claude Desktop:在 Customize(自定义)→ Connectors(连接器)→ Add custom connector(添加自定义连接器) 中填写远程 MCP 地址,按提示连接并登录。不要把上面的 Claude Code JSON 直接放进 Desktop 的本地配置。远程连接由 Anthropic 云端发起,服务地址需允许其访问,不能填写你电脑的 localhost。Claude Desktop 官方说明

使用 WorkBuddy、Qoder Work、Codex 或 Dify?看客户端接入说明。自己从零部署?看快速上手。

非 Microsoft 或 21Vianet 官方产品。需要世纪互联租户和管理员授权,不适用于直接连接全球版 Microsoft 365 或个人 Outlook 账号。本文中的业务示例需要对应模块与权限,初始配置只开放个人资料查询。

Related MCP server: MS 365-21V MCP Server

先看它能帮你做什么

你对 AI 说

能力

启用条件

“获取我的个人资料,确认当前登录账号。”

验证 OAuth → Graph 链路

快速上手的默认场景

“列出最近 5 封邮件,只显示主题和发件人。”

邮件读取

Mail 模块、Mail.Read、mcp.mail

“检查明天的会议是否有时间冲突。”

日程查询与冲突标记

Calendar 模块、Calendars.Read、mcp.calendar

“在我的 OneDrive 中查找项目计划。”

文件检索

OneDrive 模块、Files.Read、mcp.drive

“整理回复内容,发送前让我确认。”

邮件写入与确认

额外写权限;保持 MCP_SEND_MODE=confirm

工具会返回数据供 AI 客户端使用,不会因为接入 MCP 而授予用户原本没有的数据权限。完整角色、scope 和工具映射见工具目录。

为什么专门做一个 21V 版本

  • 中国区身份与数据端点:围绕 21V Entra 和 Microsoft Graph 中国区设计,而不是只替换全球版服务的域名。

  • 客户端接入更统一:Streamable HTTP + OAuth bridge,通过一个 MCP 地址连接;服务端使用当前用户的 delegated permissions / OBO。

  • 可控制的工具与写操作:App Roles、按模块与 scope 过滤、常用工具直达/长尾工具发现,以及确认与脱敏审计。

覆盖邮件、日历、OneDrive、SharePoint、Teams、联系人、组织用户和 Microsoft Search。代码中实现了工具,不等于你的租户已授权,也不等于每个全球云 API 都在 21V 可用。

快速开始

只使用别人已经部署好的服务?

不需要克隆仓库,也不需要自己创建 Entra 应用。向管理员获取 HTTPS MCP 地址及使用权限,在支持 Streamable HTTP 和 OAuth 的客户端添加它,然后登录。参见用户使用说明。

第一次部署?从“读取我的资料”开始

准备 Node.js 22+、Git,以及能配置 Entra 应用、同意权限并分配角色的管理员。先按快速上手完成单应用配置,再运行:

git clone https://github.com/mdwsk88/ms-365-21v-mcp-server.git
cd ms-365-21v-mcp-server
npm run setup

向导只询问 Tenant ID、API Client ID 和服务地址。它生成最小 .env,不会覆盖已有文件,也不会要求你把 client secret 放进命令行。编辑 .env 中的 MS_CLIENT_SECRET,使用 secret 的 Value,不是 Secret ID,然后运行:

npm run doctor
npm ci
npm run build
npm run start:http

本机桌面客户端连接 http://localhost:3000/mcp。远程或云端客户端需要能够访问的 HTTPS 地址;云端客户端的 localhost 不是你的电脑。

成功标准: 在客户端完成登录,调用 auth_status,再成功执行 graph_get_me。健康检查通过或能看到工具,都不等于 Graph 权限已经配置成功。

初始配置保持 OAuth、App Roles、审计和操作确认开启,只加载个人资料模块。后续按需启用邮件、日历等功能,不用一次申请全部权限。逐步启用只读邮件

已有部署请先运行 npm run doctor,不要重新生成或覆盖 .env。Docker、双应用、反向代理和生产检查见完整部署说明。

使用已发布的 Docker 镜像

配置好 Entra 和 .env 后,可以直接使用镜像,无需在本机编译:

docker compose -f docker-compose.release.yml pull
docker compose -f docker-compose.release.yml up -d

默认镜像为 ghcr.io/mdwsk88/ms-365-21v-mcp-server:v0.2.0,支持 Linux amd64 / arm64。使用旧版 Compose 文件时,在 .env 中设置 MCP_IMAGE_TAG=v0.2.0 后再执行上述命令;已有该设置时以你指定的版本为准。配置文件下载、首次启动和升级回退见 Docker 镜像说明,更新记录见 Releases。

配置错了,从哪里查?

npm run doctor
npm run --silent doctor -- --json

离线检查会提示缺失或占位凭据、错误的云端点、地址覆盖、端口格式和单/双应用凭据不匹配等常见问题。它不打印配置值、不访问网络,也不修改 Entra。检查通过不代表管理员同意、Conditional Access 或真实 OAuth/Graph 调用已经验证。

常见问题与检查边界

客户端兼容性

仓库此前记录 WorkBuddy、Qoder Work、Codex 和 Dify 已完成远程连接、OAuth、工具发现与调用验证;这不是本次维护对这些客户端最新版的重新认证。详细记录保留在完整部署说明。

其他客户端需要支持 Streamable HTTP、OAuth 资源元数据/授权服务器发现、浏览器回调和 Bearer token。客户端能打开登录页面,也仍可能被租户 MFA、设备合规或用户分配策略拦截。

安全边界

远程服务使用 HTTPS;生产凭据放入 Secret Manager;只授予实际需要的 Graph delegated permissions 和 App Roles。不要为解决登录问题关闭认证或直接开放全部模块。

使用中国区 Graph 不自动保证端到端数据不出境:工具结果还会发送给你选择的 AI 客户端/模型服务。上线前需审核客户端数据流、日志留存、模型供应商及组织合规要求。详见威胁模型和安全策略。

文档与参与

目标

入口

首次跑通、检查配置、逐步启用功能

快速上手

Docker、双应用、角色、生产部署

完整部署

实际使用方式与提示词

用户使用说明

工具及所需权限

工具目录

回调、设备策略与登录问题

Entra 登录排障

后续维护优先级与发布记录

维护路线 · Changelog

项目解决了你的 21V 接入问题,欢迎点一个 Star,也欢迎提交脱敏的使用反馈或客户端兼容性记录。贡献前请阅读 CONTRIBUTING.md;安全漏洞不要公开提交 Issue。

License

Apache License 2.0。Microsoft、Microsoft 365、Microsoft Entra、Microsoft Graph 等名称属于各自商标权利人,参见 TRADEMARKS.md。

Available Tools

16 tools
auth_clear_local_cacheClear Local Auth CacheA

Development only. Delete locally cached tokens and pending device-code login state. Chinese intents / 中文意图: 清除本地登录, 退出本地登录, 删除缓存令牌.

Inputs: no named parameters.

auth_complete_device_loginComplete Local Device LoginA

Development only. Poll the token endpoint after the user enters the device code, then cache the token locally. Token values are not returned. Chinese intents / 中文意图: 完成本地登录, 完成设备码登录, 保存本地令牌.

Inputs: timeoutSeconds.

auth_start_device_loginStart Local Device LoginA

Development only. Start a 21V Entra device-code login and cache the result locally. Chinese intents / 中文意图: 本地登录, 设备代码登录, 开发调试登录.

Inputs: scopes.

auth_statusCheck Auth StatusA

Inspect MCP auth state, local token state, remote OAuth/OBO configuration, and current request user details. Token values are never returned. Chinese intents / 中文意图: 查看认证状态, 检查登录状态, 诊断授权问题.

Inputs: no named parameters.

calendar_list_viewList Calendar ViewA
Read-only

List meetings and events, including recurring instances, in a date-time range: subject, time, location, organizer, my response, attendees and cancellation state. Requires delegated Calendars.Read. Chinese intents / 中文意图: 查看今天的会议, 按时间范围查看日历, 查看明天日程, 查看本周会议, 展开重复日程.

Inputs: endDateTime (required), startDateTime (required), top, timeZone.

confirm_executeExecute Approved OperationA

Continue a pending sensitive operation after the same signed-in user approved its web preview. This tool never grants approval itself. Call it only after the user says the confirmation page was approved; the token is user-bound, one-time, and short-lived. Chinese intents / 中文意图: 继续执行我刚刚在网页确认的操作, 执行已批准的敏感操作.

Inputs: confirmToken (required).

files_get_download_urlGet File Download URLA
Read-only

Resolve a OneDrive or SharePoint file from a link pasted in chat or mail, or from driveId and itemId, and return a short-lived pre-authenticated download URL for the client to fetch and parse. format pdf converts Office files to PDF first. Small plain-text files also return their text inline. SharePoint files also require the mcp.sharepoint App Role. Chinese intents / 中文意图: 打开SharePoint链接, 读取文档内容, 下载文件, 获取文件下载地址, 把Word转成PDF.

Inputs: url, format, itemId, driveId, +2 more.

gateway_execute_toolExecute Authorized ToolA
Destructive

Execute a tool returned by gateway_search_tools with parameters matching its inputSchema. The target tool is rechecked for App Roles, confirmation policy, audit, and Graph scope controls. Invalid parameters return the expected schema. Chinese intents / 中文意图: 执行搜索到的工具, 调用长尾工具, 执行Microsoft 365操作.

Inputs: toolName (required), parameters.

gateway_get_tool_schemaGet Tool SchemaA
Read-only

Get the exact input schema and authorization metadata for a tool returned by gateway_search_tools. Chinese intents / 中文意图: 查看工具参数, 获取工具Schema, 确认工具需要哪些参数.

Inputs: toolName (required).

gateway_search_toolsSearch Available ToolsA
Read-only

Search the signed-in user's authorized Microsoft 365 tools by English or Chinese intent, for anything the directly exposed tools do not cover (sending, scheduling, OneDrive and SharePoint management, contacts, users...). Top results include their input schema. Chinese intents / 中文意图: 搜索可用工具, 查找能完成任务的工具, 发现更多Microsoft 365能力.

Inputs: limit, query, category, schemaCount.

mail_get_messageGet Mail DetailsA
Read-only

Read one message as plain text with recipients and attachment list. onlyNewContent drops quoted earlier mails; long bodies continue with offset. Requires delegated Mail.Read. Chinese intents / 中文意图: 查看邮件详情, 读取邮件正文, 查看邮件内容, 查看邮件附件列表.

Inputs: messageId (required), offset, maxChars, bodyFormat, +2 more.

mail_list_messagesList My MailA
Read-only

List mail newest first with sender, recipients, preview, read and flag state. Filter by folder (inbox by default, or all), time window, unread, flagged, importance or sender address. Use mail_search_messages for keywords. Requires delegated Mail.Read. Chinese intents / 中文意图: 查看我的邮件, 看最近邮件, 查看未读邮件, 查看标旗邮件, 某段时间的邮件, 列出收件箱邮件.

Inputs: top, from, since, until, +5 more.

mail_search_messagesSearch My MailA
Read-only

Search mail by keywords with KQL, for example "budget", "from:Zhang Wei", "subject:review", "hasAttachments:true". Searches all folders unless folder is set. Requires delegated Mail.Read. Chinese intents / 中文意图: 搜索邮件, 按关键词查邮件, 查找某人发的邮件, 查找某封邮件.

Inputs: query (required), top, cursor, folder.

teams_list_chat_messagesList Teams Chat MessagesA
Read-only

Read messages in a Teams chat as plain text, oldest first within a page, with sender, @mentions and shared files. Supports a since/until window and nextCursor for older messages. Requires delegated Chat.Read. Chinese intents / 中文意图: 查看Teams聊天消息, 读取聊天记录, 查看群聊消息, 看某段时间的聊天.

Inputs: chatId (required), top, since, until, +3 more.

teams_list_chatsList My Teams ChatsA
Read-only

List one-on-one, group and meeting Teams chats, most recently active first, with member names and the last message. Use since to keep only chats with new messages, and query to find a chat by person or topic. Requires delegated Chat.Read. Chinese intents / 中文意图: 查看Teams聊天, 找和某人的聊天, 最近有新消息的聊天, 查看群聊和私聊, 列出Teams会话.

Inputs: top, query, since, cursor, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 16 tools

    Disambiguation4/5

    Most tools target distinct resources and actions (mail_list/search/get, teams_list_chats vs teams_list_chat_messages, auth_* lifecycle). The only mild overlap is gateway_search_tools already returning schemas while gateway_get_tool_schema exists for explicit schema retrieval, and gateway_execute_tool vs confirm_execute for executing operations, but descriptions clarify the boundaries.

    Naming Consistency4/5

    Names follow a predictable domain_verb_noun snake_case pattern (mail_list_messages, calendar_list_view, files_get_download_url, gateway_search_tools). Minor deviations like auth_status (noun-only) and confirm_execute (no domain prefix) are readable and don't break the overall convention.

    Tool Count4/5

    16 tools is slightly above the ideal 3-15 range but well justified by the breadth of Microsoft 365 domains covered (auth, mail, calendar, files, teams, gateway). The gateway pattern lets a small curated set extend to a long tail without bloating the direct surface.

    Completeness4/5

    Core read workflows are fully covered per domain (mail list/search/get, calendar list view, files search/download, teams chats/messages) plus a complete auth lifecycle. Write operations (send mail, create calendar events, upload files) are not directly exposed but are discoverable and executable through gateway_search_tools/gateway_execute_tool, so only minor gaps remain.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables MCP-compatible AI clients to access 21Vianet Microsoft 365 mail, calendar, OneDrive, SharePoint, Teams, contacts, and other Microsoft Graph China resources as the signed-in user, with delegated permissions, operation confirmation, and audit controls.
      -
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables MCP-capable AI clients to access 21Vianet-operated Microsoft 365 resources — mail, calendar, OneDrive, SharePoint, Teams, contacts, org users and search — through the China-region Microsoft Graph using per-user OAuth delegated permissions. It supports client connectivity over Streamable HTTP with an OAuth bridge, plus module/scope filtering, write-operation confirmation and desensitized auditing.
      -
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables MCP-capable AI clients to access and manage a user's 21Vianet Microsoft 365 mail, calendar, OneDrive, SharePoint, Teams, contacts, org users, and search through Microsoft Graph China, while respecting delegated permissions, confirmations, and audit boundaries.
      -
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables MCP-capable AI clients to access and act on a user's 21Vianet Microsoft 365 resources—mail, calendar, OneDrive, SharePoint, Teams, contacts, and search—via Microsoft Graph China while preserving delegated permissions, confirmations, and audit boundaries.
      MIT