gdocs-mcp

v1.0.0
io.github.dasasian/gdocs-mcp Checked 1 day ago Published 1 month ago

Treat a Google Doc like a local file: content editing, tracked-changes review, comments, tables.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

list_accounts List authorized Google accounts

List the Google accounts that have been authorized for this server.

set_project_default Set this project’s default account/folder

Write this project’s defaults to a .gdocs-mcp.json in the current working directory (or update an existing one up the tree). Set a default account and/or a default folder (URL or id). The folder is where write_doc is told new docs go: a new doc given as a bare name or at the top of My Drive is refused once, naming the folder and the full path to call. It is read when the server starts, so write_doc’s description shows a change after a restart; the refusal reads it fresh. To set a folder by name, find it first with drive({ cmd: 'find' }) and pass its id.

ParameterTypeDescription
accountstringdefault Google account email (must be authorized)
folderstringdefault Drive folder (URL or id): where write_doc says a bare-named new doc will go

get_project_config Show this project’s gdocs defaults

Show the effective .gdocs-mcp.json defaults (account/folder) for the current working directory, and where the file is.

read_doc Read a Google Doc

Read a Google Doc as markdown + inline HTML. The read opens with a <style> block — one CSS rule per named style (p = Normal text, h1–h6, .title, .subtitle), in pt — and a paragraph or run shows style="…" only where it differs from its rule (text-align, line-height, margin-top/bottom/left/right, text-indent; a hanging indent is margin-left:36pt with a negative text-indent). Title and Subtitle paragraphs read as <p class="title">. A page break reads as <div style="page-break-after:always"></div> on its own line, where the break is. Every element in a paragraph reads, so an edit that quot…

ParameterTypeDescription
path *stringThe doc or tab: a Drive id or URL, /folder/doc, or /folder/doc/tab (nested: /folder/doc/tab/child). A doc with one tab needs no tab step; a doc with several is refused until one is named, and the refu…
accountstringGoogle account email to use. Defaults to GDOCS_DEFAULT_ACCOUNT, or the sole account.
modestringread mode (default clean)
pagestringwhich header/footer, when a doc defines more than one (default-page, first-page, even-page). Omit to use whichever exists.
segmentstringcontent tree to read (default body)

edit_doc Edit a Google Doc

Replace an exact unique snippet of text in a Google Doc (like a local file Edit). old_string is matched markup-tolerantly; ambiguous matches return surrounding context to disambiguate; a table is matched as its rows, in the form read_doc shows it (a pipe table, or the HTML <table> of a styled one). Elements read_doc shows are kept when old_string and new_string both hold them as read (a person chip inside a sentence you reword survives), deleted when new_string leaves them out, and created when new_string adds one: [^label] with a [^label]: note line, <time datetime="2026-11-15">Nov 15, 2026</…

ParameterTypeDescription
old_string *stringexact text to replace (quote a unique slice from read_doc)
path *stringThe doc or tab: a Drive id or URL, /folder/doc, or /folder/doc/tab (nested: /folder/doc/tab/child). A doc with one tab needs no tab step; a doc with several is refused until one is named, and the refu…
accountstringGoogle account email to use. Defaults to GDOCS_DEFAULT_ACCOUNT, or the sole account.
baseDirstringabsolute dir to resolve relative local image paths and contentFile against
confirmLossstringthe confirmLoss string from the refusal of a table edit that moves a row or column whose text comments quote, passed back exactly, after the user has agreed that those comments are lost. Never needed…
contentFilestringpath to a local markdown/text file to use as new_string, read directly by the server — preferred for long text. Absolute, or relative to baseDir. Mutually exclusive with new_string.
new_stringstringreplacement markdown (or use contentFile)
pagestringwhich header/footer, when a doc defines more than one (default-page, first-page, even-page). Omit to use whichever exists.
replace_allbooleanreplace every occurrence (default false)
segmentstringwhich content tree to target: body (default), or the page header/footer. Header/footer content is invisible to a body read — a letterhead logo lives there.
suggestbooleansend the edit as suggestions for a person to accept or reject, instead of applying it (default false)

get_page_setup Read document page setup

Read a doc’s (or tab’s) page setup — margins, page size (in points, plus a preset name if it matches letter/legal/a4/tabloid), and orientation. The read counterpart to set_page_setup; use it to mirror another document’s layout onto a new doc.

ParameterTypeDescription
path *stringThe doc or tab: a Drive id or URL, /folder/doc, or /folder/doc/tab (nested: /folder/doc/tab/child). A doc with one tab needs no tab step; a doc with several is refused until one is named, and the refu…
accountstringGoogle account email to use. Defaults to GDOCS_DEFAULT_ACCOUNT, or the sole account.

set_page_setup Set document page setup

Set document-level page setup for a doc (or tab): page margins, page size, and orientation — the File > Page setup controls. Margins and explicit page sizes are in points (72 pt = 1 inch). pageSize is a preset (letter/legal/a4/tabloid) or an explicit {width,height} in points; orientation (portrait/landscape) swaps the page dimensions. Always a direct change: page geometry is a document-style change, so there is no suggest option.

ParameterTypeDescription
path *stringThe doc or tab: a Drive id or URL, /folder/doc, or /folder/doc/tab (nested: /folder/doc/tab/child). A doc with one tab needs no tab step; a doc with several is refused until one is named, and the refu…
accountstringGoogle account email to use. Defaults to GDOCS_DEFAULT_ACCOUNT, or the sole account.
marginBottomnumberbottom margin in points
marginLeftnumberleft margin in points
marginRightnumberright margin in points
marginTopnumbertop margin in points (72 = 1 inch)
orientationstringportrait or landscape (orders the page width/height)
pageSizea preset name, or {width,height} in points

download_images Download a doc’s images

Download every embedded image in a Google Doc to a local folder. Returns the objectId→filename mapping, which correlates with read_doc’s `<img src="image:<objectId>">` markers so you can rewrite them to local paths (the inverse of publishing).

ParameterTypeDescription
dir *stringabsolute local folder to save images into (created if missing)
path *stringThe doc or tab: a Drive id or URL, /folder/doc, or /folder/doc/tab (nested: /folder/doc/tab/child). A doc with one tab needs no tab step; a doc with several is refused until one is named, and the refu…
accountstringGoogle account email to use. Defaults to GDOCS_DEFAULT_ACCOUNT, or the sole account.

list_suggestions List suggestions in a doc

List the pending suggestions (tracked changes) in a Google Doc, in document order. Each has an `id`, a `summary` (Docs’ own words for it, as in the Docs sidebar, e.g. Replace: “30” with “45”), a `context` (the change in its sentence, [deleted→inserted], so two suggestions with the same summary can be told apart), and its author and time. Returns the doc `title`. Pass the title as expectTitle and each context as expectContext to apply_suggestions. segment: "header" or "footer" lists that one’s suggestions.

ParameterTypeDescription
path *stringThe doc or tab: a Drive id or URL, /folder/doc, or /folder/doc/tab (nested: /folder/doc/tab/child). A doc with one tab needs no tab step; a doc with several is refused until one is named, and the refu…
accountstringGoogle account email to use. Defaults to GDOCS_DEFAULT_ACCOUNT, or the sole account.
pagestringwhich header/footer, when a doc defines more than one (default-page, first-page, even-page). Omit to use whichever exists.
segmentstringwhich content tree to target: body (default), or the page header/footer. Header/footer content is invisible to a body read — a letterhead logo lives there.

apply_suggestions Accept/reject one or more suggestions

Accept or reject pending suggestions (from list_suggestions) in one update. Each one is resolved on its own, exactly as clicking the check or the cross in Docs: accept keeps the proposed change, reject restores the original. Two suggestions that touch each other (by different people) are decided one at a time, and the text comes out as Docs makes it; to decide them together, pass both. A style-only suggestion resolves like any other. expectTitle is checked against the live document first (status "wrong_doc" on a mismatch, e.g. an id from a different, similarly-titled document), and each expect…

ParameterTypeDescription
expectTitle *stringthe document’s title, from list_suggestions; checked before anything is changed
path *stringThe doc or tab: a Drive id or URL, /folder/doc, or /folder/doc/tab (nested: /folder/doc/tab/child). A doc with one tab needs no tab step; a doc with several is refused until one is named, and the refu…
resolutions *arrayone entry per suggestion to resolve
accountstringGoogle account email to use. Defaults to GDOCS_DEFAULT_ACCOUNT, or the sole account.
pagestringwhich header/footer, when a doc defines more than one (default-page, first-page, even-page). Omit to use whichever exists.
segmentstringwhich content tree to target: body (default), or the page header/footer. Header/footer content is invisible to a body read — a letterhead logo lives there.

list_comments List comments on a doc

