谷歌文档工具套件

一个Python MCP服务器,将Google文档、表格、幻灯片和表单作为工具提供给任何兼容MCP的AI助手使用。

  • by stratosphereips
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 stratosphereips/strato-mcp-gdocs-suite

使用说明

平流层MCP GDocs套件

一个Python MCP服务器,它将谷歌文档、谷歌表格、谷歌幻灯片和谷歌表单作为任何兼容MCP的人工智能助手的工具。目前支持 26工具 跨文档、电子表格、演示文稿和表单。

先决条件

在您的Google Cloud项目中启用这些API:

  1. 谷歌文档API
  2. 谷歌网页API
  3. 谷歌幻灯片API
  4. Google Drive API
  5. 谷歌表单API

然后创建OAuth凭据:

  1. 首选 APIs & Services -> OAuth consent screen 并对其进行配置
  2. 在OAuth同意屏幕上,转到 范围 并添加以下范围:
    • https://www.googleapis.com/auth/documents
    • https://www.googleapis.com/auth/spreadsheets
    • https://www.googleapis.com/auth/presentations
    • https://www.googleapis.com/auth/drive.readonly
    • https://www.googleapis.com/auth/forms.body
    • https://www.googleapis.com/auth/forms.responses.readonly
  3. 首选 APIs & Services -> Credentials -> Create credentials -> OAuth client ID -> Desktop app
  4. 复制 Client ID 和 Client Secret

快速入门(Docker)

第一步:构建

docker compose build

步骤2:配置

cp .env.example .env
# Fill in GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET

步骤3:身份验证(一次)

docker compose run --rm -p 8082:8082 auth

第4步:向您的AI助手注册

Claude Desktop

添加 ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "google-docs": {
      "command": "docker",
      "args": [
        "run", "--rm", "-i",
        "-v", "gdocs-suite-mcp-tokens:/tokens",
        "--env-file", "/absolute/path/to/.env",
        "gdocs-suite-mcp:latest",
        "serve"
      ]
    }
  }
}
Claude Code
claude mcp add --transport stdio google-docs -- \
  docker run --rm -i \
    -v gdocs-suite-mcp-tokens:/tokens \
    --env-file /absolute/path/to/.env \
    gdocs-suite-mcp:latest serve
Gemini CLI

添加 ~/.gemini/settings.json (或 .gemini/settings.json 项目级):

{
  "mcpServers": {
    "gdocs-suite": {
      "command": "docker",
      "args": [
        "run", "--rm", "-i",
        "-v", "gdocs-suite-mcp-tokens:/tokens",
        "--env-file", "/absolute/path/to/.env",
        "gdocs-suite-mcp:latest",
        "serve"
      ]
    }
  }
}
OpenAI Codex CLI

添加 ~/.codex/config.toml (或 .codex/config.toml 项目级):

[mcp_servers.gdocs-suite]
command = "docker"
args = ["run", "--rm", "-i", "-v", "gdocs-suite-mcp-tokens:/tokens", "--env-file", "/absolute/path/to/.env", "gdocs-suite-mcp:latest", "serve"]
enabled = true

替代方案:本地安装

git clone https://github.com/stratosphereips/strato-mcp-gdocs-suite
cd strato-mcp-gdocs-suite
uv venv && source .venv/bin/activate
uv pip install -e .
cp .env.example .env

验证一次:

gdocs-suite-auth

启动MCP服务器:

gdocs-suite-mcp

可用工具

文件

工具 参数 说明
list_documents_tool max_results=10, query="" 列出Google Docs文件,可选择按名称筛选
search_documents_tool query, max_results=10 跨文档内容的全文搜索
get_document_tool document_id 获取文档元数据和提取的纯文本
create_document_tool title, content="" 创建具有可选初始文本的文档
update_document_tool document_id, requests 应用原始 文档API批更新 请求:

电子表格

工具 参数 说明
list_spreadsheets_tool max_results=10, query="" 列出Google表格文件,可选择按名称筛选
get_spreadsheet_tool spreadsheet_id 获取电子表格元数据和工作表名称
create_spreadsheet_tool title 创建新的电子表格
read_range_tool spreadsheet_id, range 从A1符号范围读取单元格值(例如。 Sheet1!A1:C10)
write_range_tool spreadsheet_id, range, values 将二维值列表写入一个范围
append_rows_tool spreadsheet_id, range, values 将范围内的数据附加到最后一行下方的行

演示

工具 参数 说明
list_presentations_tool max_results=10, query="" 列出Google幻灯片文件,可选择按名称筛选
get_presentation_tool presentation_id 获取演示文稿元数据、幻灯片数量和幻灯片标题
create_presentation_tool title 创建新演示文稿

表单

工具 参数 说明
list_forms_tool max_results=10, query="" 列出Google Forms文件,可选择按名称筛选
get_form_tool form_id 获取表单元数据、描述和所有项目/问题
create_form_tool title, description="" 创建一个带有可选描述的新表单
add_question_tool form_id, question_type, title, required=False, index=None, options=None 添加一个问题(类型: text, paragraph, multiple_choice, checkbox, dropdown, scale, date, time)
update_form_info_tool form_id, title="", description="" 更新表单标题和/或描述
delete_item_tool form_id, item_id 按项目ID删除问题/项目
list_responses_tool form_id, max_results=100 列出表单的所有回复
get_response_tool form_id, response_id 通过响应ID获取单个响应
move_item_tool form_id, original_index, new_index 将项目移动到新位置(基于0的索引)
add_text_item_tool form_id, title, description="", index=0 添加带有可选描述的节标题
add_page_break_tool form_id, title="", index=0 添加分页符以开始新的部分
update_form_settings_tool form_id, email_collection_type="", is_quiz=None 设置电子邮件收藏(DO_NOT_COLLECT, VERIFIED, RESPONDER_INPUT)和/或测验模式

注: Forms工具需要两个额外的OAuth作用域(forms.body 和 forms.responses.readonly).如果您之前在没有这些作用域的情况下进行了身份验证,请重新运行身份验证步骤: docker compose run --rm -p 8082:8082 auth

配置参考

变量 必填 默认 描述
GOOGLE_CLIENT_ID 是 - OAuth客户端ID
GOOGLE_CLIENT_SECRET 是 - OAuth客户端密钥
GOOGLE_REDIRECT_URI 没有 http://localhost:8082 OAuth重定向URI
TOKEN_STORE_PATH 没有 ~/.config/gdocs-suite-mcp/ (本地)/ /tokens (Docker) Token存储目录
GOOGLE_SCOPES 否 文档+工作表+幻灯片+驱动器。只读 逗号分隔的OAuth作用域
LOG_LEVEL 没有 WARNING 日志级别(仅限stderr)

发展

uv pip install -e ".[dev]"
uv run pytest