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
135 stars

This comprehensive MCP server connects Claude and other AI assistants to Google Docs and Drive, allowing them to read, edit, format documents, and manage files. It serves as a powerful bridge that enables AI tools to interact with your Google ecosystem programmatically.

Installation

Prerequisites

Before installation, ensure you have:

  • Node.js (v18+) and npm
  • Git
  • A Google Account
  • Basic command line knowledge

Step 1: Set Up Google Cloud Project

  1. Go to the Google Cloud Console
  2. Create a new project or select an existing one
  3. Enable the required APIs:
    • Search for and enable "Google Docs API"
    • Search for and enable "Google Drive API"
  4. Configure the OAuth consent screen:
    • Navigate to "APIs & Services" → "OAuth consent screen"
    • Select "External" and click "CREATE"
    • Fill in app information (name, support email, developer contact)
    • Add these scopes: https://www.googleapis.com/auth/documents and https://www.googleapis.com/auth/drive.file
    • Add your Google email as a test user
  5. Create OAuth credentials:
    • Go to "APIs & Services" → "Credentials"
    • Click "+ CREATE CREDENTIALS" and select "OAuth client ID"
    • Choose "Desktop app" as the application type
    • Name your client and click "CREATE"
    • Download the JSON file and rename it to credentials.json

Step 2: Get the Server Code

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

Move your credentials.json file into the mcp-googledocs-server directory.

Step 3: Install Dependencies

npm install

Step 4: Build the Server

npm run build

Step 5: First Run & Authorization

  1. Start the server:

    node ./dist/server.js
    
  2. A URL will appear in your terminal. Copy it and open in your browser.

  3. Log in with your Google account and grant the requested permissions.

  4. After authorization, your browser will redirect to a "site can't be reached" page. Copy the code from the URL (between code= and &scope).

  5. Paste the code back in your terminal and press Enter.

  6. A token.json file will be created in your project directory.

Step 6: Configure Claude Desktop (Optional)

  1. Get the absolute path to your server directory using pwd (macOS/Linux) or cd (Windows).

  2. Locate or create Claude's configuration file:

    • macOS: ~/Library/Application Support/Claude/mcp_config.json
    • Windows: %APPDATA%\Claude\mcp_config.json
    • Linux: ~/.config/Claude/mcp_config.json
  3. Add your server configuration (replace the path with your actual path):

    {
      "mcpServers": {
        "google-docs-mcp": {
          "command": "node",
          "args": [
            "/PATH/TO/YOUR/CLONED/REPO/mcp-googledocs-server/dist/server.js"
          ],
          "env": {}
        }
      }
    }
    
  4. Save the file and restart Claude.

Usage

Basic Document Operations

Ask Claude to:

  • "Read the document with ID YOUR_GOOGLE_DOC_ID using the google-docs-mcp server."
  • "Append 'This was added by Claude!' to document YOUR_GOOGLE_DOC_ID."
  • "Insert text at index 100 in document YOUR_GOOGLE_DOC_ID."

Working with Multi-tab Documents

Listing Tabs:

  • "List all tabs in document YOUR_GOOGLE_DOC_ID using the listDocumentTabs tool."

Reading from Specific Tabs:

  • "Read the content from tab TAB_ID in document YOUR_GOOGLE_DOC_ID."

Writing to Specific Tabs:

  • "Append 'New content' to tab TAB_ID in document YOUR_GOOGLE_DOC_ID."
  • "Insert text at index 100 in tab TAB_ID of document YOUR_GOOGLE_DOC_ID."

Formatting and Structure

Text Styling:

  • "Make the text 'Important Section' bold and red in document YOUR_GOOGLE_DOC_ID."

Paragraph Styling:

  • "Center-align the paragraph containing 'Title Here' in document YOUR_GOOGLE_DOC_ID."

Tables and Images:

  • "Insert a 3x4 table at index 500 in document YOUR_GOOGLE_DOC_ID."
  • "Insert an image from 'https://example.com/image.png' at index 100."

Image Insertion Options

  1. Insert from URL:

  2. Upload Local Image:

    • "Upload and insert the image at /Users/myname/Pictures/chart.png at index 200 in document YOUR_DOC_ID."

Google Drive File Management

  • "List recent Google Docs using the getRecentGoogleDocs tool."
  • "Search for documents containing 'Project Plan' using searchGoogleDocs."
  • "Create a new folder named 'My Project' using createFolder."
  • "Move file FILE_ID to folder FOLDER_ID."

Troubleshooting

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

  • Check the path in mcp_config.json is correct
  • Ensure you ran npm run build successfully
  • Try running the server manually to check for errors

For Google authorization errors:

  • Verify you enabled the correct APIs
  • Check that your email is added as a test user
  • Confirm credentials.json is in the correct location

For tab-related issues:

  • Use listDocumentTabs to see available tab IDs
  • Ensure you're using the correct ID format
  • Remember that single-tab documents don't require a tabId

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