Google Docs MCP Server
March 6, 2025 · View on GitHub
A Model Context Protocol (MCP) server that enables AI assistants like Claude to seamlessly access and retrieve content from Google Docs.
Features
- Search for documents in Google Drive
- Read content from Google Docs, Sheets, and Slides
- List available documents with filtering options
- Automatic format conversion (Docs → Markdown, Sheets → CSV, etc.)
Installation
Prerequisites
- Python 3.9 or higher
- Google Cloud Platform account with Google Drive API enabled
- OAuth 2.0 client credentials
Setup
-
Clone this repository:
git clone https://github.com/yourusername/gdocs-mcp-server.git cd gdocs-mcp-server -
Install the package:
pip install -e . -
Configure OAuth credentials:
- Create a project in the Google Cloud Console
- Enable the Google Drive API
- Create OAuth 2.0 credentials (Desktop application type)
- Download the credentials JSON file
- Save it as
credentials.jsonin theconfigdirectory
Detailed Setup Guide
Creating Google Cloud Project and OAuth Credentials
- Go to the Google Cloud Console
- Click "New Project" at the top right and create a new project
- Once in your project, go to "APIs & Services" > "Library"
- Search for "Google Drive API" and enable it
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "OAuth client ID"
- Select "Desktop application" as the application type
- Name your OAuth client (e.g., "Google Docs MCP")
- Click "Create"
- Download the JSON file by clicking the download icon
- Rename the downloaded file to
credentials.json - Create a
configdirectory in your project root if it doesn't exist - Move the
credentials.jsonfile to theconfigdirectory
First Run Authentication
When you first run the server, the following will happen:
- The server will detect that you haven't authenticated yet
- It will open a browser window asking you to sign in to your Google account
- After signing in, Google will ask for permission to access your Drive files
- Once you grant permission, you'll be redirected to a page showing an authentication code
- The server will automatically receive this code and store a
token.jsonfile in yourconfigdirectory - This
token.jsonfile will be used for future authentication, so you won't need to sign in again unless the token expires
Usage
-
Start the server:
gdocs-mcp -
On first run, the server will prompt you to authorize access via a browser (as described above)
-
Configure Claude Desktop or another MCP client to connect to the server:
{ "mcpServers": { "gdocs": { "command": "gdocs-mcp" } } } -
You can now use the MCP tools in Claude or other compatible AI assistants to access your Google Docs
Setting Up Claude with the MCP Server
- Install Claude Desktop from the Anthropic website
- Open Claude Desktop
- Go to Settings > Advanced
- Under "MCP Configuration," add the following configuration:
{ "mcpServers": { "gdocs": { "command": "gdocs-mcp" } } } - Save settings and restart Claude
- When interacting with Claude, you can now use prompts like "Search my Google Docs for [query]" or "Read the content of my Google Doc with ID [id]"
Troubleshooting
Authentication Issues
- If you encounter authentication errors, delete the
token.jsonfile in yourconfigdirectory and restart the server - Make sure your
credentials.jsonfile is correctly placed in theconfigdirectory - Check that you've enabled the Google Drive API in your Google Cloud project
Connection Issues
- Ensure the server is running when trying to use it with Claude
- Check if any firewall settings are blocking the local connections
- Verify your MCP configuration in Claude settings is correct
Available Tools
1. gdocs_search
Search for documents in Google Drive.
Parameters:
query: Search query stringmax_results(optional): Maximum number of results to return
2. gdocs_read
Read content from a Google Doc.
Parameters:
doc_id: Google document IDformat(optional): Output format (markdown, text, html)
3. gdocs_list
List documents in Google Drive.
Parameters:
folder_id(optional): ID of the folder to listmax_results(optional): Maximum number of results to return
Development
Setup Development Environment
pip install -e ".[dev]"
Run Tests
pytest
Code Formatting
black .
isort .
License
MIT