Skip to main content
Glama

replace_symbol

Replaces a function, method, or class definition with new source code, auto-fixing indentation and rejecting syntax-breaking edits; returns file and related test check results.

Instructions

Replace a whole function/method/class definition with new_source (include the signature line and any decorators/annotations; indentation is fixed for you). Refused if it would break syntax. Returns check results for the file and its related tests.

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": {
      "name": "<name>",
      "new_source": "<new_source>"
    },
    "name": "replace_symbol"
  }
}

Input Schema

NameRequiredDescriptionDefault
nameYes
new_sourceYes

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.8/5.0
Behavior4/5

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

With no annotations, the description carries the full behavioral burden and does real work: it discloses a validation gate ('refused if it would break syntax'), an automatic normalization step ('indentation is fixed for you'), and that the call returns check results for the file and its related tests, i.e. tests are exercised as a side effect. It does not say whether the write is persisted atomically or how to undo it, which keeps it below 5.

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?

Three short sentences, front-loaded with the action and its requirement, then the safety gate, then the return. Every clause carries information; the parenthetical is dense but not redundant.

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

Completeness4/5

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

A two-parameter mutation tool with an output schema, so return values need not be spelled out in detail. The description covers the essential contract — required source shape, indentation handling, failure mode, and that checks run — with only the identifier format and persistence/reversibility left unspecified.

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 0%, so the description must supply parameter meaning, and it does substantially for new_source: it must contain the signature line and any decorators/annotations, and indentation is normalized automatically. The 'name' parameter is left implicit — the reader must guess whether it is a bare symbol name, a qualified name, or a file-scoped identifier — which is the remaining gap.

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

Purpose4/5

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

States a specific verb and resource (replace a whole function/method/class definition) and scopes it precisely: the new source must include the signature line and decorators, so it is clearly a whole-symbol rewrite rather than a line or block edit. It does not explicitly distinguish itself from siblings like get_symbol or check, so it stops short of a 5.

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

Usage Guidelines3/5

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

Usage is implied by the scoping language — this is the tool for wholesale symbol replacement, not partial edits — and the 'include the signature line' note tells the agent what condition the call must satisfy. There is no explicit when-to-use/when-not statement or named alternative, so guidance is inferential rather than stated.

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