List the comments on a Google Doc, each with the text it is on (`quotedText`), the sentence around it (`context`, the text in ⟦⟧), its author (a display name, never an email) and time, whether it is open or resolved, its body and its replies. A comment with a `range` is on that part of the doc, in the body or in a header or footer, and moves with its text; a comment with none was made in Drive and has only its quoted text. Pass a comment’s `id` as replyTo to add_comment, and its `quotedText` as expectQuotedText to resolve_comment.

ParameterTypeDescription
path *stringThe doc: a Drive id or URL, or /folder/doc. A tab path names its doc.
accountstringGoogle account email to use. Defaults to GDOCS_DEFAULT_ACCOUNT, or the sole account.

add_comment Add a comment or reply

Comment on text in a Google Doc: `quotedText` is the text the comment sits on, found the way edit_doc finds old_string (markup-tolerant; text that matches more than once is refused with the context of each match, so quote more of it). The comment stays on that text as it moves. Docs has no comment on the whole doc, so quotedText is required; put overall feedback on the title, or on its first words. The tab comes from path, and segment: "header" or "footer" comments in the page header or footer. To reply to an existing comment instead, pass replyTo (a comment id from list_comments) and no quote…

ParameterTypeDescription
content *stringthe comment, or the reply
path *stringThe doc or tab: a Drive id or URL, /folder/doc, or /folder/doc/tab (nested: /folder/doc/tab/child). A doc with one tab needs no tab step; a doc with several is refused until one is named, and the refu…
accountstringGoogle account email to use. Defaults to GDOCS_DEFAULT_ACCOUNT, or the sole account.
pagestringwhich header/footer, when a doc defines more than one (default-page, first-page, even-page). Omit to use whichever exists.
quotedTextstringthe text to comment on; required unless replyTo is given
replyTostringa comment id (from list_comments) to reply to; omit to start a new comment
segmentstringwhich content tree to target: body (default), or the page header/footer. Header/footer content is invisible to a body read — a letterhead logo lives there.

resolve_comment Resolve or reopen a comment

Resolve (or reopen) a comment thread by comment id. expectQuotedText is REQUIRED: the `quotedText` list_comments gave for that comment, exactly. It is checked against the live comment first, so a stale or wrong id is refused instead of resolving the wrong thread.

ParameterTypeDescription
commentId *string
expectQuotedText *stringthe comment’s quotedText from list_comments; verified before the comment is changed
path *stringThe doc: a Drive id or URL, or /folder/doc. A tab path names its doc.
accountstringGoogle account email to use. Defaults to GDOCS_DEFAULT_ACCOUNT, or the sole account.
reopenbooleanreopen instead of resolve

export_doc Export a doc to a file

Export a Google Doc to a real file on disk — pdf (default), docx, odt, rtf, txt, html, epub, or md. Google renders it server-side (File > Download in the UI), so page setup, pagination and layout match the editor. A doc path exports every tab; a tab path (/folder/doc/tab) exports only that tab, through an endpoint Google does not document and rate-limits — if it fails the call is refused and says so, it never falls back to the whole doc. Returns the local path and byte size. Note: Drive refuses to export files larger than 10 MB.

ParameterTypeDescription
dir *stringabsolute local folder to save the export into (created if missing)
path *stringThe doc: a Drive id or URL, or /folder/doc. A tab path names its doc.
accountstringGoogle account email to use. Defaults to GDOCS_DEFAULT_ACCOUNT, or the sole account.
filenamestringoverride the filename (default: the doc’s title + extension)
formatstringdefault pdf

write_doc Write a doc or a tab

Write markdown-rendered content to a path, like the local Write tool. A path that names nothing is CREATED and never asks, but only an absolute path (or a Drive id or URL start) creates: a bare name like Contract is refused with the full path to call. When the project has a default folder for new docs, a new doc at the top of My Drive (/Contract) is refused once too, with the default folder’s full path to call, so the user is told where it goes first; the same call repeated goes through: /Work/Contract creates a doc in the folder /Work, /Work/Contract/Notes a tab in that doc, /Work/Contract/…

