跳过安装。2 分钟内即可运行。
在 cloud.anythingmcp.com 开始免费试用,一键添加 Word (Microsoft 365),然后将你的 AI 客户端(Claude、ChatGPT、Copilot 或 Cursor)指向生成的 MCP 端点。无需 Docker,无需 git clone,无需任何工程经验。
摘要
让你的 AI 处理 OneDrive 和 SharePoint 中的 Word 文档:查找文档,读取详细信息、版本历史和访问权限,以 PDF 或原始文件获取,从模板创建新文档,重命名、移动、签出和签入,并恢复早期版本。通过 Microsoft Graph 使用 Microsoft 365,以你的 Microsoft 账户登录;共享链接和删除在安装时关闭。
试试这样问
Word (Microsoft 365) 的示例提示
点击任意提示即可复制,然后粘贴到 Claude、ChatGPT、Cursor、Gemini、Copilot 或 OpenClaw 中,在该连接器上运行。
Claude 是 AI,可能会出错。请核对回答。
💡 无需安装? 直接使用 cloud.anythingmcp.com。 登录、点击 Connectors → Word (Microsoft 365)、粘贴凭证、生成 MCP API key,即可完成。无 Docker、无
git clone、无本地服务器。
Word (Microsoft 365) + Gemini
让你的 AI 处理 OneDrive 和 SharePoint 中的 Word 文档:查找文档,读取详细信息、版本历史和访问权限,以 PDF 或原始文件获取,从模板创建新文档,重命名、移动、签出和签入,并恢复早期版本。通过 Microsoft Graph 使用 Microsoft 365,以你的 Microsoft 账户登录;共享链接和删除在安装时关闭。
前提条件
完整的设置说明已内置在连接器中 (在 store 中选择连接器时可见)。所需环境变量:
MICROSOFT_CLIENT_ID, MICROSOFT_CLIENT_SECRET, MICROSOFT_TENANT_ID
步骤 1 — 获取凭证
设置大约需要 10 分钟。你需要存放文档的 OneDrive 或 SharePoint 所属的 Microsoft 账户,以及 Microsoft Entra 中一个免费的应用注册。
-
打开 https://entra.microsoft.com(或 https://portal.azure.com),进入 Applications → App registrations → New registration。
-
给应用起个名字,例如 "AnythingMCP Microsoft 365",并选择 Supported account types。这个选择决定
MICROSOFT_TENANT_ID填什么:- Accounts in this organizational directory only(单租户):应用 Overview 页面上的 Directory (tenant) ID(一个 GUID),或你的域名,例如
contoso.onmicrosoft.com。 - Accounts in any organizational directory(多租户):
organizations。 - Accounts in any organizational directory and personal Microsoft accounts:
common(工作、学校和个人账户)或consumers(仅个人账户)。
如果该值与账户类型不符,Microsoft 会以 AADSTS50194 或 AADSTS50020 拒绝登录。
- Accounts in this organizational directory only(单租户):应用 Overview 页面上的 Directory (tenant) ID(一个 GUID),或你的域名,例如
-
在 Redirect URI 下选择平台 Web,填写
<your AnythingMCP URL>/api/mcp-oauth/callback,在 AnythingMCP Cloud 上填写https://cloud.anythingmcp.com/api/mcp-oauth/callback。必须逐字符一致,否则 Microsoft 返回 AADSTS50011。 -
打开 API permissions → Add a permission → Microsoft Graph → Delegated permissions,添加
offline_access、User.Read和Files.ReadWrite。如果 AI 需要访问 SharePoint、Teams 中或别人共享给你的文档,再添加Files.ReadWrite.All(见 Scope)。 -
打开 Certificates & secrets → New client secret,复制密钥的 Value,不是 Secret ID;它只显示一次。记下到期日期:密钥过期后,连接器会停止工作,直到你粘贴新的密钥。
-
把 Application (client) ID 粘贴到
MICROSOFT_CLIENT_ID,密钥值粘贴到MICROSOFT_CLIENT_SECRET,第 2 步的租户值粘贴到MICROSOFT_TENANT_ID,然后安装连接器。 -
在连接器页面点击 Authorize with Provider,用 AI 要处理其文档的账户登录。刷新令牌加密保存,访问令牌(约一小时有效)会自动续期。
-
运行
microsoft_word_get_my_drive:它会显示连接器连接的是哪个 OneDrive。
一个 Entra 应用服务所有 Microsoft 连接器:为 Outlook、OneDrive 或 Excel 连接器创建的应用注册在这里同样可用。添加第 4 步的权限,保留相同的重定向 URI,并复用相同的客户端 ID、密钥和租户。每个连接器在授权时只请求自己的 scope。
管理员同意:这些委托权限通常不需要管理员,但许多组织关闭了用户同意。如果登录时显示 "Need admin approval"(AADSTS65001 或 AADSTS90094),租户管理员需打开一次应用注册,为组织点击 API permissions → Grant admin consent。
能看到谁的文档:所有操作都以授权连接器的用户身份执行,AI 能看到和修改的正是该用户能看到和修改的内容。工作或学校账户(Microsoft 365)支持所有工具;个人 OneDrive 支持搜索、详细信息、下载、PDF、复制、重命名和移动。
Scope:连接器请求 offline_access User.Read Files.ReadWrite。offline_access 让 Microsoft 签发刷新令牌,Files.ReadWrite 覆盖你自己的 OneDrive。要访问 SharePoint 文档库、Teams 频道中或他人共享的文档,以及使用 microsoft_word_find_documents,请在应用注册中添加 Files.ReadWrite.All,在连接器的 OAuth 设置中用它替换 Files.ReadWrite,然后重新授权。如需只读设置,使用 offline_access User.Read Files.Read.All,重新授权,并停用 microsoft_word_copy_document、microsoft_word_rename_document、microsoft_word_move_document、microsoft_word_restore_version、microsoft_word_check_out 和 microsoft_word_check_in。
读取的内容:Word 文档(.docx、.docm 和旧版 .doc)。它可以在你的 OneDrive 中按名称和内容查找(microsoft_word_search_my_documents,也会返回其他类型的文件),按 Documents/Contracts/Offer 2026.docx 这样的路径查找,浏览文件夹,或者用 microsoft_word_find_documents 通过 Microsoft Search 和 KQL 在你有权访问的所有位置(OneDrive、SharePoint、Teams、共享给你的文件)查找,仅限工作或学校账户。对每个文档,它读取名称、大小、创建者和最后修改者及其时间、在 Word 网页版中打开它的 webUrl、签出状态、版本历史以及谁有访问权限。要读取内容,microsoft_word_convert_to_pdf 让 Microsoft 365 把文档转换成 AI 能读的 PDF:Graph 没有返回文档文本的 API。microsoft_word_download_document 和 microsoft_word_download_version 提供原始文件或早期版本。
写入的内容:Graph 无法写入文档内部,连接器也不能上传文件。新文档通过 microsoft_word_copy_document 以新名称复制模板来创建;复制在后台进行,几秒后出现在目标文件夹中。此外,连接器可以重命名文档、在同一驱动器内移动文档、用 microsoft_word_restore_version 让早期版本重新成为当前版本(被替换的内容保留在历史中,因此可以撤销;仅限工作或学校账户),并在要求签出的 SharePoint 文档库中签出文档、带注释签入。之后由你通过 webUrl 自己编辑文档。
安装时关闭:microsoft_word_create_sharing_link(为 anonymous、organization 或 users 创建 view 或 edit 链接)和 microsoft_word_delete_document。共享链接会把文件交给其他人,而 AI 读到的文档可能会要求它共享或删除某些内容,所以由管理员在团队需要时开启。被删除的文档进入回收站,可以在那里恢复。
数据格式:每个工具都接收文档的 drive_id 和 item_id。搜索和按路径查找把它们作为 id 和 parentReference.driveId 返回;microsoft_word_find_documents 的结果在 hitsContainers[0].hits[] 中,使用 resource.id 和 resource.parentReference.driveId。microsoft_word_list_folder 配合 item_id root 列出驱动器的顶层。版本 ID 形如 4.0,按从新到旧排列。文件(包括 PDF)在 10 MB 以内会作为附件提供;更大的文件只给出描述而不附加,AI 会改为给你 webUrl。PDF 转换适用于 .docx、.docm、.doc、.dotx、.odt 和 .rtf 文件,不会改动已保存的文件。
分页和限制:只要还有更多结果,列表和搜索的响应就带有 @odata.nextLink;AI 会把该链接中的 $skiptoken 值填入 skip_token,再次调用同一个工具。microsoft_word_find_documents 用 from 和 size 分页,moreResultsAvailable 表示是否还有更多。Microsoft Graph 按用户和应用限流:返回带 Retry-After 的 429 或 503 时,请等待后重试。大文档转换为 PDF 可能需要几秒钟。
常见错误:401 InvalidAuthenticationToken 表示授权已被撤销或客户端密钥已过期:如有需要请粘贴新密钥,并再次点击 Authorize with Provider。403 accessDenied 表示缺少权限或未获同意,或者文档属于他人而 scope 中没有 Files.ReadWrite.All;没有 Files.Read.All 或 Files.ReadWrite.All 时,microsoft_word_find_documents 返回 403。404 itemNotFound 表示驱动器、项目或版本 ID 错误,或项目已被删除。PDF 转换返回 406 或 415 表示该文件类型无法转换或文件受密码保护。409 nameAlreadyExists 表示该文件夹中已有同名文件:换一个名称,或把 conflict_behavior 设为 rename。423 resourceLocked 表示文件已被他人签出或因编辑被锁定。
该连接器不上传 Word 文件,不编辑其内容,不读取或添加批注和修订,也不管理 SharePoint 网站(由 Microsoft SharePoint 连接器负责)。
步骤 2 — 安装 adapter
curl -fsSL https://raw.githubusercontent.com/HelpCode-ai/anythingmcp/main/docker-compose.quickstart.yml -o docker-compose.yml
printf 'JWT_SECRET=%s\nENCRYPTION_KEY=%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
docker compose up -d
步骤 3 — 在 Gemini 中添加连接器
你的服务器 URL: 在 AnythingMCP 中打开 MCP Servers → 此连接器所在的服务器,复制它的 URL(
https://cloud.anythingmcp.com/mcp/…)。本指南中出现YOUR_SERVER_ID的地方都用它替换。
Gemini CLI 从 ~/.gemini/settings.json(Windows 上为 %USERPROFILE%\.gemini\settings.json)读取 MCP 服务器。添加:
{
"mcpServers": {
"anythingmcp": {
"httpUrl": "https://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID",
"headers": { "X-API-Key": "YOUR_MCP_API_KEY" }
}
}
}
- 在 AnythingMCP 的 MCP Servers → 你的服务器 → API keys 中创建 MCP API 密钥,并用它替换
YOUR_MCP_API_KEY。 - 保存文件并重启
gemini。 - 在 Gemini CLI 中运行
/mcp(或在终端运行gemini mcp list),anythingmcp应显示为已连接。 - 开始输入提示,Gemini CLI 现在可以调用
Word (Microsoft 365)的工具。
可用工具
| Tool | What it does |
|---|---|
microsoft_word_get_my_drive | Get the signed-in user's OneDrive: drive id (the drive_id for documents stored there), type (personal or business), owner, storage quota… |
microsoft_word_search_my_documents | Search the user's own OneDrive by name, metadata and content, e.g. "offer 2026" |
microsoft_word_find_documents | Find Word documents everywhere the user has access (their OneDrive, SharePoint sites, Teams files, files shared with them) with Microsoft… |
microsoft_word_list_folder | List the files and folders inside a folder of a drive (item_id "root" for its top level), to browse to a document |
microsoft_word_get_document | Get a document's details: name, size, created and last modified (when and by whom), folder (parentReference), mimeType and hashes, sharing… |
microsoft_word_get_document_by_path | Get a document in the user's own OneDrive by its path, e.g. "Documents/Contracts/Offer 2026.docx" |
microsoft_word_download_document | Download the document file itself (.docx), as it is stored |
microsoft_word_convert_to_pdf | Get the document converted to PDF by Microsoft 365 (works for .docx, .docm, .doc, .dotx, .odt and .rtf files), attached to the result as a… |
microsoft_word_list_versions | List the document's version history: each version's id (e.g. "4.0"), when and by whom it was saved, and size, newest first |
microsoft_word_download_version | Download an earlier version of the document as an attached file (up to 10 MB), e.g. to compare it with the current one |
microsoft_word_list_permissions | List who has access to the document: each permission's id, roles (read, write, owner), the people or groups granted (grantedToV2… |
microsoft_word_copy_document | Create a new document as a copy of an existing one, typically a template (e.g. "Templates/Offer template.docx"), in a target folder under a… |
microsoft_word_rename_document | Rename a document in place |
microsoft_word_move_document | Move a document into another folder of the same drive, optionally renaming it on the way |
microsoft_word_restore_version | Make an earlier version the current content of the document |
microsoft_word_check_out | Check out a document in a SharePoint library that requires check-out, so that only the user can change it until it is checked in |
microsoft_word_check_in | Check a checked-out document back in, with a comment that is stored with the new version, so other people see the changes and can edit it… |
microsoft_word_create_sharing_link | Create a sharing link for the document: type "view" or "edit", scope "anonymous" (anyone with the link, if the organisation allows it)… |
microsoft_word_delete_document | Delete a document |
示例提示
- “在 SharePoint 中找到与 Contoso 的框架协议,总结其中的付款和终止条款。”
- “用 Templates/Offer template.docx 在 Offers 2026 文件夹里新建一份报价,命名为 Offer Acme 2026.docx。”
- “谁有权访问 Documents/Contracts/NDA Acme.docx?有没有匿名链接?”
- “显示这个文档的版本历史,并恢复上周一保存的版本。”
- “签出 HR 文档库里的差旅制度,方便我编辑,并给我在 Word 中打开它的链接。”
FAQ
Gemini CLI 从哪里读取 MCP 服务器? 用户级配置位于 ~/.gemini/settings.json,项目级配置位于项目内的 .gemini/settings.json。gemini mcp list 会列出每个服务器及其连接状态。
下一步
这份指南对你有帮助吗?