Google Docs Mcp Server

Google Docs Mcp Server

🚀 Google Docs MCP 服务器

Google Docs MCP 服务器是一个中间件平台,用于与 Google 文档 API 进行交互。它支持通过命令对 Google 文档进行创建、读取、更新和删除等操作,同时还具备导出、共享和搜索等实用功能。

🚀 快速开始

Google Docs MCP 服务器为您与 Google 文档 API 的交互提供了便捷途径。您可以通过一系列命令轻松实现对 Google 文档的各种操作。

✨ 主要特性

  • 支持对 Google 文档进行创建、读取、更新和删除操作。
  • 具备文档导出、共享和搜索功能。
  • 提供多种认证方式,包括使用 Google Cloud Project ID 和 Service Account Key JSON、API Key 以及 OAuth 2.0。
  • 支持 Docker 部署,方便快捷。
  • 可集成到 Claude 或其他支持 MCP 的助手中。

📦 安装指南

安装依赖项

使用以下命令安装所需的依赖项:

npm install

运行服务器

运行服务器:

node dist/index.js

🔧 认证配置

要与 Google Docs API 交互,您需要适当的认证信息。以下是支持的几种认证方式:

1. 使用 Google Cloud Project ID 和 Service Account Key JSON

  • 参数:
    • GOOGLE_CLOUD_PROJECT_ID:您的 Google Cloud 项目 ID。
    • GOOGLE_APPLICATION_CREDENTIALS:包含您的服务账户密钥的 JSON 文件路径。
      export GOOGLE_CLOUD_PROJECT_ID=your-project-id
      export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account-key.json
      

2. 使用 API Key

  • 参数:
    • GOOGLE_API_KEY:您的 Google API 密钥。
      export GOOGLE_API_KEY=your-api-key
      

3. 使用 OAuth 2.0(适用于用户认证)

  • 参数:
    • client_id:您的应用客户端 ID。
    • client_secret:您的应用客户端密钥。
    • refresh_token:用户的刷新令牌。
      export client_id=your-client-id
      export client_secret=your-client-secret
      export refresh_token=your-refresh-token
      

🐳 Docker 支持

构建镜像

docker build -t google-docs-mcp-server .

运行容器

docker run -p 8080:8080 \
-e GOOGLE_CLOUD_PROJECT_ID=your-project-id \
-e GOOGLE_APPLICATION_CREDENTIALS_JSON='{"type":"service_account","project_id":"..."}' \
-e client_id=your-client-id \
-e client_secret=your-client-secret \
-e refresh_token=your-refresh-token \
-e AUTH_SERVER_URL=https://your-auth-server.com/verify \
google-docs-mcp-server

🔌 MCP 集成

要在 Claude 或其他支持 MCP 的助手中使用此服务器,将其添加到 MCP 设置:

{
"mcpServers": {
"google-docs": {
"command": "node",
"args": ["/path/to/google-docs-mcp-server/dist/index.js"],
"config": {
"GOOGLE_CLOUD_PROJECT_ID": "your-project-id",
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service-account-key.json"
}
}
}
}

🛠️ 可用工具

以下是可通过服务器进行的操作:

工具名称 描述 所需参数
createDocument 创建新文档 documentTitle, body
getDocumentById 通过 ID 获取文档内容 id
updateDocument 更新现有文档内容 id, newBody
deleteDocument 删除指定文档 id
exportDocumentToFormat 将文档导出为不同格式(PDF, Word, HTML) id, format
shareDocument 分享文档 id, emailAddress, role
searchDocuments 搜索文档内容 query

💻 使用示例

基础用法

创建新文档

{
"command": "createDocument",
"params": {
"documentTitle": "My New Document",
"body": "This is the content of the new document."
}
}

更新现有文档

{
"command": "updateDocument",
"params": {
"id": "1234567890abcdefghijklmnopqrstuvwxyz",
"newBody": "Updated content of the document."
}
}

📄 许可证

本项目采用 MIT 许可证,详情请查阅 LICENSE 文件。

  • 0 关注
  • 0 收藏,27 浏览
  • system 提出于 2025-10-06 04:48

相似服务问题

相关AI产品