连接器指南阅读约 5 分钟19 个 MCP 工具7 种语言

如何通过 MCP 将 Microsoft OneDrive 连接到 Gemini

让你的 AI 在 OneDrive 中工作:浏览和搜索文件与文件夹,查看详情和有权访问的人,创建文件夹,上传和更新文本文件,复制、重命名和移动。通过 Microsoft Graph 支持工作或学校版 OneDrive 和个人版 OneDrive,使用你的 Microsoft 账户登录。

HC作者:HelpCode 团队更新于 5 分钟阅读 在 GitHub 开源

无需信用卡 · 7 天试用 · 提供自托管方案

OneDrive (Microsoft 365)

OneDrive (Microsoft 365)

Let your AI work in OneDrive: browse and search files and folders, see details and who has access, create folders, upload and update text files, copy, rename and move. OneDrive for work or school and personal OneDrive through Microsoft Graph, signed in with your Microsoft account.

个工具

19

区域

INTL

类别

文件存储

身份验证

OAuth 2.0

所需环境变量

MICROSOFT_CLIENT_IDMICROSOFT_CLIENT_SECRETMICROSOFT_TENANT_ID
在 Cloud 上一键安装

7 天免费试用 · 无需信用卡

  • 7 天免费试用
    无需信用卡
  • 符合 GDPR,SOC 2 就绪
    数据驻留欧盟,审计日志
  • 在 GitHub 开源
    开源 · AGPL-3.0
  • 支持 ChatGPT、Claude、Gemini
    任何兼容 MCP 的客户端

跳过安装。2 分钟内即可运行。

在 cloud.anythingmcp.com 开始免费试用,一键添加 OneDrive (Microsoft 365),然后将你的 AI 客户端(Claude、ChatGPT、Copilot 或 Cursor)指向生成的 MCP 端点。无需 Docker,无需 git clone,无需任何工程经验。

开始免费试用

摘要

让你的 AI 在 OneDrive 中工作:浏览和搜索文件与文件夹,查看详情和有权访问的人,创建文件夹,上传和更新文本文件,复制、重命名和移动。通过 Microsoft Graph 支持工作或学校版 OneDrive 和个人版 OneDrive,使用你的 Microsoft 账户登录。

试试这样问

OneDrive (Microsoft 365) 的示例提示

点击任意提示即可复制,然后粘贴到 Claude、ChatGPT、Cursor、Gemini、Copilot 或 OpenClaw 中,在该连接器上运行。

OneDrive (Microsoft 365) · 通过 MCP 实时
分享
Opus 4.7

Claude 是 AI,可能会出错。请核对回答。

💡 无需安装? 直接使用 cloud.anythingmcp.com。 登录、点击 Connectors → OneDrive (Microsoft 365)、粘贴凭证、生成 MCP API key,即可完成。无 Docker、无 git clone、无本地服务器。

Microsoft OneDrive + Gemini

让你的 AI 在 OneDrive 中工作:浏览和搜索文件与文件夹,查看详情和有权访问的人,创建文件夹,上传和更新文本文件,复制、重命名和移动。通过 Microsoft Graph 支持工作或学校版 OneDrive 和个人版 OneDrive,使用你的 Microsoft 账户登录。

前提条件

完整的设置说明已内置在连接器中 (在 store 中选择连接器时可见)。所需环境变量:

MICROSOFT_CLIENT_ID, MICROSOFT_CLIENT_SECRET, MICROSOFT_TENANT_ID

