谷歌文档MCP服务器
用于Google Docs API的模型上下文协议(MCP)服务器,允许语言模型创建、搜索、附加和更新Google Docs。
特性
- 搜索文档:使用自定义查询在云端硬盘中搜索谷歌文档
- 创建文档:创建具有可选初始内容的新Google文档
- 附至文件:将内容附加到现有Google文档的末尾
- 更新文档:用新内容替换现有Google文档中的内容
设置
先决条件
- Node.js(v14或更高版本)
- npm
- 启用了Google Drive和Google Docs API的Google云平台帐户
安装
- 克隆此存储库:
git clone
cd google-docs-mcp-server- 安装依赖项:
npm install- 设置Google API凭据:
- 转到 谷歌云控制台 - 创建新项目(或选择现有项目) - 启用Google Drive API和Google Docs API - 创建OAuth 2.0凭据(桌面应用程序) - 下载凭据JSON文件并将其另存为 credentials.json 在项目根中
- 获取身份验证令牌:
node get-refresh-token.js按照浏览器提示授权应用程序。这将创建一个 token.json 文件。
- 构建服务器:
npm run build构建Extism插件
服务器使用ExtismWebAssembly插件与GoogleDocsneneneba API进行交互。要构建插件,请执行以下操作:
cd extism-plugin
npm install
npm run build这将在dist目录中创建plugin.wasm文件。
用法
运行服务器
启动MCP服务器:
npm start或者使用显式节点命令:
node build/index.js直接测试插件
您可以直接使用Extism CLI测试Extism插件:
cd extism-plugin
extism call --wasi --allow-host www.googleapis.com --allow-host docs.googleapis.com --config GOOGLE_ACCESS_TOKEN= dist/plugin.wasm describe要搜索文档,请执行以下操作:
extism call --wasi --allow-host www.googleapis.com --allow-host docs.googleapis.com --config GOOGLE_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= dist/plugin.wasm call --input '{"toolId": "create_doc", "arguments": {"title": "My New Document", "content": "Initial content"}}'许可证
麻省理工学院
