返回 MCP 目录
public公开dns本地运行

google-docs-mcp-server

一个基于Google Docs API的MCP服务器,支持语言模型创建、搜索、追加和更新Google文档。

article

README

🚀 谷歌文档 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 <repository-url>
    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=<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 许可证。

help

运行方式说明

cloud

托管运行

托管运行通常表示这个 MCP Server 由服务方环境承载,用户一般按页面提供的连接方式或授权流程接入,不需要在本地长期启动一个 MCP 进程

  1. 打开服务方连接页
  2. 完成授权或复制端点
  3. 在 MCP 客户端中连接
terminal

本地运行 / 其它方式

本地运行通常需要用户在自己的电脑或服务器上安装依赖,把 server_config 复制到 MCP 客户端,并按 env_schema 补齐环境变量、密钥或其它配置

  1. 复制 server_config
  2. 安装所需依赖
  3. 补齐环境变量后重启客户端