Google Docs MCP Server

Google Docs MCP Server

site icon
2025.04.05 2
TypeScript文档管理自动化工具内容生成交流协作
Google Docs MCP Server 是一个基于 Model Context Protocol (MCP) 的服务,用于与 Google Docs API 交互,允许语言模型创建、搜索、追加和更新 Google Docs。
View on GitHub

Overview

基本能力

产品定位

Google Docs MCP Server 是一个用于与 Google Docs API 交互的 MCP 服务,主要用于文档的创建、搜索、更新和管理。

核心功能

  • 搜索文档:使用自定义查询在 Google Drive 中搜索 Google Docs。
  • 创建文档:创建新的 Google Docs,并可选择添加初始内容。
  • 追加内容:在现有 Google Doc 的末尾追加内容。
  • 更新文档:用新内容替换现有 Google Doc 中的内容。

适用场景

  • 自动化文档管理
  • 批量文档处理
  • 文档内容生成和更新

工具列表

  • Extism 插件:用于与 Google Docs API 交互的 WebAssembly 插件。

常见问题解答

使用教程

使用依赖

  • Node.js (v14 或更高版本)
  • npm
  • Google Cloud Platform 账户,并启用 Google Drive 和 Google Docs API

安装教程

  1. 克隆仓库: git clone <repository-url> cd google-docs-mcp-server

  2. 安装依赖: npm install

  3. 设置 Google API 凭证:

  4. 访问 Google Cloud Console
  5. 创建新项目或选择现有项目
  6. 启用 Google Drive API 和 Google Docs API
  7. 创建 OAuth 2.0 凭证(桌面应用)
  8. 下载凭证 JSON 文件并保存为 credentials.json 到项目根目录

  9. 获取认证令牌: node get-refresh-token.js 按照浏览器提示授权应用,这将创建 token.json 文件。

  10. 构建服务器: npm run build

构建 Extism 插件

cd extism-plugin
npm install
npm run build

调试方式

  1. 启动 MCP 服务器: npm startnode build/index.js

  2. 直接测试插件: cd extism-plugin extism call --wasi --allow-host www.googleapis.com --allow-host docs.googleapis.com --config GOOGLE_ACCESS_TOKEN=<your-access-token> dist/plugin.wasm describe

搜索文档: extism call --wasi --allow-host www.googleapis.com --allow-host docs.googleapis.com --config GOOGLE_ACCESS_TOKEN=<your-access-token> dist/plugin.wasm call --input '{"toolId": "search_docs", "arguments": {"query": "name contains \"report\""}}'

创建新文档: extism call --wasi --allow-host www.googleapis.com --allow-host docs.googleapis.com --config GOOGLE_ACCESS_TOKEN=<your-access-token> dist/plugin.wasm call --input '{"toolId": "create_doc", "arguments": {"title": "My New Document", "content": "Initial content"}}'

许可证

该项目遵循 MIT 开源许可条款。