MCP Hub
Back to servers

mcp-gdocs

MCP server for Google Docs, Drive & Comments (OAuth + Service Account)

npm436/wk
Updated
Mar 21, 2026

Quick Install

npx -y mcp-gdocs

mcp-gdocs

Русский | 中文

Why mcp-gdocs exists

MCP server for Google Docs, Google Drive and Comments with flexible authentication.

Connect Cursor, Claude Desktop, or any MCP client to your Google Docs and Drive.

Start with a single command: npx -y mcp-gdocs.


Quick Start

1. Google Cloud Setup

  1. Go to Google Cloud Console
  2. Create or select a project
  3. Enable Google Docs API and Google Drive API
  4. Choose authentication method:
  • Service Account — for automation, CI, servers
  • OAuth — for personal documents

See the Authentication section below for details.

2a. Service Account — share your documents

Share the documents/folders with the service account email (client_email from the JSON key).

2b. OAuth — authorize

GOOGLE_CLIENT_ID="your-client-id" \
GOOGLE_CLIENT_SECRET="your-client-secret" \
npx -y mcp-gdocs auth

A browser window will open for Google authorization. The refresh token is saved to ~/.config/mcp-gdocs/token.json.

3. Add to Cursor / MCP Client

Service Account:

{
  "mcpServers": {
    "mcp-gdocs": {
      "command": "npx",
      "args": ["-y", "mcp-gdocs"],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service-account.json"
      }
    }
  }
}

OAuth:

{
  "mcpServers": {
    "mcp-gdocs": {
      "command": "npx",
      "args": ["-y", "mcp-gdocs"],
      "env": {
        "GOOGLE_CLIENT_ID": "your-client-id",
        "GOOGLE_CLIENT_SECRET": "your-client-secret"
      }
    }
  }
}

The server starts automatically when the MCP client connects.


What Can It Do?

Most write operations accept an items array for bulk execution in a single call. All tools support an optional tabId parameter for multi-tab documents.

Google Docs

ToolDescription
docs_read_documentRead content as plain text, JSON, or markdown
docs_get_document_infoGet document metadata (title, ID, revision)
docs_list_document_tabsList all tabs in a multi-tab document
docs_insert_textInsert text at one or multiple positions
docs_append_textAppend text to the end
docs_delete_rangeRemove content by one or multiple index ranges
docs_replace_all_textReplace all occurrences of one or multiple patterns
docs_replace_document_contentReplace entire document content
docs_insert_page_breakInsert one or multiple page breaks
docs_apply_text_styleBold, italic, underline, colors, font, links
docs_apply_paragraph_styleAlignment, spacing, indentation
docs_apply_heading_styleHeading styles (H1–H6)
docs_insert_tableCreate tables
docs_insert_table_rowAdd row to table
docs_insert_table_columnAdd column to table
docs_delete_table_rowDelete row from table
docs_delete_table_columnDelete column from table
docs_update_table_cell_contentUpdate one or multiple cells content
docs_update_table_cell_styleCell background color
docs_insert_imageInsert one or multiple images from URL
docs_insert_local_imageInsert images from local files (upload + insert)
docs_replace_with_markdownReplace entire document from Markdown (headings, lists, tables, strikethrough, HR)
docs_append_markdownAppend Markdown-formatted content
docs_batch_updateBatch multiple operations in one API call
docs_rename_tabRename a document tab
docs_insert_table_with_dataCreate a table and fill it with data in one call
docs_format_by_textFind text and apply formatting without knowing indices

Comments

ToolDescription
docs_list_commentsList all comments with author and date
docs_get_commentGet a specific comment with replies
docs_add_commentCreate one or multiple comments anchored to text
docs_reply_to_commentReply to one or multiple comments
docs_resolve_commentMark one or multiple comments as resolved
docs_delete_commentRemove one or multiple comments

Google Drive

ToolDescription
drive_list_documentsList documents, optionally filtered
drive_search_documentsFull-text search across documents
drive_create_documentCreate one or multiple new documents
drive_create_from_templateCreate one or more documents from a template
drive_create_folderCreate one or multiple folders
drive_list_folder_contentsList folder contents
drive_get_folder_infoGet folder metadata
drive_move_fileMove one or multiple files to another folder
drive_copy_fileDuplicate one or multiple files
drive_rename_fileRename one or multiple files
drive_delete_fileMove one or multiple files to trash

Batch Operations

The batch update tool combines multiple heterogeneous operations into a single API request. This helps with the per-minute quota (60 write ops/min) during bulk formatting. Large arrays are automatically split into chunks.


Authentication

The server supports multiple authentication methods. If several variables are set, the first found is used: OAuth → SERVICE_ACCOUNT_PATHCREDENTIALS_CONFIGGOOGLE_APPLICATION_CREDENTIALS → ADC.

Service Account vs OAuth

CriteriaService AccountOAuth
Document accessOnly shared with SAAll your documents
Drive operationsOnly in shared foldersFull access to your Drive
Best forCI/CD, servers, automationPersonal use, Cursor, Claude Desktop
SetupDownload JSON key, share documentsOAuth flow in browser
Google WorkspaceImpersonation — full access as userNot needed

Enterprise (Google Workspace): with domain-wide delegation, SA can act on behalf of any domain user via GOOGLE_IMPERSONATE_USER.

Recommendation: use OAuth for personal work in Cursor/Claude Desktop. Use Service Account with impersonation for enterprise automation.

Method A: Service Account

Headless, secure, ideal for server environments.

