Google Docs MCP Server

by Gurgeron

Integrations

  • Enables listing, reading, creating, updating, searching, and deleting Google Docs in your Drive

  • Allows accessing and managing Google Docs stored in your Drive, including listing all documents and performing document operations

Google Docs MCP 服务器

这是一个模型上下文协议 (MCP) 服务器,允许您通过 Claude 连接到 Google 文档。使用此服务器,您可以:

  • 列出云端硬盘中的所有 Google 文档
  • 阅读具体文件的内容
  • 创建新文档
  • 更新现有文档
  • 搜索文档
  • 删除文档

先决条件

  • Node.js v16.0.0 或更高版本
  • 启用了 Google Docs API 和 Google Drive API 的 Google Cloud 项目
  • 您的 Google Cloud 项目的 OAuth 2.0 凭据

设置

  1. 克隆此存储库并导航到项目目录:
git clone https://github.com/yourusername/MCP-Google-Doc.git cd MCP-Google-Doc
  1. 安装依赖项:
npm install
  1. 在 Google Cloud Console 中创建 OAuth 2.0 客户端 ID:
    • 前往Google Cloud Console
    • 创建新项目或选择现有项目
    • 启用 Google Docs API 和 Google Drive API
    • 前往“API 和服务”>“凭证”
    • 点击“创建凭证”>“OAuth 客户端 ID”
    • 选择“桌面应用”作为应用程序类型
    • 下载 JSON 文件并将其保存为项目目录中的credentials.json

    重要提示credentials.jsontoken.json文件包含敏感信息,并且已通过.gitignore排除在版本控制之外。切勿将这些文件提交到您的代码库。

  2. 构建项目:
npm run build
  1. 运行服务器:
npm start

首次运行服务器时,它会提示您使用 Google 进行身份验证。按照屏幕上的说明授权应用程序。这将生成一个token.json文件,用于存储您的访问令牌。

安全注意事项

  • 凭证安全credentials.jsontoken.json均包含敏感信息,切勿共享或提交至版本控制。它们已添加到.gitignore文件中。
  • 令牌刷新:当访问令牌过期时,应用程序会自动刷新访问令牌。
  • 撤销访问权限:如果您需要撤销访问权限,请删除token.json文件并转到您的Google 帐户安全设置,从您的授权应用程序中删除该应用程序。

连接到 Claude 桌面版

要将此服务器与 Claude for Desktop 一起使用:

  1. 编辑您的 Claude Desktop 配置文件:
    • 在 macOS 上: ~/Library/Application Support/Claude/claude_desktop_config.json
    • 在 Windows 上: %APPDATA%\Claude\claude_desktop_config.json
  2. 将以下内容添加到您的配置中:
{ "mcpServers": { "googledocs": { "command": "node", "args": ["/absolute/path/to/build/server.js"] } } }

/absolute/path/to/build/server.js替换为您构建的 server.js 文件的实际路径。

  1. 重新启动 Claude 桌面版。

用户界面

Google Docs MCP 服务器具有用户友好的对话界面,可以:

  • 以清晰易读的格式呈现文档信息
  • 使用自然语言响应而不是原始 API 数据
  • 以人类可读的方式格式化日期
  • 采取行动后提供有用的后续问题
  • 绝不会暴露 OAuth 令牌等敏感数据

此界面样式旨在与 Notion 等其他 Claude MCP 集成相匹配,提供一致且愉悦的用户体验。

发展

项目结构

google-docs-integration/ ├── build/ # Compiled JavaScript files ├── src/ # TypeScript source code │ └── server.ts # Main server implementation ├── .gitignore # Git ignore file ├── credentials.json # OAuth 2.0 credentials (not in version control) ├── package.json # Project dependencies and scripts ├── README.md # Project documentation ├── token.json # OAuth tokens (not in version control) └── tsconfig.json # TypeScript configuration

添加新功能

要向 MCP 服务器添加新功能:

  1. 修改src/server.ts文件以实现新功能
  2. 使用npm run build构建项目
  3. 通过运行npm start测试你的更改

可用资源

  • googledocs://list - 列出您云端硬盘中的所有 Google 文档
  • googledocs://{docId} - 通过 ID 获取特定文档的内容

