跳过安装。2 分钟内即可运行。
在 cloud.anythingmcp.com 开始免费试用,一键添加 Excel (Microsoft 365),然后将你的 AI 客户端(Claude、ChatGPT、Copilot 或 Cursor)指向生成的 MCP 端点。无需 Docker,无需 git clone,无需任何工程经验。
摘要
让你的 AI 处理 OneDrive 和 SharePoint 中的 Excel 工作簿:列出工作表,读取任意区域或工作表的已用区域,写入值和公式,读取和追加表格行,添加工作表并创建表格。通过 Microsoft Graph 工作簿 API 支持 Microsoft 365,使用你的 Microsoft 账户登录。
试试这样问
Excel (Microsoft 365) 的示例提示
点击任意提示即可复制,然后粘贴到 Claude、ChatGPT、Cursor、Gemini、Copilot 或 OpenClaw 中,在该连接器上运行。
Claude 是 AI,可能会出错。请核对回答。
💡 无需安装? 直接使用 cloud.anythingmcp.com。 登录、点击 Connectors → Excel (Microsoft 365)、粘贴凭证、生成 MCP API key,即可完成。无 Docker、无
git clone、无本地服务器。
Microsoft Excel + ChatGPT
让你的 AI 处理 OneDrive 和 SharePoint 中的 Excel 工作簿:列出工作表,读取任意区域或工作表的已用区域,写入值和公式,读取和追加表格行,添加工作表并创建表格。通过 Microsoft Graph 工作簿 API 支持 Microsoft 365,使用你的 Microsoft 账户登录。
前提条件
完整的设置说明已内置在连接器中 (在 store 中选择连接器时可见)。所需环境变量:
MICROSOFT_CLIENT_ID, MICROSOFT_CLIENT_SECRET, MICROSOFT_TENANT_ID
步骤 1 — 获取凭证
-
打开 Microsoft Entra 管理中心(entra.microsoft.com)或 Azure 门户,进入 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,填写
https://cloud.anythingmcp.com/api/mcp-oauth/callback。如果你自行托管 AnythingMCP,则改为填写https://your-anythingmcp-host/api/mcp-oauth/callback。URI 必须逐字符一致,否则 Microsoft 会返回 AADSTS50011。 -
打开 API permissions → Add a permission → Microsoft Graph → Delegated permissions,添加
offline_access、User.Read和Files.ReadWrite。offline_access让 Microsoft 签发刷新令牌;缺少它,连接器会在授权一小时后停止工作。 -
打开 Certificates & secrets → New client secret。复制密钥的 Value,而不是 Secret ID;它只显示一次。记下到期日期:密钥过期后,连接器会停止工作,直到你创建新密钥并填入。
-
将 Overview 页面上的 Application (client) ID 填入
MICROSOFT_CLIENT_ID,将密钥值填入MICROSOFT_CLIENT_SECRET,将第 2 步中的租户值填入MICROSOFT_TENANT_ID,然后安装连接器。 -
在连接器页面点击 Authorize with Provider,用 AI 要处理其工作簿的账户登录。刷新令牌会加密保存,访问令牌(有效期约一小时)会自动续期。
-
先运行
excel_get_my_drive:它会显示连接器登录的是哪个 OneDrive。
一个 Entra 应用服务所有 Microsoft 连接器:你为 Outlook、OneDrive 或 SharePoint 连接器创建的应用注册在这里同样适用。打开它,在 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 为整个组织授予同意。之后每个用户都可以授权。每个连接器仍然只能处理登录账户有权查看的内容。
SharePoint 中或共享给你的工作簿:Files.ReadWrite 涵盖你自己 OneDrive 中的工作簿。对于 SharePoint 库中的工作簿或其他人共享的工作簿,请在应用注册中添加 Files.ReadWrite.All,在连接器的 OAuth 设置中用它替换 Files.ReadWrite,然后重新授权。AI 会按名称或路径(例如 Finance/Budget 2026.xlsx)在你的 OneDrive 中查找工作簿;对于 SharePoint 库,它会从 Microsoft SharePoint 连接器获取该库的 drive id。
保持工作簿不被修改:即使只是读取工作簿也需要写入权限,因为 Microsoft Graph 会在 Excel 会话中打开它。要防止 AI 修改工作簿,请停用 excel_update_range、excel_add_worksheet、excel_add_table_rows 和 excel_create_table。
安装时默认关闭:excel_clear_range 和 excel_delete_worksheet。这两项操作都无法通过 API 撤销,只能从文件的版本历史中恢复。只有在 AI 确实需要时才打开它们。
读取和写入:只支持 .xlsx 文件(以及 .xlsm、.xlsb);不支持 .xls 和 .csv 文件。除非 AI 请求显示的文本,否则日期会以 Excel 序列号返回;大型工作表会按行分块读取。向 Excel 表格追加行是添加记录最安全的方式:表格会随之扩展,并保留其中的公式和格式。公式使用英文函数名和逗号,例如 =SUM(B2:B20)。每次更改都会立即保存到文件中,Excel 网页版和桌面应用都能看到。个人 OneDrive 账户支持大多数读取和区域工具,但不支持表格行。
限制:Microsoft Graph 可处理最大约 100 MB 的工作簿,请求在约 30 秒后超时,因此请让区域保持适中。如果有人在 Excel 桌面应用中打开了该文件且有未保存的更改,或者大型工作簿仍在加载,Graph 可能返回 409 或 504:稍等片刻再试。
常见错误:401 InvalidAuthenticationToken 表示授权已被撤销或客户端密钥已过期;如有需要填入新密钥,然后再次点击 Authorize with Provider。403 accessDenied 表示缺少某个权限,或者工作簿属于其他人而权限范围中没有 Files.ReadWrite.All。404 itemNotFound 表示工作簿有误,或工作表或表格名称不存在。400 InvalidArgument 表示 Excel 无法识别该地址,或值与区域的形状不匹配。UnsupportedWorkbook 或 NotSupported 表示文件不是 .xlsx 格式、受密码保护,或对工作簿 API 来说太大。
连接器不创建新的工作簿文件、图表、数据透视表或命名项,也不设置数字格式以外的单元格格式。
步骤 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 — 在 ChatGPT 中添加连接器
你的服务器 URL: 在 AnythingMCP 中打开 MCP Servers → 此连接器所在的服务器,复制它的 URL(
https://cloud.anythingmcp.com/mcp/…)。本指南中出现YOUR_SERVER_ID的地方都用它替换。
ChatGPT 通过开发者模式(Developer mode)将 MCP 服务器作为自定义应用接入,仅付费套餐可用,免费套餐不可用。在 Business 和 Enterprise 工作区中,可能需要管理员先开启。
- 在 ChatGPT 中打开 Settings → Security and login,开启 Developer mode。
- 前往 chatgpt.com/plugins,点击 +。
- 填写名称和简短描述,例如 Name:
Microsoft Excel。 - 在 Connection 下填入 MCP 服务器 URL
https://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID,然后创建连接。 - ChatGPT 提示时,登录 AnythingMCP(OAuth)并允许访问。
可用工具
| Tool | What it does |
|---|---|
excel_get_my_drive | Get the signed-in user's OneDrive: its id (the drive_id for workbooks stored there), type and owner |
excel_find_workbooks | Search the user's OneDrive for workbooks by name or content, e.g. "budget" or "xlsx" |
excel_get_workbook_by_path | Look up a workbook in the user's OneDrive by path, e.g. "Documents/Budget 2026.xlsx", and return its id and parentReference.driveId for the… |
excel_list_worksheets | List the worksheets (tabs) of a workbook: id, name, position (0-based) and visibility |
excel_read_range | Read a range of one worksheet, e.g. "A1:D20": returns address and values (a list of rows, numbers as numbers, dates as serial numbers) by… |
excel_read_used_range | Read the part of a worksheet that holds values (its used range): address (e.g |
excel_update_range | Write into a range, overwriting what is there: values, or formulas (e.g. [["=SUM(B2:B20)"]]), and optionally numberFormat |
excel_add_worksheet | Add a worksheet (tab) at the end of the workbook |
excel_list_tables | List the tables (formatted Excel tables) of a workbook: id, name, showHeaders, showTotals and style |
excel_list_table_columns | List a table's columns: id, name (the header text) and index |
excel_list_table_rows | Read the data rows of a table (without the header): each row's index and values |
excel_add_table_rows | Append rows at the end of a table (or insert them at a 0-based index); the table grows and formulas and formats of the table columns carry… |
excel_create_table | Turn a range into an Excel table, e.g. address "Sheet1!A1:D1" with has_headers true to start an empty table from a header row |
excel_clear_range | Clear a range: its contents, its formats, or both |
excel_delete_worksheet | Delete a worksheet with everything on it |
示例提示
- “打开“财务/2026 预算.xlsx”,告诉我哪些成本中心超出了预算。”
- “把这三笔费用作为新行,添加到我的差旅工作簿中的“费用”表格里。”
- “读取“销售”工作表,把每月合计写入一个名为“汇总”的新工作表。”
- “工作簿“2026 价格”有哪些工作表?每个工作表各用了多少行?”
FAQ
ChatGPT 免费套餐能用自定义 MCP 连接器吗? 不能。自定义 MCP 连接需要开发者模式,只有付费套餐提供。
下一步
这份指南对你有帮助吗?