步骤 1 — 获取凭证

  1. 打开 Microsoft Entra 管理中心(entra.microsoft.com)或 Azure 门户,进入 Applications → App registrations → New registration。

  2. 为应用命名(例如 "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)。

  3. 在 Redirect URI 下选择平台 Web,填写 https://cloud.anythingmcp.com/api/mcp-oauth/callback。如果你自行托管 AnythingMCP,则改为填写 https://your-anythingmcp-host/api/mcp-oauth/callback。URI 必须逐字符一致,否则 Microsoft 会返回 AADSTS50011。

  4. 打开 API permissions → Add a permission → Microsoft Graph → Delegated permissions,添加 offline_access、User.Read 和 Files.ReadWrite。offline_access 让 Microsoft 签发刷新令牌;缺少它,连接器会在授权一小时后停止工作。

  5. 打开 Certificates & secrets → New client secret。复制密钥的 Value,而不是 Secret ID;它只显示一次。记下到期日期:密钥过期后,连接器会停止工作,直到你创建新密钥并填入。

  6. 将 Overview 页面上的 Application (client) ID 填入 MICROSOFT_CLIENT_ID,将密钥值填入 MICROSOFT_CLIENT_SECRET,将第 2 步中的租户值填入 MICROSOFT_TENANT_ID,然后安装连接器。

  7. 在连接器页面点击 Authorize with Provider,用 AI 要使用其 OneDrive 的账户登录。刷新令牌会加密保存,访问令牌(有效期约一小时)会自动续期。

  8. 先运行 onedrive_get_drive:它会显示连接器登录的是哪个 OneDrive,以及还剩多少存储空间。

一个 Entra 应用服务所有 Microsoft 连接器:你为 Outlook、SharePoint 或 Excel 连接器创建的应用注册在这里同样适用。打开它,在 API permissions 下添加第 4 步中的权限,保留相同的重定向 URI,并复用同一个客户端 ID、密钥和租户。每个连接器在授权时只请求它自己需要的权限:

  • Outlook:Mail.ReadWrite、Mail.Send、Calendars.ReadWrite
  • OneDrive:Files.ReadWrite
  • Excel:Files.ReadWrite(工作簿位于 SharePoint 中或由他人共享给你时,还需要 Files.ReadWrite.All)
  • SharePoint:Sites.ReadWrite.All 和 Files.ReadWrite.All

它们都还需要 offline_access 和 User.Read。

管理员同意:这些委托权限通常不需要管理员,但许多组织关闭了用户同意。如果登录时显示 "Need admin approval"(AADSTS65001 或 AADSTS90094),需要租户管理员打开一次应用注册,点击 API permissions → Grant admin consent 为整个组织授予同意。之后每个用户都可以授权。每个连接器仍然只能处理登录账户有权查看的内容。

共享给你的文件:Files.ReadWrite 涵盖你自己的 OneDrive。要打开其他人共享给你的文件,请在应用注册中添加 Files.ReadWrite.All,在连接器的 OAuth 设置中用它替换 Files.ReadWrite,然后重新授权。

只读设置:在连接器的 OAuth 设置中将 scopes 替换为 offline_access User.Read Files.Read(或 Files.Read.All),重新授权,并停用 onedrive_create_folder、onedrive_upload_text_file、onedrive_replace_file_content、onedrive_copy_item、onedrive_rename_item 和 onedrive_move_item。

安装时默认关闭:onedrive_delete_item、onedrive_create_sharing_link 和 onedrive_invite。共享链接和邀请是有意关闭的:它们会让其他人访问你的文件,而 AI 读取的文档里可能含有要求它共享内容的文字。只有在 AI 确实需要时才打开某个工具。删除的项目会进入 OneDrive 回收站,可以从那里恢复。

文件和内容:连接器可以列出、搜索和描述文件,但不会下载文件,AI 会改为给你文件的链接。它可以创建最大约 4 MB 的文本文件(.txt、.md、.csv、.json、.html、.xml)并覆盖它们;OneDrive 会在文件的版本历史中保留之前的内容。要处理 Excel 工作簿中的单元格,请使用 Microsoft Excel 连接器。

常见错误:401 InvalidAuthenticationToken 表示授权已被撤销或客户端密钥已过期;如有需要填入新密钥,然后再次点击 Authorize with Provider。403 accessDenied 表示缺少第 4 步中的某个权限或该权限未获同意,或者你无权修改该项目。404 itemNotFound 表示 id 或路径错误、项目已被删除,或它位于其他人的云盘中。409 nameAlreadyExists 表示文件夹中已有同名项目。423 resourceLocked 表示文件正处于编辑状态或已被签出。

连接器不下载文件内容,不上传二进制文件或超过 4 MB 的文件,不恢复版本,不清空回收站,也不打开其他用户的 OneDrive 和 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" }
    }
  }
}
  1. 在 AnythingMCP 的 MCP Servers → 你的服务器 → API keys 中创建 MCP API 密钥,并用它替换 YOUR_MCP_API_KEY。
  2. 保存文件并重启 gemini。
  3. 在 Gemini CLI 中运行 /mcp(或在终端运行 gemini mcp list),anythingmcp 应显示为已连接。
  4. 开始输入提示,Gemini CLI 现在可以调用 Microsoft OneDrive 的工具。

可用工具

