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

This MCP server allows you to connect Claude Desktop or other MCP clients to your Google Docs and Drive, creating a powerful bridge for AI assistants to interact with your documents programmatically. It provides comprehensive tools for reading, writing, formatting documents, and managing your entire Google Drive.

Prerequisites

Before getting started, ensure you have:

  1. Node.js and npm: Version 18 or higher recommended, available from nodejs.org
  2. Git: Required for cloning the repository, available from git-scm.com/downloads
  3. A Google Account: The account that owns or has access to the Google Docs you want to interact with
  4. Command Line Familiarity: Basic comfort using a terminal or command prompt
  5. Claude Desktop (Optional): If you plan to connect this server to Claude

Setup Instructions

Step 1: Google Cloud Project & Credentials

  1. Go to Google Cloud Console: Visit the 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:
    • In the search bar, type "APIs & Services" and select "Library"
    • Search for "Google Docs API", click on it, then click "ENABLE"
    • Search for "Google Drive API", click on it, then click "ENABLE"
  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")
      • User support email (your email)
      • Developer contact information (your email)
    • Click "SAVE AND CONTINUE"
    • 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 address as a test user
    • Click "SAVE AND CONTINUE" then "BACK TO DASHBOARD"
  5. Create Credentials:
    • Go to "APIs & Services" → "Credentials"
    • Click "+ CREATE CREDENTIALS" and choose "OAuth client ID"
    • Select "Desktop app" as the application type
    • Name it (e.g., "MCP Docs Desktop Client")
    • Click "CREATE"
  6. Download Credentials File:
    • Click "DOWNLOAD JSON"
    • Rename the downloaded file to exactly credentials.json

⚠️ SECURITY WARNING: Treat the credentials.json file like a password. Do not share it publicly or commit it to GitHub.

Step 2: Get the Server Code

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

Place your renamed credentials.json file directly in the mcp-googledocs-server 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 compiled server:

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

  3. Log in with the same Google account you added as a test user and grant the requested permissions.

  4. After clicking "Allow," you'll be redirected to a page that can't be reached. Copy the code from the URL (between code= and &scope).

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

  6. You should see "Authentication successful!" and "Token stored to .../token.json"

⚠️ SECURITY WARNING: The token.json file contains access credentials. Protect it like a password and do not commit it to GitHub.

Step 6: Configure Claude Desktop (Optional)

  1. Find 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. Edit mcp_config.json to include:

    {
      "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.

  4. Save the file and 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."
  • "Can you get the content of Google Doc YOUR_GOOGLE_DOC_ID?"
  • "Append 'This was added by Claude!' to document YOUR_GOOGLE_DOC_ID."

Advanced 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."

  • Comment Management: "Use listComments to show all comments in document YOUR_GOOGLE_DOC_ID."

  • Drive Management: "Use listGoogleDocs to show my recent documents."

Always replace YOUR_GOOGLE_DOC_ID with the actual ID from a Google Doc's URL (the long string between /d/ and /edit).

Troubleshooting

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

    • Verify the path in mcp_config.json is correct and absolute
    • Ensure you ran npm run build successfully
    • Try running the command manually: node /PATH/TO/YOUR/CLONED/REPO/mcp-googledocs-server/dist/server.js
    • Check Claude Desktop logs
  • Google Authorization Errors:

    • Confirm you enabled the correct APIs (Docs, Drive)
    • Make sure you added your email as a Test User
    • Verify credentials.json is correctly placed in the project root

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