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
Provider
a-bonus
Release date
Apr 15, 2025
Language
TypeScript
Stats
15 stars

This MCP server provides a bridge between AI assistants like Claude and Google Docs, enabling document reading, writing, formatting, and structure manipulation through the Model Context Protocol.

Installation

Prerequisites

Before starting, ensure you have:

  • Node.js (v18+) installed from nodejs.org
  • Git installed from git-scm.com
  • A Google account
  • Basic command line knowledge
  • Claude Desktop app (optional)

Setting Up Google Cloud Credentials

  1. Create a Google Cloud Project:

  2. Enable Required APIs:

    • Go to "APIs & Services" > "Library"
    • Enable the "Google Docs API"
    • Enable the "Google Drive API"
  3. Configure OAuth Consent Screen:

    • Go to "APIs & Services" > "OAuth consent screen"
    • Select "External" and click "CREATE"
    • Enter app information (name, support email, developer contact)
    • Add these scopes:
      • https://www.googleapis.com/auth/documents
      • https://www.googleapis.com/auth/drive.file
    • Add your Google email address as a test user
  4. Create OAuth Credentials:

    • Go to "APIs & Services" > "Credentials"
    • Click "CREATE CREDENTIALS" and select "OAuth client ID"
    • Choose "Desktop app" as application type
    • Give it a name and click "CREATE"
    • Download the JSON file and rename it to credentials.json

Installing the Server

  1. Clone the repository:

    git clone https://github.com/a-bonus/google-docs-mcp.git mcp-googledocs-server
    cd mcp-googledocs-server
    
  2. Add your credentials:

    • Move your renamed credentials.json file into the project root directory
  3. Install dependencies:

    npm install
    
  4. Build the server:

    npm run build
    
  5. Authorize with Google (first run):

    node ./dist/server.js
    
    • Follow the authorization URL displayed in your terminal
    • Log in with your Google account
    • Grant the requested permissions
    • Copy the authorization code from the browser URL after code= and before &scope
    • Paste the code into your terminal and press Enter
    • This creates a token.json file in your project directory

Configuring Claude Desktop

  1. Find your server path:

    • In the project directory, run pwd (macOS/Linux) or cd (Windows)
    • Copy the full path
  2. Edit Claude's configuration:

    • Find Claude's mcp_config.json file:
      • 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. Add server configuration:

    {
      "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 path
    • Merge with existing settings if the file already exists
  4. Restart Claude Desktop

Usage

Basic Commands

To use the server with Claude, try these commands:

  • Read a document:

    Use the google-docs-mcp server to read the document with ID YOUR_GOOGLE_DOC_ID
    
  • Append text to a document:

    Append 'This was added by Claude!' to document YOUR_GOOGLE_DOC_ID using the google-docs-mcp tool
    
  • Insert text at a specific position:

    Use insertText to add "New content here" at position 500 in document YOUR_GOOGLE_DOC_ID
    

Advanced Formatting

  • Apply text styling:

    Use applyTextStyle to make the text 'Important Section' bold and red (#FF0000) in document YOUR_GOOGLE_DOC_ID
    
  • Format paragraphs:

    Use applyParagraphStyle to center-align the paragraph containing 'Title Here' in document YOUR_GOOGLE_DOC_ID
    
  • Create tables:

    Insert a 3x4 table at index 500 in document YOUR_GOOGLE_DOC_ID using the insertTable tool
    

Finding Google Doc ID

The Google Doc ID is the long string in the URL between /d/ and /edit, for example:

https://docs.google.com/document/d/THIS_IS_YOUR_DOCUMENT_ID/edit

Troubleshooting

Connection Issues

If Claude shows "Failed" or "Could not attach":

  • Verify the path in mcp_config.json is correct and absolute
  • Ensure the dist folder exists (run npm run build)
  • Try running the server manually: node /PATH/TO/SERVER/dist/server.js
  • Check Claude Desktop logs

Authorization Problems

If you encounter Google authorization errors:

  • Confirm you enabled the Google Docs and Drive APIs
  • Verify you added your email as a test user
  • Ensure credentials.json is correctly placed in the project root
  • Delete token.json and reauthorize if necessary

How to add this MCP server to 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 > MCP and click "Add new global MCP server".

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

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

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