Skip to main content
Glama

replace_signature

Destructive

Replace a function signature or class header while keeping the body and existing decorators or annotations intact, so you can update parameters, return types, or names without rewriting the implementation.

Instructions

Replace the signature of a function, or the header of a class, keeping its body. Existing decorators, Java annotations and a C++ template <...> header stay unless new_signature has its own. Code that read_symbol's signature starts with (a JS/TS const f =, a closure's key, a TS declare, a Ruby private) is replaced when new_signature starts with it, else kept. A method without a body keeps its ;. Refused for a symbol with no signature, such as a variable.

Use this when: changing a function's parameters, return type or name. Don't use this when: the body changes too (replace_function), or one parameter is added or removed (add_parameter, remove_parameter).

Example: target="LRUCache.get" new_signature="def get(self, key, default=None):"

Input Schema

NameRequiredDescriptionDefault
targetYesFunction or method name as list_symbols lists it, dotted for nesting ('LRUCache.get'); overloads take parameter types ('A.m(int)').
file_pathYesAbsolute path to the source or config file.
new_signatureYesEverything from the start of the definition up to its body, as read_symbol(depth='signature') returns it (e.g. 'def get(self, key):', JS 'get(key, d)' without the '{'); indentation on its first line is ignored.

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv3.2.0
    • addedInput schema / properties / file_path / description
      Added value: +"Absolute path to the source or config file."
    • addedInput schema / properties / new_signature / description
      Added value: +"Everything from the start of the definition up to its body, as read_symbol(depth='signature') returns it (e.g. 'def get(self, key):', JS 'get(key, d)' without the '{'); indentation on its first line is ignored."
    • addedInput schema / properties / target / description
      Added value: +"Function or method name as list_symbols lists it, dotted for nesting ('LRUCache.get'); overloads take parameter types ('A.m(int)')."
  2. First observedv2.0.1

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already declare destructiveHint=true and non-read-only, so the description's job is to explain the blast radius — and it does: the body is preserved, decorators/Java annotations/`template<...>` headers survive unless overridden, prefix tokens are conditionally replaced, and the operation is refused for symbols with no signature. That is materially more than the annotations convey.

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 the core action, then scoped by when/when-not and anchored by an example — a well-organized shape. The decorator/template preservation sentence is dense but relevant to correctness; nothing is redundant filler.

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?

An output schema exists, so return values need not be described. The description covers the mutation's side effects, preservation rules, and refusal cases, which is everything an agent needs to invoke this destructive edit safely.

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 the schema already documents all three parameters. The description still adds value by clarifying how new_signature interacts with the existing signature (prefix kept vs. replaced) and by giving a concrete target/new_signature example, though it does not restate the dotted-nesting target format.

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 ('replace the signature of a function, or the header of a class, keeping its body'), which is precise enough to distinguish it from replace_function and replace_function_body without opening either schema. The refusal condition ('symbol with no signature, such as a variable') further narrows the scope.

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?

Explicit 'Use this when' (parameter/return type/name changes) and 'Don't use this when' clauses name the exact alternatives — replace_function for body changes, add_parameter/remove_parameter for single-parameter edits. The routing decision is fully determined.

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