文档管理协议服务器

Google Docs MCP Server是一个基于Model Context Protocol的服务器,允许语言模型通过API创建、搜索、追加和更新Google Docs文档。

  • by highlight-ing
  • TypeScript
  • 本地部署
  • 2 星标
  • 更新于
在 GitHub 查看 highlight-ing/google-docs-mcp-server

使用说明

谷歌文档MCP服务器

用于Google Docs API的模型上下文协议(MCP)服务器,允许语言模型创建、搜索、附加和更新Google Docs。

特性

  • 搜索文档:使用自定义查询在云端硬盘中搜索谷歌文档
  • 创建文档:创建具有可选初始内容的新Google文档
  • 附至文件:将内容附加到现有Google文档的末尾
  • 更新文档:用新内容替换现有Google文档中的内容

设置

先决条件

  • Node.js(v14或更高版本)
  • npm
  • 启用了Google Drive和Google Docs API的Google云平台帐户

安装

  1. 克隆此存储库:

    git clone <repository-url>
    cd google-docs-mcp-server
    
  2. 安装依赖项:

    npm install
    
  3. 设置Google API凭据:

    • 转到 谷歌云控制台
    • 创建新项目(或选择现有项目)
    • 启用Google Drive API和Google Docs API
    • 创建OAuth 2.0凭据(桌面应用程序)
    • 下载凭据JSON文件并将其另存为 credentials.json 在项目根中
  4. 获取身份验证令牌:

    node get-refresh-token.js
    

    按照浏览器提示授权应用程序。这将创建一个 token.json 文件。

  5. 构建服务器:

    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=<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"}}'

许可证

麻省理工学院