可用工具

  • create-doc - 创建具有指定标题和可选内容的新 Google 文档
  • update-doc - 使用新内容更新现有的 Google Doc(附加或替换)
  • insert-text - 无需 Notion 或其他集成,直接将文本插入文档
  • search-docs - 搜索包含特定文本的 Google 文档
  • delete-doc - 根据 ID 删除 Google 文档

可用提示

  • create-doc-template - 帮助根据指定主题和写作风格创建新文档
  • analyze-doc - 分析文档内容并提供摘要

使用示例

以下是服务器连接后可以与 Claude 一起使用的一些示例提示:

  • “显示我的所有 Google 文档的列表”
  • “创建一个名为‘会议记录’的新 Google 文档,内容为‘要讨论的主题:...’”
  • “更新我的 ID 为‘1abc123def456’的文档,在末尾添加此部分:...”
  • “在我的 Google 文档中搜索包含‘项目提案’的任何文档”
  • “删除 ID 为‘1abc123def456’的 Google 文档”
  • “创建一份关于气候变化的正式文件”
  • “分析 ID 为‘1abc123def456’的文档内容”

故障排除

如果您遇到身份验证问题:

  1. 删除项目目录中的token.json文件
  2. 再次运行服务器以触发新的身份验证流程

如果您在使用 Google Docs API 时遇到问题:

  1. 确保您的 Google Cloud Console 中已启用 API
  2. 检查您的 OAuth 凭据是否具有正确的范围

贡献

  1. 分叉存储库
  2. 创建功能分支: git checkout -b feature/your-feature-name
  3. 提交您的更改: git commit -am 'Add some feature'
  4. 推送到分支: git push origin feature/your-feature-name
  5. 提交拉取请求

执照

麻省理工学院

环境变量

使用以下键在项目根目录创建一个.env文件(或在 shell 中导出变量):

# OAuth 2.0 client credentials – **JSON string** of the credentials file GOOGLE_DOCS_CREDENTIALS_JSON={...} # OAuth token – **JSON string** returned by the OAuth consent flow GOOGLE_DOCS_TOKEN_JSON={...}

如果设置了这些变量,服务器将不会尝试从磁盘读取credentials.jsontoken.json

-
security - not tested
F
license - not found
-
quality - not tested

local-only server

The server can only run on the client's local machine because it depends on local resources.

将 Claude 连接到 Google Docs,允许用户通过自然语言交互列出、阅读、创建、更新、搜索和删除 Google Drive 中的文档。

  1. 先决条件
    1. 设置
      1. 安全注意事项
        1. 连接到 Claude 桌面版
          1. 用户界面
            1. 发展
              1. 项目结构
              2. 添加新功能
            2. 可用资源
              1. 可用工具
                1. 可用提示
                  1. 使用示例
                    1. 故障排除
                      1. 贡献
                        1. 执照
                          1. 环境变量

                            Related MCP Servers

                            • -
                              security
                              A
                              license
                              -
                              quality
                              Integrates with Google Drive to enable listing, searching, and reading files, plus reading and writing to Google Sheets.
                              Last updated -
                              91
                              86
                              TypeScript
                              MIT License
                            • -
                              security
                              F
                              license
                              -
                              quality
                              Enables managing Google Cloud Platform resources through natural language commands in Claude Desktop, supporting comprehensive operations across compute, storage, databases, networking, monitoring, and IAM without manual credential setup.
                              Last updated -
                              8
                              Python
                              • Apple
                            • -
                              security
                              F
                              license
                              -
                              quality
                              Connects Google Search Console with Claude AI to enable SEO professionals to analyze their SEO data through natural language conversations, providing access to property information, search analytics, URL inspection, and sitemap management.
                              Last updated -
                              44
                              Python
                              • Apple
                            • -
                              security
                              A
                              license
                              -
                              quality
                              A server that connects Claude to your documentation via Inkeep's API, enabling AI-powered interactions with your documentation content.
                              Last updated -
                              5
                              Python
                              MIT License
                              • Apple
                              • Linux

                            View all related MCP servers

                            ID: tlntygn26g