Steps:

  1. GCP Console → IAM & Admin → Service Accounts → Create
  2. Download JSON key
  3. Share documents/folders with SA email (Editor)

Three ways to provide credentials:

A1. SERVICE_ACCOUNT_PATH (+ impersonation)

{
  "mcpServers": {
    "mcp-gdocs": {
      "command": "npx",
      "args": ["-y", "mcp-gdocs"],
      "env": {
        "SERVICE_ACCOUNT_PATH": "/path/to/service-account-key.json",
        "GOOGLE_IMPERSONATE_USER": "user@yourdomain.com"
      }
    }
  }
}

A2. CREDENTIALS_CONFIG — Base64-encoded JSON (Docker / CI / K8s)

base64 -w 0 service-account.json   # Linux
base64 -i service-account.json | tr -d '\n'   # macOS
{
  "mcpServers": {
    "mcp-gdocs": {
      "command": "npx",
      "args": ["-y", "mcp-gdocs"],
      "env": {
        "CREDENTIALS_CONFIG": "ewogICJ0eXBlIjogInNlcnZpY2VfYWNjb3VudCIs..."
      }
    }
  }
}

A3. GOOGLE_APPLICATION_CREDENTIALS

{
  "mcpServers": {
    "mcp-gdocs": {
      "command": "npx",
      "args": ["-y", "mcp-gdocs"],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service-account.json"
      }
    }
  }
}

Method B: OAuth 2.0

For personal use with interactive browser login.

Step 1: Create OAuth Client

  1. Google Cloud Console → APIs & Services → Credentials
  2. Create OAuth client ID → Desktop app
  3. Copy Client ID and Client Secret
  4. OAuth consent screen → add your email as Test User

Step 2: Authorize

GOOGLE_CLIENT_ID="your-client-id" \
GOOGLE_CLIENT_SECRET="your-client-secret" \
npx -y mcp-gdocs auth

Step 3: MCP configuration

{
  "mcpServers": {
    "mcp-gdocs": {
      "command": "npx",
      "args": ["-y", "mcp-gdocs"],
      "env": {
        "GOOGLE_CLIENT_ID": "your-client-id",
        "GOOGLE_CLIENT_SECRET": "your-client-secret"
      }
    }
  }
}

Method C: Application Default Credentials (ADC)

Ideal for Google Cloud environments (GKE, Compute Engine, Cloud Run) and local development with gcloud.

ADC is used automatically as a fallback when no other methods are configured.

For local development:

gcloud auth application-default login \
  --scopes=https://www.googleapis.com/auth/documents,https://www.googleapis.com/auth/drive

For Google Cloud: attach a service account to the compute resource — no extra variables needed.

Multiple Google Accounts (Profiles)

GOOGLE_MCP_PROFILE isolates token storage per profile:

{
  "mcpServers": {
    "mcp-gdocs-work": {
      "command": "npx",
      "args": ["-y", "mcp-gdocs"],
      "env": {
        "GOOGLE_CLIENT_ID": "...",
        "GOOGLE_CLIENT_SECRET": "...",
        "GOOGLE_MCP_PROFILE": "work"
      }
    },
    "mcp-gdocs-personal": {
      "command": "npx",
      "args": ["-y", "mcp-gdocs"],
      "env": {
        "GOOGLE_CLIENT_ID": "...",
        "GOOGLE_CLIENT_SECRET": "...",
        "GOOGLE_MCP_PROFILE": "personal"
      }
    }
  }
}

Tokens are stored separately:

~/.config/mcp-gdocs/
├── token.json              # default (no profile)
├── work/token.json         # GOOGLE_MCP_PROFILE=work
└── personal/token.json     # GOOGLE_MCP_PROFILE=personal

Token Storage

OAuth refresh tokens are stored in ~/.config/mcp-gdocs/token.json (respects XDG_CONFIG_HOME). To re-authorize, run npx -y mcp-gdocs auth again or delete the token file.

Environment Variables

VariableMethodDescription
SERVICE_ACCOUNT_PATHSAPath to SA JSON key (+ impersonation support)
GOOGLE_IMPERSONATE_USERSAEmail for impersonation (optional)
CREDENTIALS_CONFIGSABase64-encoded SA JSON (Docker/CI)
GOOGLE_APPLICATION_CREDENTIALSADCPath to SA JSON key (standard Google variable)
GOOGLE_CLIENT_IDOAuthOAuth client ID
GOOGLE_CLIENT_SECRETOAuthOAuth client secret
GOOGLE_MCP_PROFILEOAuthProfile name for isolated token storage

Known Limitations

  • SA without Workspace: Service account without Google Workspace license has Drive quota = 0 and cannot create files. Use OAuth or impersonation.
  • Comment anchoring: Programmatically created comments appear in the list but may not be anchored to text in Google Docs UI (Drive API limitation).
  • Deeply nested lists: Lists with 3+ nesting levels may have formatting artifacts when converting Markdown.
  • Paragraph style safe range: paragraph and heading style tools automatically adjust ranges to prevent styles from bleeding into adjacent paragraphs.

Troubleshooting

  • Server won't start: check that environment variables (GOOGLE_CLIENT_ID / GOOGLE_APPLICATION_CREDENTIALS) are set in the MCP config env block.
  • Authorization errors: make sure Docs API and Drive API are enabled in Google Cloud Console. For OAuth — check that your email is added as Test User in OAuth consent screen.
  • Re-authorization: delete ~/.config/mcp-gdocs/token.json and run npx -y mcp-gdocs auth again.

Changelog

License

Reviews

No reviews yet

Sign in to write a review