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 凭据
设置
- 克隆此存储库并导航到项目目录:
- 安装依赖项:
- 在 Google Cloud Console 中创建 OAuth 2.0 客户端 ID:
- 前往Google Cloud Console
- 创建新项目或选择现有项目
- 启用 Google Docs API 和 Google Drive API
- 前往“API 和服务”>“凭证”
- 点击“创建凭证”>“OAuth 客户端 ID”
- 选择“桌面应用”作为应用程序类型
- 下载 JSON 文件并将其保存为项目目录中的
credentials.json
重要提示:
credentials.json
和token.json
文件包含敏感信息,并且已通过.gitignore
排除在版本控制之外。切勿将这些文件提交到您的代码库。 - 构建项目:
- 运行服务器:
首次运行服务器时,它会提示您使用 Google 进行身份验证。按照屏幕上的说明授权应用程序。这将生成一个token.json
文件,用于存储您的访问令牌。
安全注意事项
- 凭证安全:
credentials.json
和token.json
均包含敏感信息,切勿共享或提交至版本控制。它们已添加到.gitignore
文件中。 - 令牌刷新:当访问令牌过期时,应用程序会自动刷新访问令牌。
- 撤销访问权限:如果您需要撤销访问权限,请删除
token.json
文件并转到您的Google 帐户安全设置,从您的授权应用程序中删除该应用程序。
连接到 Claude 桌面版
要将此服务器与 Claude for Desktop 一起使用:
- 编辑您的 Claude Desktop 配置文件:
- 在 macOS 上:
~/Library/Application Support/Claude/claude_desktop_config.json
- 在 Windows 上:
%APPDATA%\Claude\claude_desktop_config.json
- 在 macOS 上:
- 将以下内容添加到您的配置中:
将/absolute/path/to/build/server.js
替换为您构建的 server.js 文件的实际路径。
- 重新启动 Claude 桌面版。
用户界面
Google Docs MCP 服务器具有用户友好的对话界面,可以:
- 以清晰易读的格式呈现文档信息
- 使用自然语言响应而不是原始 API 数据
- 以人类可读的方式格式化日期
- 采取行动后提供有用的后续问题
- 绝不会暴露 OAuth 令牌等敏感数据
此界面样式旨在与 Notion 等其他 Claude MCP 集成相匹配,提供一致且愉悦的用户体验。
发展
项目结构
添加新功能
要向 MCP 服务器添加新功能:
- 修改
src/server.ts
文件以实现新功能 - 使用
npm run build
构建项目 - 通过运行
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’的文档内容”
故障排除
如果您遇到身份验证问题:
- 删除项目目录中的
token.json
文件 - 再次运行服务器以触发新的身份验证流程
如果您在使用 Google Docs API 时遇到问题:
- 确保您的 Google Cloud Console 中已启用 API
- 检查您的 OAuth 凭据是否具有正确的范围
贡献
- 分叉存储库
- 创建功能分支:
git checkout -b feature/your-feature-name
- 提交您的更改:
git commit -am 'Add some feature'
- 推送到分支:
git push origin feature/your-feature-name
- 提交拉取请求
执照
麻省理工学院
环境变量
使用以下键在项目根目录创建一个.env
文件(或在 shell 中导出变量):
如果设置了这些变量,服务器将不会尝试从磁盘读取credentials.json
或token.json
。
Related MCP Servers
- -securityAlicense-qualityIntegrates with Google Drive to enable listing, searching, and reading files, plus reading and writing to Google Sheets.Last updated -9186TypeScriptMIT License
- -securityFlicense-qualityEnables 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 -8Python
- -securityFlicense-qualityConnects 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 -44Python
Inkeep MCP Serverofficial
-securityAlicense-qualityA server that connects Claude to your documentation via Inkeep's API, enabling AI-powered interactions with your documentation content.Last updated -5PythonMIT License