SuperAPIAI Directory

mcp-google-docs

github.com · AI productivity

Google Docs API: read documents as text, structure or Markdown, and edit ranges, styles, tables and comments.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)

About this tool

Purpose

mcp-google-docs is an MCP (Model Context Protocol) server that wraps the Google Docs API, enabling AI applications to read and edit Google documents using natural language. It is aimed at MCP-capable AI clients such as Claude, Cursor, and Codex, with the goal of handing document operations over to the AI assistant while clearly defining the capability boundaries of the Google Docs API itself.

Main Capabilities

The server provides a total of 27 tools, covering the following areas:

  • Reading: Read documents as plain text, structure, or Markdown, and view the tab tree.
  • Editing: Replace, insert, and delete text by exact index ranges; supports full-text replacement (e.g., replacing all "Q3" with "Q4").
  • Formatting and structure: Set character and paragraph styles, create headings, lists, tables, and page breaks, and insert images from public URLs.
  • Comments: List, reply to, and add comment threads, and mark comments as resolved.
  • Export: Export to Markdown, PDF, DOCX, and other formats.
  • Creation: create_document can create an empty document, or generate a document from Markdown conversion in one step.

Editing uses exact index ranges (UTF-16 positions) rather than guessing. Because every insertion or deletion shifts subsequent indices, the server guides the assistant to obtain the latest indices via read_document_text before each edit, and to edit from the end of the document backward.

How to Use

Requires Node.js 20+ and a Google account. No credentials are needed during installation; the server can complete the connection within the conversation.

Recommended method: Say "connect Google Docs" in the conversation, and the assistant will guide you through creating an OAuth client and authorizing. The process includes: setup_instructions prints a checklist (create or select a Google Cloud project, enable the Google Docs API, configure the consent screen, create a desktop app OAuth client); download the client JSON and provide its path; set_client stores it with owner-only permissions, and the secret does not pass through the conversation; start_login returns a Google consent link, which you open and approve locally, and the code is returned through a one-time listener on 127.0.0.1 (PKCE), without passing through the chat; finish_login exchanges the code and saves the token to ~/.config/mcp-google-docs/credentials.json (permissions 0600). The token is re-read on every call, and the connection takes effect immediately without restarting the AI application. auth_status can be used to view the connection status, and logout can revoke and delete it.

To add manually in an AI application: Open Settings → MCP servers, select Add server, select STDIO, enter the command npx -y @a1-x-tech/mcp-google-docs@latest and the environment variables GOOGLE_DOCS_CLIENT_ID, GOOGLE_DOCS_CLIENT_SECRET, GOOGLE_DOCS_REFRESH_TOKEN, then save and restart.

Environment variable method (suitable for CI and unattended installations): Create or select a Google Cloud project, enable the Google Docs API and Google Drive API (Drive endpoints are used internally for export, Markdown conversion, and comments); configure the OAuth consent screen and create a desktop app OAuth client; authorize a Google account that owns or can edit documents. Two scopes can be requested:https://www.googleapis.com/auth/documents and https://www.googleapis.com/auth/drive。更窄的设置中,若导出、Markdown and comments only involve documents created through this OAuth client, drive.file is sufficient; read-only tools can use documents.readonly + drive.readonly. In test mode, OAuth refresh tokens may expire after seven days; for long-term access, publish the OAuth app or use an internal app in a Workspace domain. Client secrets and refresh tokens should be treated as passwords. All variables are optional; when no variables are provided, the server connects from the conversation.

Use cases

  • Read and summarize documents, including unresolved comment threads.
  • Create meeting notes documents from Markdown.
  • Insert summary paragraphs into documents, replace specific text, delete outdated sections.
  • Convert paragraphs into numbered lists, set heading levels, bold keywords, and link to a glossary.
  • Insert tables and fill in headers, add page breaks, insert images from public URLs.
  • List and summarize comment threads, reply to comments and mark them resolved, add comments quoting a sentence.
  • Export documents as Markdown, PDF, or DOCX.

Limitations

  • Content is addressed by index (UTF-16 positions in the tab body), and every insertion or deletion shifts subsequent indexes; the server guides the assistant to reread and obtain the latest indexes before each edit, and to edit from the end of the document backward.
  • import_markdown replaces the entire body: comment anchors, positioned objects, headers/footers, and additional tabs are not preserved after conversion.
  • Tabs can be read and located, but the API cannot create, rename, delete, or reorder tabs.
  • Comments are stored in Drive and managed as threads. New comments cannot be anchored to text ranges (the anchor format is not public), so they are attached at the document level, optionally quoting the relevant text.
  • Exports are limited to 10 MB and do not include comments or suggestions.
  • Inline images are fetched by Google from public URLs (PNG/JPEG/GIF, max 50 MB and 25 megapixels); there is no channel for uploading image files.
  • The AI client controls confirmation prompts; the server marks read, write, and destructive tools so clients can distinguish inspection from live changes.
  • Google Docs requires OAuth 2.0; an API key is not enough.
  • Requests are sent to Google. The local server refreshes the Google OAuth token and calls the Docs API; exports, Markdown conversion, and comments internally use Drive API endpoints. Anonymous telemetry includes installation ID, package version, AI client and platform version, and tool names, and never includes OAuth tokens, document content, tool parameters, or prompts. Set ASKADS_TELEMETRY=0 to opt out.
  • Google has per-minute quotas. On 429, the server backs off and retries; reads also retry after network and 5xx errors, but writes are never replayed after an uncertain failure, because replaying writes may duplicate edits.
  • There is no background polling. The server runs only when invoked. If the AI app supports scheduled tasks, it can periodically check documents or their comments.
Up/Down to navigate · Enter to open · ESC to closeBrowse all tools