Google Docs MCP
v1.1.2MCP server for the Google Docs API: read and edit documents, styles, tables, images, comments.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
auth_status Google connection status
Shows whether this server is connected to Google: token presence and source (env variables or a stored in-chat login), expiry, the Google account email, granted vs missing OAuth scopes, where the credentials file lives and where the OAuth client comes from. Makes no network calls and never returns the token itself. Call it first when other tools report the server is not connected.
setup_instructions Setup instructions
Step-by-step checklist for connecting this server to Google: creating a Google Cloud project and a Desktop-app OAuth client, publishing the consent screen (mandatory — Testing-mode refresh tokens die after 7 days), downloading the client JSON and handing its PATH to set_client. Works without any credentials; with your own client already configured it shortens to 'enable the API + log in' (one client serves the whole mcp-google-* line). Never asks the user to paste secrets into the chat.
set_client Save the OAuth client
Saves the OAuth client credentials from the JSON file downloaded from Google Cloud Console ('Download JSON' on a Desktop-app client). Pass the file PATH — the secret must never be pasted into the chat. The client is stored once in the shared ~/.config/mcp-google-auth/client.json (owner-only) and reused by every mcp-google-* server; tokens stay per-server. After this, call start_login.
| Parameter | Type | Description |
|---|---|---|
path * | string | Absolute path to the client_secret_*.json file downloaded from Google Cloud Console. |
start_login Start the Google login
First step of connecting from the chat, without editing config files or restarting the client. Returns authorizeUrl — show it to the user as a clickable link and ask them to open it in the browser ON THIS MACHINE, pick the Google account and approve access. A one-shot listener on 127.0.0.1 catches Google's redirect; the code is exchanged locally and never passes through the chat. Does not open the browser itself. The attempt lives 10 minutes; when the browser shows the success page, call finish_login.
finish_login Finish the Google login
Second step: waits up to 20 s for the browser consent to finish, saves the tokens to an owner-only file and verifies the login with a read-only identity call, returning the account email and the granted scopes. After success every tool works immediately — no client restart. If the user granted only part of the requested permissions, the login is still saved and missingScopes lists what will not work. Logging in under a different Google account replaces the previous login (its refresh token is revoked best-effort) and the response carries previousAccountEmail so the change never goes unnotice…
logout Disconnect from Google
Revokes the stored token at Google (oauth2.googleapis.com/revoke) and deletes the local credentials file. Tokens supplied via env variables are NOT touched — remove them from the MCP client config manually; envTokenStillSet in the response says whether any are still in effect.
create_document Create a document
Creates a new Google Doc and returns its documentId. Without markdown it calls documents.create, which accepts ONLY a title — add content afterwards with insert_text/import_markdown. With markdown, the document is created from that Markdown via Drive conversion (headings, bold/italic, links, lists, tables and code blocks become native Docs formatting) and the result carries id (the documentId), name and mimeType. The document lands in the authorized user's My Drive root; moving or sharing it needs the Drive UI or API, which this server does not cover.
| Parameter | Type | Description |
|---|---|---|
title * | string | The document title (the Drive file name). |
markdown | string | Initial content as Markdown; omitted = an empty document. |
get_document Get document structure
Returns the raw Docs API document: title, documentId, revisionId, per-tab body with every structural element's startIndex/endIndex, textRun styles, tables, lists, inlineObjects (image ids for replace_image), headers/footers (their segment ids) and named styles. This is the exact index map that range tools consume, but it is VERBOSE — for reading content prefer read_document_text, which returns compact blocks with the same indexes. include_tabs_content=true (default) populates all tabs; suggestions_view_mode controls how unresolved suggestions render (default DEFAULT_FOR_CURRENT_ACCESS).
| Parameter | Type | Description |
|---|---|---|
document_id * | string | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. |
include_tabs_content | boolean | Populate every tab's content (default true). false = first-tab legacy shape. |
suggestions_view_mode | string | How unresolved suggested edits render in the returned content. |
read_document_text Read document as text
Returns the document as compact readable blocks, per tab: each paragraph with its text, start/end indexes (UTF-16 code units — the coordinates insert_text/replace_range/delete_range/style tools take), named style (headings) and bullet flag; tables come as cells[row][column] plain text with the table's range. Inline images appear as [image:<objectId>] placeholders (the id feeds replace_image). tab_id limits the output to one tab. Call this before any range edit — every insert/delete shifts later indexes, so indexes from before a mutation are stale.
| Parameter | Type | Description |
|---|---|---|
document_id * | string | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. |
tab_id | string | Tab to target (from list_tabs). Omit for the first/only tab. |
list_tabs List document tabs
Returns the document's tab tree without content: tabId, title, position index and nested childTabs. Use the tabId values to target a specific tab in read_document_text and every editing tool. NOTE: the Docs API cannot create, rename, delete or reorder tabs — that is UI-only; this tool only discovers what exists.
| Parameter | Type | Description |
|---|---|---|
document_id * | string | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. |
export_document Export a document
Exports the document via Drive. Text formats (markdown, txt, html) are returned inline as the tool result — format=markdown is the way to read a doc as Markdown for a round trip with import_markdown. Binary formats (pdf, docx, odt, rtf, epub) require output_path and are written to that local file (the result reports saved_to and bytes); output_path also works for text formats. output_path must be absolute, and an existing file is never overwritten unless overwrite=true. Exports are capped at 10 MB by the Drive API; comments and suggestions are not part of any export. Nothing in Google Docs c…
| Parameter | Type | Description |
|---|---|---|
document_id * | string | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. |
format * | string | Target format; markdown/txt/html can be returned inline, the rest need output_path. |
output_path | string | Absolute local file path to write the export to (required for binary formats). Refused if the file already exists, unless overwrite=true. |
overwrite | boolean | Allow output_path to replace an existing file (default false). |
import_markdown Replace document with Markdown
REPLACES the ENTIRE document content with the given Markdown via Drive conversion — the Markdown round-trip writer paired with export_document format=markdown. Supported Markdown (headings, bold/italic/strikethrough, links, ordered/unordered lists, tables, code blocks, images by URL) becomes native Docs formatting. Everything not expressed in the Markdown is LOST: existing text, comment anchors (comments survive but detach), positioned objects, headers/footers and extra tabs. For surgical edits use replace_range/style tools instead. Returns the Drive file resource (id, name, modifiedTime).
| Parameter | Type | Description |
|---|---|---|
document_id * | string | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. |
markdown * | string | The full new document content as Markdown. |
insert_text Insert text
Inserts plain text at an index (UTF-16 code units; body content starts at index 1 — get indexes from read_document_text). Omit index to append at the end of the body (or of the segment when segment_id is set). Newlines in the text create new paragraphs; the text inherits the style at the insertion point — style it afterwards with style_text/style_paragraph. Every insert shifts all later indexes, so when making several edits, apply them from the END of the document backwards or re-read between edits. Returns the batchUpdate reply with the new revisionId.
| Parameter | Type | Description |
|---|---|---|
document_id * | string | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. |
text * | string | The text to insert; \n starts a new paragraph. |
index | integer | Insertion index (from read_document_text). Omit to append at the end. |
segment_id | string | Header/footer/footnote segment id (from get_document). Omit for the document body. |
tab_id | string | Tab to target (from list_tabs). Omit for the first/only tab. |
replace_range Replace a text range
Replaces the content in [start_index, end_index) with new text — one atomic batchUpdate that deletes the range and inserts at its start, so nothing is lost if either step would fail. Get fresh indexes from read_document_text first: indexes are stale after ANY previous edit. The new text takes the style at start_index. Cannot cut across a table cell boundary or delete a paragraph's final newline together with only part of the next paragraph — the API rejects such ranges. An empty replacement is allowed and equals delete_range.
| Parameter | Type | Description |
|---|---|---|
document_id * | string | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. |
end_index * | integer | End of the range to replace (exclusive). |
start_index * | integer | Start of the range to replace (inclusive). |
text * | string | The replacement text; empty string just deletes the range. |
segment_id | string | Header/footer/footnote segment id (from get_document). Omit for the document body. |
tab_id | string | Tab to target (from list_tabs). Omit for the first/only tab. |
replace_all_text Find and replace text
Replaces EVERY occurrence of a literal string (no regex) across the whole document, or only in the tabs named by tab_ids. match_case defaults to true. Returns occurrencesChanged in the batchUpdate reply — 0 means the text was not found, not an error. Safer than replace_range for textual substitutions because it does not depend on indexes; use replace_range when position matters (e.g. only one of several occurrences).
| Parameter | Type | Description |
|---|---|---|
document_id * | string | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. |
find * | string | The literal text to find (no regex). |
replace * | string | The replacement text; empty string deletes the occurrences. |
match_case | boolean | Case-sensitive matching (default true). |
tab_ids | array | Limit the replacement to these tabs (from list_tabs); omit for all tabs. |
delete_range Delete a text range
Deletes the content in [start_index, end_index) — text, inline images, whole tables or any mix, as long as the range does not cut across a table cell boundary. Get fresh indexes from read_document_text first; every delete shifts all later indexes down. Deleting a paragraph's trailing newline merges it with the next paragraph. The tab's final newline cannot be deleted. This is final — there is no undo through the API.
| Parameter | Type | Description |
|---|---|---|
document_id * | string | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. |
end_index * | integer | End of the range to delete (exclusive). |
start_index * | integer | Start of the range to delete (inclusive). |
segment_id | string | Header/footer/footnote segment id (from get_document). Omit for the document body. |
tab_id | string | Tab to target (from list_tabs). Omit for the first/only tab. |
style_text Style a text range
Applies character formatting to [start_index, end_index): bold, italic, underline, strikethrough, small_caps, font_size (points), font_family (e.g. "Roboto"), foreground_color/background_color (6-digit hex), link_url (empty string removes an existing link) and baseline_offset (superscript/subscript/none). Only the provided fields change (the fields mask is computed); at least one is required. Explicit false turns a toggle off. Get indexes from read_document_text. Styling does not shift indexes, so several style calls can safely reuse the same coordinates.
| Parameter | Type | Description |
|---|---|---|
document_id * | string | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. |
end_index * | integer | End of the range to style (exclusive). |
start_index * | integer | Start of the range to style (inclusive). |
background_color | string | Text highlight color, e.g. "#ffff00". |
baseline_offset | string | Vertical offset of the text. |
bold | boolean | Bold on/off. |
font_family | string | Font family name, e.g. "Roboto". |
font_size | number | Font size in points. |
foreground_color | string | Text color, e.g. "#1a73e8". |
italic | boolean | Italic on/off. |
link_url | string | Turn the range into a link to this URL; empty string removes an existing link. |
segment_id | string | Header/footer/footnote segment id (from get_document). Omit for the document body. |
small_caps | boolean | Small caps on/off. |
strikethrough | boolean | Strikethrough on/off. |
tab_id | string | Tab to target (from list_tabs). Omit for the first/only tab. |
underline | boolean | Underline on/off. |
style_paragraph Style paragraphs
Applies paragraph formatting to every paragraph overlapping [start_index, end_index): named_style (normal_text, title, subtitle, heading_1..heading_6 — the way to make headings), alignment (start/center/end/justified), line_spacing (100 = single, 200 = double), space_above/space_below (points), indent_start/indent_end/indent_first_line (points), keep_with_next and direction (ltr/rtl). Only the provided fields change; at least one is required. A range inside a single paragraph styles that whole paragraph.
| Parameter | Type | Description |
|---|---|---|
document_id * | string | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. |
end_index * | integer | End of the paragraph range (exclusive). |
start_index * | integer | Start of the paragraph range (inclusive). |
alignment | string | Text alignment. |
direction | string | Content direction. |
indent_end | number | Indent from the end edge, points. |
indent_first_line | number | First-line indent, points. |
indent_start | number | Indent from the start edge, points. |
keep_with_next | boolean | Keep on the same page as the next paragraph. |
line_spacing | number | 100 = single spacing, 200 = double. |
named_style | string | Named paragraph style — headings feed the document outline. |
segment_id | string | Header/footer/footnote segment id (from get_document). Omit for the document body. |
space_above | number | Extra space above the paragraph, points. |
space_below | number | Extra space below the paragraph, points. |
tab_id | string | Tab to target (from list_tabs). Omit for the first/only tab. |
set_paragraph_bullets Set or remove list bullets
Turns the paragraphs overlapping [start_index, end_index) into a list, or removes their bullets with remove=true. Presets: disc, arrow, checkbox, star, diamond (bulleted); decimal, decimal_parens, decimal_nested, upper_alpha, upper_roman, zero_decimal (numbered). Nesting follows each paragraph's leading tabs — indent with \t in insert_text before applying bullets to create sub-items. Exactly one of preset or remove is required.
| Parameter | Type | Description |
|---|---|---|
document_id * | string | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. |
end_index * | integer | End of the paragraph range (exclusive). |
start_index * | integer | Start of the paragraph range (inclusive). |
preset | string | The bullet/numbering style to apply. |
remove | boolean | true removes existing bullets instead of applying a preset. |
tab_id | string | Tab to target (from list_tabs). Omit for the first/only tab. |
insert_table Insert a table
Inserts an empty rows x columns table at an index, or at the end of the body when index is omitted. Fill the cells afterwards: read_document_text shows the new table's range and per-cell layout, then insert_text into each cell (cell content ranges are visible in get_document; each cell holds its own paragraphs). Cell merging, cell background/borders and pinned header rows are not covered by typed tools — use raw_request with mergeTableCells/updateTableCellStyle/pinTableHeaderRows.
| Parameter | Type | Description |
|---|---|---|
columns * | integer | Number of columns (the API caps width). |
document_id * | string | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. |
rows * | integer | Number of rows. |
index | integer | Insertion index (from read_document_text). Omit to append at the end. |
segment_id | string | Header/footer/footnote segment id (from get_document). Omit for the document body. |
tab_id | string | Tab to target (from list_tabs). Omit for the first/only tab. |
edit_table Edit table rows and columns
Inserts or deletes a row/column of an existing table. The table is addressed by table_start_index — the table block's start index from read_document_text (its startIndex in get_document). action=insert_row adds next to the cell at row_index/column_index (insert_below, default true); insert_column likewise (insert_right, default true); delete_row / delete_column remove the row/column containing that cell WITH ALL ITS CONTENT — that content is unrecoverable. row_index/column_index are 0-based and default to 0. Deleting shifts every later index in the document; re-read before further edits.
| Parameter | Type | Description |
|---|---|---|
action * | string | What to do with the table. |
document_id * | string | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. |
table_start_index * | integer | The table's start index (the table block's start in read_document_text). |
column_index | integer | 0-based column of the anchor cell (default 0). |
insert_below | boolean | insert_row only: insert below the anchor row (default true; false = above). |
insert_right | boolean | insert_column only: insert right of the anchor column (default true; false = left). |
row_index | integer | 0-based row of the anchor cell (default 0). |
tab_id | string | Tab to target (from list_tabs). Omit for the first/only tab. |
insert_break Insert a page or section break
Inserts a break at an index (or at the end of the body when index is omitted). kind=page starts a new page; kind=section_next_page starts a new section on a new page; kind=section_continuous starts a new section on the same page. Sections carry their own margins/columns — style them via raw_request updateSectionStyle. Breaks cannot be inserted into headers, footers, footnotes or table cells. A break occupies one index position; remove one by deleting its range with delete_range.
| Parameter | Type | Description |
|---|---|---|
document_id * | string | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. |
kind * | string | The break type. |
index | integer | Insertion index (from read_document_text). Omit to append at the end of the body. |
segment_id | string | Header/footer/footnote segment id (from get_document). Omit for the document body. |
tab_id | string | Tab to target (from list_tabs). Omit for the first/only tab. |
insert_image Insert an image
Inserts an inline image fetched from a PUBLIC URL at an index (or at the end of the body when index is omitted). The URL must be reachable by Google without auth, at most 50 MB and 25 megapixels, in PNG, JPEG or GIF; there is no upload channel — a local file must be hosted somewhere public first. width_pt/height_pt set the displayed size in points (omit both for natural size capped to the page width; when only one is given the API scales the other to keep the aspect ratio). Returns the created objectId in the reply — keep it for replace_image. Delete an image by deleting its range with del…
| Parameter | Type | Description |
|---|---|---|
document_id * | string | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. |
uri * | string | Public image URL (PNG/JPEG/GIF, <=50 MB, <=25 MP; fetched by Google, not this server). |
height_pt | number | Displayed height in points. |
index | integer | Insertion index (from read_document_text). Omit to append at the end. |
segment_id | string | Header/footer/footnote segment id (from get_document). Omit for the document body. |
tab_id | string | Tab to target (from list_tabs). Omit for the first/only tab. |
width_pt | number | Displayed width in points. |
replace_image Replace an image
Replaces an existing image's contents with a new image from a public URL, keeping the original's size and position (the new image is center-cropped to fit). image_object_id is the inline object id — read_document_text shows it inside [image:<objectId>] placeholders, and get_document lists all ids under inlineObjects. The same URL rules as insert_image apply (public, <=50 MB, <=25 MP, PNG/JPEG/GIF).
| Parameter | Type | Description |
|---|---|---|
document_id * | string | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. |
image_object_id * | string | The image's object id (from read_document_text [image:...] or get_document inlineObjects). |
uri * | string | Public URL of the new image. |
tab_id | string | Tab to target (from list_tabs). Omit for the first/only tab. |
list_comments List comments
Lists the document's comment threads via the Drive API: for each comment its id, content, author displayName, createdTime/modifiedTime, resolved flag, the quoted document text it anchors to (quotedFileContent) and its replies (with their action: resolve/reopen). Paginate with page_token; include_deleted=true also returns deleted comments as tombstones. Requires a Drive scope on the OAuth token (comments are Drive data, not Docs API data). Comment ids feed manage_comment.
| Parameter | Type | Description |
|---|---|---|
document_id * | string | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. |
include_deleted | boolean | Also return deleted comments (default false). |
page_size | integer | Comments per page (default 20, max 100). |
page_token | string | Continuation token from the previous page. |
manage_comment Create, reply to, resolve or delete a comment
Manages comment threads via the Drive API. action=create adds a NEW comment (needs content; optional quoted_text cites a passage — the API cannot anchor a new comment to a live range, that anchor format is not public, so it appears at document level). action=reply adds a reply (needs comment_id + content). action=resolve closes the thread (needs comment_id; optional content posts a closing reply); action=reopen reactivates it. action=delete PERMANENTLY removes the comment and all its replies (needs comment_id) — deleting is final, resolving is the reversible way to close a thread. Get comm…
| Parameter | Type | Description |
|---|---|---|
action * | string | What to do with the document's comments. |
document_id * | string | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. |
comment_id | string | reply/resolve/reopen/delete: the comment thread to target (from list_comments). |
content | string | create/reply: the comment text (plain text). Optional closing text for resolve/reopen. |
quoted_text | string | create only: the passage of document text the comment refers to (shown as a quote). |
raw_request Raw Google Docs API call
Escape hatch to call any Google Docs API v1 path directly, for requests the typed tools don't cover — e.g. a batchUpdate with mergeTableCells, updateTableCellStyle, pinTableHeaderRows, updateSectionStyle, updateDocumentStyle, createHeader/createFooter, createFootnote, named ranges, or several requests at once with writeControl.requiredRevisionId: path "v1/documents/<documentId>:batchUpdate", method POST, body {"requests":[...]}. The path may carry a query string. The Bearer token is added automatically; the method defaults to GET. Only docs.googleapis.com paths are reachable — Drive endpoi…
| Parameter | Type | Description |
|---|---|---|
path * | string | API path relative to https://docs.googleapis.com, e.g. "v1/documents/<documentId>:batchUpdate". |
body | object | JSON request body (POST only). |
method | string | HTTP method (the Docs API uses only these two). Defaults to GET. |