跳过安装。2 分钟内即可运行。
在 cloud.anythingmcp.com 开始免费试用,一键添加 Google Sheets,然后将你的 AI 客户端(Claude、ChatGPT、Copilot 或 Cursor)指向生成的 MCP 端点。无需 Docker,无需 git clone,无需任何工程经验。
摘要
让你的 AI 使用 Google Sheets:读取任意范围或一次读取多个范围,查看表格中的工作表及其大小,向表格追加行,写入和更新单元格与公式,创建表格,以及添加或重命名工作表。支持个人 Google 账户和 Google Workspace。
试试这样问
Google Sheets 的示例提示
点击任意提示即可复制,然后粘贴到 Claude、ChatGPT、Cursor、Gemini、Copilot 或 OpenClaw 中,在该连接器上运行。
Claude 是 AI,可能会出错。请核对回答。
💡 无需安装? 直接使用 cloud.anythingmcp.com。 登录、点击 Connectors → Google Sheets、粘贴凭证、生成 MCP API key,即可完成。无 Docker、无
git clone、无本地服务器。
Google Sheets + Gemini
让你的 AI 使用 Google Sheets:读取任意范围或一次读取多个范围,查看表格中的工作表及其大小,向表格追加行,写入和更新单元格与公式,创建表格,以及添加或重命名工作表。支持个人 Google 账户和 Google Workspace。
前提条件
完整的设置说明已内置在连接器中 (在 store 中选择连接器时可见)。所需环境变量:
GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET
步骤 1 — 获取凭证
- 打开 console.cloud.google.com,选择或创建一个项目,然后进入 APIs & Services → Library 启用 Google Sheets API。
- 打开 APIs & Services → OAuth consent screen。如果你使用 Google Workspace,选择 Internal(最简单),否则选择 External。选择 External 时,请把发布状态设为 In production:应用处于 Testing 状态时,Google 会在 7 天后撤销它的刷新令牌,连接器每周都会停止工作。如果只供你自己的账户使用,可以直接跳过“unverified app”警告继续。
- 打开 APIs & Services → Credentials → Create credentials → OAuth client ID,应用类型选择 Web application,并添加已授权的重定向 URI
https://cloud.anythingmcp.com/api/mcp-oauth/callback。如果你自行托管 AnythingMCP,请改填https://your-anythingmcp-host/api/mcp-oauth/callback。 - 把客户端 ID 填入
GOOGLE_CLIENT_ID,把客户端密钥填入GOOGLE_CLIENT_SECRET,然后安装连接器。 - 在连接器页面点击 Authorize with Provider,用 AI 要使用其表格的 Google 账户登录。刷新令牌会加密存储,访问令牌会自动续期。
一个 Google 客户端服务所有 Google 连接器:同一个 Cloud 项目和 OAuth 客户端可以服务所有 Google 连接器:Gmail、Google Calendar、Google Drive、Google Sheets、Google Docs、Google Tasks、Search Console、Analytics 和 Ads。在该项目中启用每个 API,复用同一个客户端 ID 和密钥,并为每个连接器各授权一次。每个连接器只请求它自己需要的权限。
查找表格:把表格的链接粘贴到聊天中;它的 ID 是 https://docs.google.com/spreadsheets/d/<id>/edit 中那串长字符。要按名称查找表格,请同时添加 Google Drive 连接器。数值会像手动输入一样写入,因此数字、日期和 =SUM(B2:B20) 这样的公式都能正常使用;新行会追加到表格最后一行之后,不会覆盖下方的任何内容。
权限:连接器请求 https://www.googleapis.com/auth/spreadsheets:读写你的账户能打开的每个表格。它不包含 Google Drive,因此连接器不能列出、搜索、移动或共享表格文件。
只读设置:在连接器的 OAuth 设置中把 scope 改为 https://www.googleapis.com/auth/spreadsheets.readonly,重新授权,并停用 gsheets_append_rows、gsheets_update_range、gsheets_batch_update_values、gsheets_create_spreadsheet、gsheets_add_sheet 和 gsheets_rename_sheet。
安装时默认关闭:gsheets_clear_range 和 gsheets_batch_update(它可以删除工作表、行和列)。如果 AI 需要,请逐个打开。
常见错误:401 表示授权已过期或被撤销(同意屏幕处于 Testing 状态时,7 天后必然发生):请再次点击 Authorize with Provider。403 PERMISSION_DENIED 表示该账户无法打开或编辑这个表格,或者 scope 是只读的;403“Sheets API has not been used in project”表示 Cloud 项目中没有启用 Google Sheets API。400 Unable to parse range 表示工作表名称拼写错误,或需要用单引号括起来,例如 '销售 2026'!A:C。
连接器不会查找、共享、移动或删除表格文件(这由 Google Drive 连接器负责),也不运行 Apps Script。
步骤 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 现在可以调用
Google Sheets的工具。
可用工具
| Tool | What it does |
|---|---|
gsheets_get_spreadsheet | Get a spreadsheet's structure without cell data: title, locale, time zone, URL, and every sheet (tab) with its sheetId, title, position… |
gsheets_read_range | Read the cell values of one range in A1 notation (e.g. "Sheet1!A1:D50") |
gsheets_batch_read | Read several ranges of one spreadsheet in a single call, e.g. ["Summary!A1:B10", "Data!A1:F100"] |
gsheets_append_rows | Append rows after the last row of the table found in range (e.g. "Sheet1!A:E" or just "Sheet1"), inserting new rows so nothing is… |
gsheets_update_range | Write values into a range, overwriting what is there (e.g. range "Sheet1!B2:C3" with [[1, 2], [3, 4]]) |
gsheets_batch_update_values | Write several ranges of one spreadsheet in a single call, overwriting them: data is a list of {"range": "Sheet1!A1:B2", "values": [[...]… |
gsheets_clear_range | Empty all values in a range (formatting and validation stay), e.g. "Sheet1!A2:Z" to keep the header row |
gsheets_create_spreadsheet | Create a new, empty spreadsheet in the root of the user's My Drive, with one sheet named "Sheet1" (or the locale's equivalent) |
gsheets_add_sheet | Add a sheet (tab) to a spreadsheet, optionally at a position |
gsheets_rename_sheet | Rename a sheet (tab). sheet_id is the numeric sheetId from gsheets_get_spreadsheet (0 for the first sheet of a new spreadsheet), not the… |
gsheets_batch_update | Run Sheets API batchUpdate requests for anything the other tools do not cover: formatting (repeatCell), sorting (sortRange), inserting or… |
示例提示
- “读取这个表格中的“订单”工作表,告诉我总额最高的五个客户。”
- “把今天的支出作为新行追加到我的支出表中:日期、说明、金额。”
- “添加一个名为“汇总”的工作表,填入每月合计,并在最后一行加上 SUM 公式。”
- “为活动嘉宾名单新建一个表格,包含姓名、邮箱、公司和状态这几列。”
FAQ
Gemini CLI 从哪里读取 MCP 服务器? 用户级配置位于 ~/.gemini/settings.json,项目级配置位于项目内的 .gemini/settings.json。gemini mcp list 会列出每个服务器及其连接状态。
下一步
这份指南对你有帮助吗?