Google Docs MCP Server
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 凭据
Related MCP server: Ultimate Google Docs & Drive MCP Server
设置
克隆此存储库并导航到项目目录:
git clone https://github.com/yourusername/MCP-Google-Doc.git
cd MCP-Google-Doc安装依赖项:
npm install在 Google Cloud Console 中创建 OAuth 2.0 客户端 ID:
创建新项目或选择现有项目
启用 Google Docs API 和 Google Drive API
前往“API 和服务”>“凭证”
点击“创建凭证”>“OAuth 客户端 ID”
选择“桌面应用”作为应用程序类型
下载 JSON 文件并将其保存为项目目录中的
credentials.json
重要提示:
credentials.json和token.json文件包含敏感信息,并且已通过.gitignore排除在版本控制之外。切勿将这些文件提交到您的代码库。构建项目:
npm run build运行服务器:
npm start首次运行服务器时,它会提示您使用 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
将以下内容添加到您的配置中:
{
"mcpServers": {
"googledocs": {
"command": "node",
"args": ["/absolute/path/to/build/server.js"]
}
}
}将/absolute/path/to/build/server.js替换为您构建的 server.js 文件的实际路径。
重新启动 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 服务器添加新功能:
修改
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 中导出变量):
# 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.json或token.json 。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Flicense-quality-maintenanceConnects AI assistants like Claude to Google Drive, enabling them to browse, read, search, create, and edit files and folders using Google's official API with secure authentication.
- Alicense-qualityDmaintenanceConnects Claude Desktop to Google Docs and Google Drive, enabling comprehensive document reading, writing, formatting, structuring, and complete Drive file management including shared drives support through OAuth 2.0 authentication.82MIT
- Flicense-quality-maintenanceEnables Claude to interact with Google Docs to list, read, create, search, and update documents in a user's Google Drive. It provides a suite of tools and prompts for document management and content analysis using OAuth 2.0 authentication.1,396
- Flicense-qualityDmaintenanceEnables managing Google Drive files, Docs, and Sheets through natural language via Claude Code, with tools for listing, searching, editing, and formatting documents and spreadsheets.
Related MCP Connectors
Connect Claude to Fathom meeting recordings, transcripts, and summaries
Connect your team's living knowledge base — docs, data, issues, CRM — to Claude and ChatGPT.
Google Docs MCP Pack — read, create, and edit Google Docs via OAuth.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Gurgeron/MCPtRY'
If you have feedback or need assistance with the MCP directory API, please join our Discord server