ToolWhat it does
onedrive_get_driveGet the signed-in user's OneDrive: drive id, type (personal, business), owner, storage quota (total, used, remaining, deleted, state) and…
onedrive_list_rootList the files and folders at the top of the user's OneDrive: id, name, size, dates, who changed it last, folder child count or file…
onedrive_list_folderList the files and folders inside one folder, addressed by its id
onedrive_list_folder_by_pathList the files and folders inside a folder addressed by its path from the top of the OneDrive, e.g. "Documents/Reports"
onedrive_get_itemGet one file's or folder's metadata by id: name, size, dates, creator and last modifier, parent folder (parentReference with driveId, id…
onedrive_get_item_by_pathGet one file's or folder's metadata by its path from the top of the OneDrive, e.g. "Documents/Budget 2026.xlsx"
onedrive_get_shared_itemGet the metadata of an item in another drive, typically a file someone shared with the user: pass remoteItem.parentReference.driveId and…
onedrive_searchSearch the user's own OneDrive for files and folders whose name, metadata or content matches the text
onedrive_search_sharedSearch the user's OneDrive and the files other people shared with the user
onedrive_create_folderCreate a folder inside a parent folder (default: the top of the OneDrive)
onedrive_upload_text_fileCreate a new text file (.txt, .md, .csv, .json, .html, .xml...) with the given content in a folder, in one call, up to about 4 MB
onedrive_replace_file_contentOverwrite the content of an existing text file with new text (up to about 4 MB)
onedrive_copy_itemCopy a file or folder (with its contents) into a folder, optionally under a new name
onedrive_rename_itemRename a file or folder in place
onedrive_move_itemMove a file or folder into another folder of the same OneDrive, optionally renaming it on the way
onedrive_delete_itemDelete a file or folder (a folder with its contents)
onedrive_list_permissionsList who has access to a file or folder: each permission's id, roles (read, write, owner), the people or groups granted (grantedToV2…
onedrive_create_sharing_linkCreate a sharing link for a file or folder: type "view" or "edit", scope "anonymous" (anyone with the link, if the organisation allows it)…
onedrive_inviteGive people access to a file or folder by email address, with role "read" or "write", and optionally send them an invitation email with a…

示例提示

  • “我的“文档/2026 报告”文件夹里有什么?本周有哪些文件改动过?”
  • “找出关于汉堡展会的文件,包括同事共享给我的那些。”
  • “新建一个“第四季度规划”文件夹,并把这份会议纪要以 notes.md 的形式保存在里面。”
  • “谁有权访问“合同”文件夹?它有没有共享链接?”

FAQ

Gemini CLI 从哪里读取 MCP 服务器? 用户级配置位于 ~/.gemini/settings.json,项目级配置位于项目内的 .gemini/settings.json。gemini mcp list 会列出每个服务器及其连接状态。

下一步

这份指南对你有帮助吗?

你的 OneDrive 智能体只差一次点击。

安装连接器,粘贴密钥,向 Gemini 提问。免费试用 7 天,无需信用卡。

相关指南

连接器

如何通过 MCP 将 Microsoft OneDrive 连接到 ChatGPT

让你的 AI 在 OneDrive 中工作:浏览和搜索文件与文件夹,查看详情和有权访问的人,创建文件夹,上传和更新文本文件,复制、重命名和移动。通过 Microsoft Graph 支持工作或学校版 OneDrive 和个人版 OneDrive,使用你的 Microsoft 账户登录。

连接器

如何通过 MCP 将 Microsoft OneDrive 连接到 Claude

让你的 AI 在 OneDrive 中工作:浏览和搜索文件与文件夹,查看详情和有权访问的人,创建文件夹,上传和更新文本文件,复制、重命名和移动。通过 Microsoft Graph 支持工作或学校版 OneDrive 和个人版 OneDrive,使用你的 Microsoft 账户登录。

连接器

如何通过 MCP 将 Microsoft OneDrive 连接到 Cursor

让你的 AI 在 OneDrive 中工作:浏览和搜索文件与文件夹,查看详情和有权访问的人,创建文件夹,上传和更新文本文件,复制、重命名和移动。通过 Microsoft Graph 支持工作或学校版 OneDrive 和个人版 OneDrive,使用你的 Microsoft 账户登录。

连接器

如何通过 MCP 将 Microsoft OneDrive 连接到 Meta Muse

让你的 AI 在 OneDrive 中工作:浏览和搜索文件与文件夹,查看详情和有权访问的人,创建文件夹,上传和更新文本文件,复制、重命名和移动。通过 Microsoft Graph 支持工作或学校版 OneDrive 和个人版 OneDrive,使用你的 Microsoft 账户登录。

连接器

Microsoft OneDrive 接入 MCP:从任意 AI 代理驱动 Microsoft OneDrive

让你的 AI 在 OneDrive 中工作:浏览和搜索文件与文件夹,查看详情和有权访问的人,创建文件夹,上传和更新文本文件,复制、重命名和移动。通过 Microsoft Graph 支持工作或学校版 OneDrive 和个人版 OneDrive,使用你的 Microsoft 账户登录。

连接器

如何通过 MCP 将 Canva 连接到 Gemini

让你的 AI 在 Canva 中工作:查找和读取设计,创建新设计,将设计导出为 PDF、PNG、PowerPoint 或视频并获取下载链接,整理文件夹,通过链接上传图片,读取品牌模板,并在设计上发表评论。