ParameterTypeDescription
path *stringThe doc or tab to write: /folder/doc, /folder/doc/tab, /folder/doc/tab/child, or a doc id or URL followed by tab steps. A path that does not exist yet is created (only its last step may be new).
accountstringGoogle account email to use. Defaults to GDOCS_DEFAULT_ACCOUNT, or the sole account.
baseDirstringabsolute dir to resolve relative local image paths against (e.g. the markdown file’s folder)
confirmLossstringthe confirmLoss string from the refusal, passed back exactly, after the user has agreed to what it lists. Never needed when creating, or with suggest.
contentstringmarkdown content (or use contentFile)
contentFilestringpath to a local markdown/text file to use as the body, read directly by the server — preferred for long documents so the body is passed through mechanically rather than retyped inline (which can sil…
pagestringwhich header/footer, when a doc defines more than one (default-page, first-page, even-page). Omit to use whichever exists.
segmentstringwhich content tree to target: body (default), or the page header/footer. Header/footer content is invisible to a body read — a letterhead logo lives there.
suggestbooleansend the replace as suggestions for a person to accept or reject, instead of applying it (default false)

drive Drive as a filesystem

Navigate and reorganise Google Drive with shell commands: ls, find, mkdir, cp, mv. Arguments are positional and follow the usual shell forms. ls [path] — list a folder (default My Drive root). find <text> [-type d|f] — search everything by name, including files no path can reach. mkdir [-p] <path> — create a folder. cp <src> <dst> — duplicate a file (preserves headers/footers, image sizing and exact formatting, which a markdown round-trip cannot rebuild). mv <src> <dst> — move and/or rename, as on a filesystem: an existing folder as <dst> means "into it", anything else means "to that…

ParameterTypeDescription
cmd *string
acceptOwnershipTransferbooleanmv only: required to move into /shared/… , which hands ownership to that drive's organisation and cannot be undone
accountstringGoogle account email to use. Defaults to GDOCS_DEFAULT_ACCOUNT, or the sole account.
argsarraypositional arguments for cmd, e.g. ["/Work/Roof", "/Archive"] for mv
expectNamestringmv only: the name the source is expected to have; the move is refused if it resolved to something else
indexintegermv of a tab only: its position among its new siblings, 0 first. Without it a tab keeps its place, or goes first when nested.

list_permissions List who a doc is shared with

List the permissions on a Google Doc (people, groups, domain, anyone-with-link) with their roles. Each entry carries a `subject` naming who it covers — an email, "<domain> (domain)", or "anyone with the link" — since a domain or link grant has no email. For those, `allowFileDiscovery: true` means the file also surfaces in that audience's search, not merely that it opens with the link. Note a doc created under a Workspace domain may already carry a domain grant before you share it.

ParameterTypeDescription
path *stringThe doc: a Drive id or URL, or /folder/doc. A tab path names its doc.
accountstringGoogle account email to use. Defaults to GDOCS_DEFAULT_ACCOUNT, or the sole account.

share_doc Share a doc (person or link)

Grant access to a Google Doc. With `email`, share with that person as reader/commenter/writer (optionally sending a notification). Without `email`, set anyone-with-link access to that role, or role "none" to disable link sharing. (To revoke a specific person’s access, use unshare_doc.)

ParameterTypeDescription
path *stringThe doc: a Drive id or URL, or /folder/doc. A tab path names its doc.
accountstringGoogle account email to use. Defaults to GDOCS_DEFAULT_ACCOUNT, or the sole account.
emailstringperson to share with; omit to set anyone-with-link access instead
notifybooleanwhen sharing with a person, send a notification email (default true)
rolestringaccess level; default writer. "none" (link only) disables link sharing.

unshare_doc Remove someone’s access

Revoke a grant on a Google Doc. Pass `email` for a person or a group. A grant with no email — a domain-wide grant, or anyone-with-link — has no email to pass, so address it by `permissionId` from list_permissions (run that first; it also tells you the role you are about to remove). Refuses to touch the owner. `expectRole` is REQUIRED — run list_permissions first and echo the role back; a permission change is recorded nowhere and cannot be restored from version history, so this is the only thing standing between a misaimed call and a silent, unrecoverable revocation. Note a doc created un…

ParameterTypeDescription
expectRole *stringREQUIRED — the grant's current role as list_permissions reported it (reader/commenter/writer). Verified first: if it changed since you looked, nothing is removed. Revoking leaves no record anywhere,…
path *stringThe doc: a Drive id or URL, or /folder/doc. A tab path names its doc.
accountstringGoogle account email to use. Defaults to GDOCS_DEFAULT_ACCOUNT, or the sole account.
emailstringperson or group to revoke; omit when using permissionId
expectTitlestringthe doc’s title; verified before revoking so a wrong id is refused
permissionIdstringid from list_permissions — the only way to revoke a domain or anyone-with-link grant