
google docs mcp
一个基于 Python 的 MCP 服务器,可读取 Google 文档并使用服务账户添加评论。
Repository Info
About This Server
一个基于 Python 的 MCP 服务器,可读取 Google 文档并使用服务账户添加评论。
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
Google Docs MCP Server
A Python-based MCP (Message Control Protocol) server that can read Google Docs and add comments to documents using a service account.
Features
- Authenticate with Google Docs API using a service account (no user interaction required)
- Read content from Google Docs
- Add comments to documents with references to specific text
- Programmatically interact with documents owned by your platform
Why Use a Service Account?
A service account is ideal for server applications that need to access Google Docs without user interaction. This approach is perfect for:
- Platforms that own the Google Docs and need to add comments programmatically
- Automated systems that process documents
- Background services that don't have a user interface
Setup
-
Clone this repository
-
Install dependencies:
pip install -r requirements.txt -
Set up a Google Cloud Project and service account:
- Go to Google Cloud Console
- Create a new project
- Enable the Google Docs API and Google Drive API
- Create a service account and download the key file
- Rename the downloaded key file to
service-account-key.jsonand place it in the project root (Useservice-account-key.example.jsonas a reference for the expected format) - Share your Google Docs with the service account's email address
-
Run the server:
python server.py
See setup_instructions.md and service_account_guide.md for detailed setup instructions.
Usage
The server exposes several endpoints:
/docs- List available documents (shared with the service account)/docs/<doc_id>- Get document content/docs/<doc_id>/comments- Add a comment to a document
Example of adding a comment:
curl -X POST http://localhost:8000/docs/DOCUMENT_ID/comments \
-H "Content-Type: application/json" \
-d '{"comment": "This is a test comment", "search_text": "text to comment on"}'
Comment Functionality
Limitations
The Google Docs API has limitations when it comes to adding comments to specific text using service accounts:
- The Docs API's
createCommentmethod doesn't fully support attaching comments to specific text when using service accounts. - The Drive API's comments are file-level and don't support direct attachment to specific text.
Current Approach
Our current approach is to:
- Find the specific text in the document using the Docs API
- Add a comment using the Drive API that references the specific text in its content
- Example: "Regarding text 'search text': This is a comment"
This approach ensures that:
- Comments are reliably added to documents
- Comments reference the specific text they're about
- The implementation works consistently with service accounts
Security Notes
Important: This repository contains a service account key example file that should be replaced with your own:
service-account-key.example.json: Template for your service account key- Never commit actual credentials to GitHub
- Ensure your
.gitignoreincludesservice-account-key.jsonand other credential files - For production deployment, consider using environment variables or a secure vault for credentials
Testing
You can test the service account authentication with:
python test_auth.py
You can test adding comments with:
python client_example.py "text to comment on"
License
MIT
Quick Start
Clone the repository
git clone https://github.com/cadenmackenzie/google-docs-mcpInstall dependencies
cd google-docs-mcp
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.