Google Docs MCP server

Provides a bridge between Google Docs and AI tools for reading document content, appending text, and applying formatting to specific text within documents.
Back to servers
Setup instructions
Provider
a-bonus
Release date
Apr 15, 2025
Language
TypeScript
Stats
43 stars

This server uses the Model Context Protocol (MCP) to connect Claude Desktop and other MCP clients to Google Docs and Google Drive. It provides comprehensive tools for reading, writing, and formatting Google Documents, plus complete Google Drive file management capabilities, serving as a bridge between AI assistants and your documents.

Prerequisites

Before installation, ensure you have:

  • Node.js and npm (version 18 or higher) from nodejs.org
  • Git for cloning the repository (Download Git)
  • A Google Account that owns or has access to your Google Docs
  • Basic command line familiarity
  • Claude Desktop (optional) if you plan to connect the server to Claude

Setup Instructions

Step 1: Google Cloud Project & Credentials

  1. Go to Google Cloud Console: Visit Google Cloud Console and log in.

  2. Create or Select a Project:

    • Click the project dropdown near the top and select "NEW PROJECT"
    • Name it (e.g., "My MCP Docs Server") and click "CREATE"
  3. Enable APIs:

    • Navigate to "APIs & Services" > "Library"
    • Search for and enable "Google Docs API"
    • Search for and enable "Google Drive API"
  4. Configure OAuth Consent Screen:

    • Go to "APIs & Services" > "OAuth consent screen"
    • Select "External" and click "CREATE"
    • Fill in app information:
      • App name (e.g., "Claude Docs MCP Access")
      • Your email for user support and developer contact
    • Click "SAVE AND CONTINUE"
    • Add scopes: Click "ADD OR REMOVE SCOPES" and add:
      • https://www.googleapis.com/auth/documents
      • https://www.googleapis.com/auth/drive.file
    • Click "UPDATE" then "SAVE AND CONTINUE"
    • Add your Google email as a test user and complete the setup
  5. Create Credentials:

    • Go to "APIs & Services" > "Credentials"
    • Click "+ CREATE CREDENTIALS" and select "OAuth client ID"
    • Choose "Desktop app" as application type
    • Name it (e.g., "MCP Docs Desktop Client") and click "CREATE"
  6. Download Credentials:

    • Click "DOWNLOAD JSON" from the popup
    • Rename the downloaded file to exactly credentials.json

    ⚠️ SECURITY WARNING: Treat this file like a password and never share it publicly!

Step 2: Get the Server Code

  1. Clone the Repository:

    git clone https://github.com/a-bonus/google-docs-mcp.git mcp-googledocs-server
    
  2. Navigate to Directory:

    cd mcp-googledocs-server
    
  3. Place Credentials: Move your renamed credentials.json file into this folder.

Step 3: Install Dependencies

npm install

Step 4: Build the Server Code

npm run build

Step 5: First Run & Google Authorization

  1. Run the server:

    node ./dist/server.js
    
  2. Authorize in Browser:

    • Copy the authorization URL from the terminal
    • Open it in your browser and log in with your Google account
    • Grant the requested permissions
  3. Complete Authorization:

    • After authorization, your browser will redirect to a page that can't be reached
    • Copy the code from the URL (between code= and &scope)
    • Paste this code into your terminal and press Enter
  4. Verification:

    • You should see "Authentication successful!" and a new token.json file created
    • This file contains your access token - protect it like a password

Step 6: Configure Claude Desktop (Optional)

  1. Find Your Absolute Path:

    • Use pwd (macOS/Linux) or cd (Windows) to get the full path to your server directory
  2. Locate mcp_config.json:

    • macOS: ~/Library/Application Support/Claude/mcp_config.json
    • Windows: %APPDATA%\Claude\mcp_config.json
    • Linux: ~/.config/Claude/mcp_config.json
    • Create the file if it doesn't exist
  3. Edit mcp_config.json:

    {
      "mcpServers": {
        "google-docs-mcp": {
          "command": "node",
          "args": [
            "/PATH/TO/YOUR/CLONED/REPO/mcp-googledocs-server/dist/server.js"
          ],
          "env": {}
        }
      }
    }
    

    Replace /PATH/TO/YOUR/CLONED/REPO with your actual absolute path.

  4. Restart Claude Desktop

Usage with Claude Desktop

Once configured, you can use commands like:

Use the `google-docs-mcp` server to read the document with ID `YOUR_GOOGLE_DOC_ID`.

Replace YOUR_GOOGLE_DOC_ID with the actual ID from your Google Doc's URL (the string between /d/ and /edit).

Basic Document Operations

  • Read documents: Ask Claude to read a document by ID
  • Append content: "Append 'This was added by Claude!' to document YOUR_GOOGLE_DOC_ID"
  • Insert text: "Insert text at position 500 in document YOUR_GOOGLE_DOC_ID"
  • Delete content: "Delete the text between positions 100 and 200 in document YOUR_GOOGLE_DOC_ID"

Advanced Usage Examples

  • Text Styling:

    Use `applyTextStyle` to make the text 'Important Section' bold and red (#FF0000) in document `YOUR_GOOGLE_DOC_ID`.
    
  • Paragraph Styling:

    Use `applyParagraphStyle` to center-align the paragraph containing 'Title Here' in document `YOUR_GOOGLE_DOC_ID`.
    
  • Table Creation:

    Insert a 3x4 table at index 500 in document `YOUR_GOOGLE_DOC_ID` using the `insertTable` tool.
    
  • File Management:

    List all documents in my Google Drive using `listGoogleDocs`.
    

Troubleshooting

  • Connection Issues:

    • Verify the absolute path in mcp_config.json is correct
    • Ensure the dist folder exists (run npm run build if needed)
    • Try running the server manually via terminal to check for errors
  • Authorization Errors:

    • Check that you enabled the correct Google APIs
    • Verify you added your email as a Test User
    • Confirm credentials.json is in the correct location
    • Delete token.json and restart the authorization process

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "google-docs-mcp" '{"command":"node","args":["/PATH/TO/YOUR/CLONED/REPO/mcp-googledocs-server/dist/server.js"],"env":[]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "google-docs-mcp": {
            "command": "node",
            "args": [
                "/PATH/TO/YOUR/CLONED/REPO/mcp-googledocs-server/dist/server.js"
            ],
            "env": []
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "google-docs-mcp": {
            "command": "node",
            "args": [
                "/PATH/TO/YOUR/CLONED/REPO/mcp-googledocs-server/dist/server.js"
            ],
            "env": []
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later