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 上安装 GoogleClaude 是 AI,可能会出错。请核对回答。
2 分钟设置
- 1在 cloud.anythingmcp.com 开始免费试用。
- 2在连接器商店点击 Google Docs。提示时粘贴凭据。
- 3生成 MCP API 密钥,将 AI 客户端指向生成的 MCP URL。
配置 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)
- Open https://console.cloud.google.com, pick or create a project, then APIs & Services → Library → enable Google Docs API.
- 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.
- 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). - Paste the client ID and secret into
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRETand install the connector. - 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_textreturnstitle,revisionIdandtext: the body as plain text, paragraphs and table cells in order. Images, drawings, footnotes, headers, footers and formatting are left out.gdocs_get_document_structurereturnsblocks, one per paragraph or table, withstartIndex,endIndex,type, the paragraphstyle(TITLE,HEADING_1toHEADING_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_filewithtext/markdownortext/plain.
Editing
gdocs_append_textadds text at the end of the body;\nseparates paragraphs (begin with\nto start a new paragraph).gdocs_insert_textinserts at anindex. 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 itsstartIndex, or at the end of a paragraph atendIndex - 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_textreplaces 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 returnsoccurrencesChanged.gdocs_batch_update(switched off) takes raw Docs API requests, e.g.deleteContentRange,updateTextStyle,updateParagraphStyle,createParagraphBullets,insertTable,insertPageBreak. Passwrite_control{"requiredRevisionId": "<revisionId>"}from the last read to fail instead of editing a document someone changed in between.gdocs_create_documenttakes 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 segmentormust 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.