Google Docs

Google Docs

Let your AI work with Google Docs: read a document as plain text or as headings and paragraphs with positions, create new documents, append or insert text and replace text everywhere, for example to fill a template. Personal Google accounts and Google Workspace.

7 天免费 · 无需信用卡 · EU 托管

问 Google 任何事

通过 AnythingMCP 对 Google Docs 试一个真实提示 — Claude 调用工具并返回答案。在你的消息上按 Enter 即可在 Cloud 安装。

在 Cloud 上安装 Google
Google Docs · 通过 MCP 实时
分享
Opus 4.7

Claude 是 AI,可能会出错。请核对回答。

2 分钟设置

  1. 1在 cloud.anythingmcp.com 开始免费试用。
  2. 2在连接器商店点击 Google Docs。提示时粘贴凭据。
  3. 3生成 MCP API 密钥,将 AI 客户端指向生成的 MCP URL。
立即安装 Google Docs

Google 指南

面向主流 AI 客户端的逐步设置。

配置 Google Docs

直接来自连接器定义:在哪里获取凭据、需要哪些权限,以及该适配器调用的是哪个 API。 由连接器作者以英文提供。

Google Docs

This connector reads and edits Google Docs through the Google Docs API v1 (https://docs.googleapis.com/v1): it reads a document as plain text or as positioned blocks, creates documents, appends and inserts text and replaces text everywhere in a document. It works with personal Google accounts and Google Workspace, on every document the authorizing Google account can open.

Setup (one-time, about 10 minutes)

  1. Open https://console.cloud.google.com, pick or create a project, then APIs & Services → Library → enable Google Docs API.
  2. APIs & Services → OAuth consent screen: choose Internal if you are on Google Workspace (simplest), otherwise External. For External, set the publishing status to In production: while an app is in Testing, Google revokes its refresh tokens after 7 days and the connector stops working every week. For your own use, the "unverified app" warning can be clicked through.
  3. APIs & Services → Credentials → Create credentials → OAuth client ID → application type Web application → add the authorized redirect URI <your AnythingMCP URL>/api/mcp-oauth/callback (on AnythingMCP Cloud: https://cloud.anythingmcp.com/api/mcp-oauth/callback).
  4. Paste the client ID and secret into GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET and install the connector.
  5. On the connector page, click Authorize with Provider and sign in with the Google account whose documents the AI should use. The refresh token is stored encrypted and access tokens are renewed automatically.

One Google client for all Google connectors: the same Cloud project and OAuth client can serve every Google connector (Gmail, Google Calendar, Google Drive, Google Sheets, Google Docs, Google Tasks, Search Console, Analytics, Ads). Enable each API in that project, reuse the same GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET, and authorize each connector once: each one asks only for its own scopes.

Scope: the connector asks for https://www.googleapis.com/auth/documents (read and edit every document the user can open). It does not include Google Drive, so it cannot list, search, share or delete documents. For a read-only setup, change the scope to https://www.googleapis.com/auth/documents.readonly in the connector's OAuth settings, authorize again, and disable gdocs_create_document, gdocs_append_text, gdocs_insert_text and gdocs_replace_all_text.

Switched off at install: gdocs_batch_update, which accepts any Docs API request including deleting content. Turn it on per tool if the AI needs it.

Finding a document: the id is the long string in the link, https://docs.google.com/document/d/<id>/edit. To find one by name, use the Google Drive connector's gdrive_search_files with mimeType = 'application/vnd.google-apps.document' and name contains '...', or ask the user for the link.

Reading

  • gdocs_get_document_text returns title, revisionId and text: the body as plain text, paragraphs and table cells in order. Images, drawings, footnotes, headers, footers and formatting are left out.
  • gdocs_get_document_structure returns blocks, one per paragraph or table, with startIndex, endIndex, type, the paragraph style (TITLE, HEADING_1 to HEADING_6, NORMAL_TEXT) and its text. Use it to find where to insert.
  • Both read the document's first tab only and are cut at 200 KB. A document with several tabs, or a very long one, reads better through the Google Drive connector: gdrive_export_file with text/markdown or text/plain.

Editing

  • gdocs_append_text adds text at the end of the body; \n separates paragraphs (begin with \n to start a new paragraph).
  • gdocs_insert_text inserts at an index. Indexes count UTF-16 code units (an emoji counts 2) from 1, the start of the body; each paragraph ends with a newline that belongs to it. Insert before a block at its startIndex, or at the end of a paragraph at endIndex - 1. An index inside a table's structure, rather than inside a cell's paragraph, is refused. After an insert, later indexes shift by the inserted length: read the structure again before the next index-based edit, or work from the end of the document backwards.
  • gdocs_replace_all_text replaces every occurrence of a literal text, in every tab, header and footer; replace_with: "" deletes them. It is the reliable way to fill templates ([Customer name], <date>) and returns occurrencesChanged.
  • gdocs_batch_update (switched off) takes raw Docs API requests, e.g. deleteContentRange, updateTextStyle, updateParagraphStyle, createParagraphBullets, insertTable, insertPageBreak. Pass write_control {"requiredRevisionId": "<revisionId>"} from the last read to fail instead of editing a document someone changed in between.
  • gdocs_create_document takes only a title; the API ignores content on creation. The file lands in the root of My Drive.

Quotas: Google allows about 300 read and 60 write requests per minute per user (3,000 and 600 per project). Over the limit it answers 429 RESOURCE_EXHAUSTED: wait a minute and retry. Several edits in one gdocs_batch_update count as one write.

Common errors

  • 401: the authorization expired or was revoked (always after 7 days while the consent screen is in Testing). Click Authorize with Provider again.
  • 403 PERMISSION_DENIED: the account cannot open (or cannot edit) that document, or the scope is read-only. 403 "Docs API has not been used in project": enable the Google Docs API in the Cloud project.
  • 404: the document id is wrong, or the id belongs to another file type (a Sheet or a Word file uploaded to Drive).
  • 400 Index N must be less than the end index of the referenced segment or must be inside the bounds of an existing paragraph: read the structure again and pick an index inside a paragraph.

Out of scope here: comments and suggestions, sharing, moving and deleting documents (Google Drive connector), and editing Word files stored in Drive.

你的 AI 距离 Google Docs 仅两次点击。

安装连接器、粘贴凭据、向 AI 提问。7 天免费,无需信用卡。