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

This MCP server connects Claude Desktop and other MCP clients to Google Docs and Drive, providing a powerful interface to read, edit, and manage your documents programmatically.

Installation

Prerequisites

Before getting started, make sure you have:

  • Node.js and npm (version 18+) from nodejs.org
  • Git for cloning the repository
  • A Google Account with access to the documents you want to interact with
  • Claude Desktop (optional) if you plan to use this server with Claude

Step 1: Google Cloud Project & Credentials

  1. Create a Google Cloud Project:

    • Go to the Google Cloud Console
    • Create a new project or select an existing one
    • Enable the Google Docs API and Google Drive API in the Library section
  2. 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 email as a test user
  3. Create and Download Credentials:

    • Go to "APIs & Services" -> "Credentials"
    • Click "+ CREATE CREDENTIALS" and select "OAuth client ID"
    • Choose "Desktop app" and give it a name
    • Download the credentials JSON file
    • Rename it to exactly 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 this directory.

Step 3: Install Dependencies

npm install

Step 4: Build the Server Code

npm run build

Step 5: First Run & Google Authorization

  1. Start the server:

    node ./dist/server.js
    
  2. The terminal will display a URL. Copy and paste it into your browser.

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

  4. After approving, you'll be redirected to a page that can't load (this is normal).

  5. Copy the code from the URL (between code= and &scope).

  6. Paste this code back into your terminal and press Enter.

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

Step 6: Configure Claude Desktop (Optional)

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

  2. Locate 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 the mcp_config.json file 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

Basic Document Operations

To work with Google Docs, you'll need the document ID (the long string between /d/ and /edit in the document URL):

  • Read a document:

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

    Append 'This was added by Claude!' to document YOUR_GOOGLE_DOC_ID
    
  • Insert text at a specific position:

    Insert text 'New content here' at index 100 in document YOUR_GOOGLE_DOC_ID
    
  • Delete content:

    Delete content from range 50-100 in document YOUR_GOOGLE_DOC_ID
    

Working with Tabs

For documents with multiple tabs:

  • List all tabs:

    List all tabs in document YOUR_GOOGLE_DOC_ID using the listDocumentTabs tool
    
  • Read from a specific tab:

    Read the content from tab TAB_ID in document YOUR_GOOGLE_DOC_ID
    
  • Write to a specific tab:

    Append 'New content' to tab TAB_ID in document YOUR_GOOGLE_DOC_ID
    

Formatting and Styling

  • 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
    

Document Structure

  • Create a table:

    Insert a 3x4 table at index 500 in document YOUR_GOOGLE_DOC_ID
    
  • Insert an image from URL:

    Insert an image from https://example.com/logo.png at index 100 in document YOUR_GOOGLE_DOC_ID
    
  • Upload and insert local image:

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

Comment Management

  • List comments:

    List all comments in document YOUR_GOOGLE_DOC_ID
    
  • Add a comment:

    Add a comment 'This needs revision' to document YOUR_GOOGLE_DOC_ID
    
  • Reply to a comment:

    Reply 'Fixed as requested' to comment COMMENT_ID in document YOUR_GOOGLE_DOC_ID
    

Google Drive File Management

  • List documents:

    List my recent Google Docs using the getRecentGoogleDocs tool
    
  • Search for documents:

    Search for Google Docs containing 'project proposal' using the searchGoogleDocs tool
    
  • Create a new document:

    Create a new Google Doc named 'Meeting Notes' using the createDocument tool
    
  • Folder operations:

    Create a new folder named 'Project Files' in Google Drive
    
    List the contents of folder FOLDER_ID in Google Drive
    

Troubleshooting

  • Authentication issues:

    • Ensure you've correctly set up Google Cloud credentials
    • Check that your credentials.json file is in the right location
    • Verify that you added your email as a test user
  • Claude integration problems:

    • Verify the path in mcp_config.json is correct and absolute
    • Ensure you built the server with npm run build
    • Check Claude's logs for detailed error messages
  • Tab-related errors:

    • Use listDocumentTabs to verify the tab IDs
    • Single-tab documents don't require tab IDs

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