cadenmackenzie
MCP Servercadenmackenziepublic

google docs mcp

一个基于 Python 的 MCP 服务器,可读取 Google 文档并使用服务账户添加评论。

Repository Info

0
Stars
0
Forks
0
Watchers
0
Issues
Python
Language
-
License

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

  1. Clone this repository

  2. Install dependencies:

    pip install -r requirements.txt
    
  3. 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.json and place it in the project root (Use service-account-key.example.json as a reference for the expected format)
    • Share your Google Docs with the service account's email address
  4. 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:

  1. The Docs API's createComment method doesn't fully support attaching comments to specific text when using service accounts.
  2. The Drive API's comments are file-level and don't support direct attachment to specific text.

Current Approach

Our current approach is to:

  1. Find the specific text in the document using the Docs API
  2. 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 .gitignore includes service-account-key.json and 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

1

Clone the repository

git clone https://github.com/cadenmackenzie/google-docs-mcp
2

Install dependencies

cd google-docs-mcp
npm install
3

Follow the documentation

Check the repository's README.md file for specific installation and usage instructions.

Repository Details

Ownercadenmackenzie
Repogoogle-docs-mcp
LanguagePython
License-
Last fetched8/10/2025

Recommended MCP Servers

💬

Discord MCP

Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.

integrationsdiscordchat
🔗

Knit MCP

Connect AI agents to 200+ SaaS applications and automate workflows.

integrationsautomationsaas
🕷️

Apify MCP Server

Deploy and interact with Apify actors for web scraping and data extraction.

apifycrawlerdata
🌐

BrowserStack MCP

BrowserStack MCP Server for automated testing across multiple browsers.

testingqabrowsers

Zapier MCP

A Zapier server that provides automation capabilities for various apps.

zapierautomation