Skip to main content
Glama

Edit a Google Doc

edit_doc

Replace selected text in a Google Doc with new content, supporting markdown and inline HTML formatting. Applies changes directly as live text for quick document updates.

Instructions

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. new_string is interpreted as inline markdown and inline HTML (bold, italic, code, text, <u>, <span style="color:…;font-size:…pt">) — the same spelling read_doc emits, so a read can be edited and written back. To restyle text you are NOT otherwise changing, use set_style instead: it needs no copy of the text. NOTE: this is a direct edit — the change is applied as live text, not a tracked suggestion (the Docs API cannot create suggestions). If the doc has pending suggestions from other reviewers, flag to the user that your edit will sit alongside them as an accepted change.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tabNoTarget a specific tab by tabId or title (from list_tabs). Defaults to the first tab.
pageNowhich header/footer, when a doc defines more than one (default-page, first-page, even-page). Omit to use whichever exists.
accountNoGoogle account email to use. Defaults to GDOCS_DEFAULT_ACCOUNT, or the sole account.
segmentNowhich 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.
documentIdYesGoogle Doc id
new_stringYesreplacement text
old_stringYesexact text to replace (quote a unique slice from read_doc)
replace_allNoreplace every occurrence (default false)
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden and excels: it discloses markup-tolerance, ambiguity handling ('ambiguous matches return surrounding context'), that new_string supports inline markdown/HTML, and the critical limitation that edits are live text, not suggestions. It also instructs flagging pending reviewer suggestions, adding behavioral nuance beyond the schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Five dense sentences, each earning its place: core action, matching behavior, formatting semantics, alternative tool, and a direct-edit caveat. No fluff, well-structured, front-loaded with the main purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For an 8-parameter tool with no output schema, the description fully covers the essential behavioral aspects: matching, formatting, alternatives, and the suggestions caveat. Remaining parameters are documented in the schema, and the description handles the nontrivial complexities comprehensively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description adds value by explaining old_string's markup-tolerant matching and ambiguity handling, and clarifying that new_string uses the same formatting syntax as read_doc. This goes beyond the schema's terse 'replacement text' and enriches parameter meaning.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb+resource phrase 'Replace an exact unique snippet of text in a Google Doc' and distinguishes from the sibling set_style by explicitly noting when to use that alternative instead. It also clarifies the 'like a local file Edit' analogy, making the tool's purpose unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It provides clear when-to-use context: quoting a unique slice from read_doc, noting markup-tolerant matching, and stating 'To restyle text you are NOT otherwise changing, use set_style instead.' It also warns about the direct-edit nature versus tracked suggestions, giving practical usage guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dasasian/gdocs-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server