Skip to main content
Glama

edit_source

Destructive

Make targeted edits to one root file or one component part, by exact text replacement — prefer this to update_file / update_component for any change to existing source. Each edit replaces old_string with new_string; old_string must match EXACTLY ONE place (whitespace, indentation and line breaks included), copied from your latest read_file / read_component. Zero matches is NOT_FOUND and several is AMBIGUOUS_MATCH — add surrounding text to make it unique, or set replace_all: true to change every occurrence. To delete, use new_string: ""; to insert, replace an existing block with that block plus the new content. Edits apply in order (a later old_string sees earlier edits) and all-or-nothing: if any edit fails, nothing is written. The result is parsed, validated and formatted like any write. expectedRevision is required. Changes are saved to the catalogue and can queue a thumbnail render that fetches external assets referenced by its content.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "documentId": "<documentId>",
      "expectedRevision": "<expectedRevision>",
      "edits": "<edits>",
      "llm_model": "<llm_model>"
    },
    "name": "edit_source"
  }
}

Input Schema

NameRequiredDescriptionDefault
fileNoA root file to edit. Give this, or componentId + part.
partNoWhich part of the component.
editsYes
llm_modelYesThe exact model identifier you (the assistant) are running as, taken from your system prompt or environment (e.g. "claude-opus-4-8", "gpt-5.2"). Used for analytics only. If you do not know your model identifier with certainty, pass "unknown" — never guess.
documentIdYesThe catalogue's id. Call list_documents first if you do not have one.
componentIdNoThe component to edit (its id, or its partial name).
conversation_idNoPass the exact conversation_id from the server's previous response, unchanged. The server provides it on the first call — never invent one, and do not issue parallel tool calls until you have it. Keep passing the same conversation_id for the rest of the conversation, including after later user messages or on a different task; do not reset it when the user starts a new request.
expectedRevisionYesThe contentRevision of the read you copied old_string from.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already flag the write/destructive profile, and the description adds substantial context beyond them: all-or-nothing commit semantics, order-dependent application, validation and formatting of the result, the required expectedRevision precondition, and a thumbnail render that fetches external assets. These are exactly the side effects an agent needs before mutating content.

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

Conciseness4/5

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

Front-loaded with purpose and the sibling preference, then error handling, then semantics and side effects. The single dense paragraph is efficient overall, though the trailing sentence about catalogue saving and thumbnail rendering could be tightened.

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 destructive edit tool with no output schema, the description covers the target selection, matching contract, error codes, ordering, atomicity, and post-write side effects. Nothing material is left for the agent to infer.

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 88%, so the baseline is 3; the description earns extra by explaining failure modes the schema does not (NOT_FOUND on zero matches, AMBIGUOUS_MATCH on multiple), the delete-by-empty-new_string and insert-by-expansion patterns, and that expectedRevision must come from the read the old_string was copied from.

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?

States a specific verb and resource ('make targeted edits to one root file or one component part, by exact text replacement') and explicitly names the siblings it supersedes, update_file and update_component. An agent can distinguish this from the bulk-update tools without opening any schema.

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?

Gives an explicit selection rule: prefer this over update_file / update_component for any change to existing source, and points to read_file / read_component as the source of old_string. It also tells the agent what to do when a match is not unique (add surrounding text, or use replace_all).

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources