Google Docs Mcp Server

Google Docs Mcp Server

🚀 谷歌文档 MCP 服务器

谷歌文档 MCP 服务器是一个基于 Google Docs API 的 Model Context Protocol (MCP) 服务器。它为语言模型提供了强大的功能,能够创建、搜索、追加内容到以及更新 Google 文档,极大地拓展了语言模型与 Google 文档的交互能力。

🚀 快速开始

该服务器允许语言模型与 Google 文档进行交互。你可以按照以下步骤设置并运行服务器。

✨ 主要特性

  • 搜索文档:借助自定义查询,可在 Drive 中精准搜索 Google 文档。
  • 创建文档:支持创建新的 Google 文档,还能选择设置初始内容。
  • 追加到文档:能够将内容添加到现有 Google 文档的末尾。
  • 更新文档:可以用新内容替换现有 Google 文档的内容。

📦 安装指南

先决条件

  • Node.js(v14 或更高版本)
  • npm
  • 谷歌云平台账户,且已启用 Google Drive API 和 Google Docs API

安装步骤

  1. 克隆此仓库:
    git clone 
    cd google-docs-mcp-server
    
  2. 安装依赖项:
    npm install
    
  3. 设置谷歌 API 凭证:
    • 访问 Google Cloud Console
    • 创建新项目(或选择现有项目)
    • 启用 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 插件

该服务器使用 Extism WebAssembly 插件与 Google Docs API 交互。要构建插件,可执行以下命令:

cd extism-plugin
npm install
npm run build

这将在 dist 目录下创建 plugin.wasm 文件。

💻 使用示例

运行服务器

启动 MCP 服务器:

npm start

或使用明确的 node 命令:

node build/index.js

直接测试插件

你可以直接使用 Extism CLI 测试插件。

基础用法

查看插件描述:

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

📄 许可证

本项目采用 MIT 许可证。

  • 0 关注
  • 0 收藏,8 浏览
  • system 提出于 2025-09-28 21:54

相似服务问题