Skip to main content
Glama

Prepare an exact function-body replacement

ast_replace_symbol_body
Read-only

Replace a symbol's body while preserving its signature. Prepares a hash-bound plan for declarations, methods, accessors, and function-valued variables or properties, enabling safe review before application.

Instructions

Prepares a hash-bound body replacement while preserving the signature. Supports declarations, methods, accessors and function-valued variables/properties.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dry_runNoCompatibility field. Direct application is disabled; this tool always prepares.
new_bodyYesNew body text without the enclosing braces.
file_pathYes
symbol_pathYes
project_rootYes
allow_new_errorsNoPermit a plan with new TypeScript errors after explicit review.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
kindYes
statusYes
blockedYes
previewYes
plan_hashYes
created_atYes
expires_atYes
diagnosticsYes
block_reasonYes
operation_idYes
project_rootYes
affected_filesYes
workspace_hashYes
reference_countYes
allow_new_errorsYes
preview_truncatedYes
workspace_file_countYes
Behavior4/5

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

Annotations declare readOnlyHint=true and destructiveHint=false, and the description aligns: the dry_run parameter clarifies 'Direct application is disabled; this tool always prepares.' This is a valuable behavioral disclosure. It adds that the tool produces a 'hash-bound' result and that changes go through a plan/prepare step, which goes beyond the annotation baseline.

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?

Two sentences, front-loaded with the core action, zero filler. The supported-types list is useful and concise. Every clause earns its place.

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?

Given there's an output schema, return-value explanation isn't needed. The tool's relationship to ast_apply_operation is implied but not spelled out — for a prepare-only operation, clarifying that the prepared plan must subsequently be applied would strengthen completeness. Otherwise, the description covers purpose, supported symbols, and the prepare-only nature well.

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 description coverage is only 50%, so the description should compensate. It notably adds that new_body is 'without the enclosing braces' — a critical format detail. The dry_run/compatibility semantics are also clarified. However, symbol_path format and project_root semantics aren't explained in the description, leaving those to schema.

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?

The description states a specific verb+resource ('prepares a hash-bound body replacement') and clarifies scope ('preserving the signature'). It lists supported symbol types (declarations, methods, accessors, function-valued variables/properties). However, it doesn't explicitly distinguish from siblings like ast_rename_symbol or ast_get_operation_preview beyond the general subject matter.

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

Usage Guidelines4/5

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

The description implies when to use this tool (when you need a body swap while keeping the signature) and lists what it supports, which gives context. However, it doesn't explicitly state when NOT to use it or name alternative tools like ast_get_operation_preview/ast_apply_operation as the pipeline for applying changes, which would clarify the workflow relationship.

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/yailPeralta/ast-mcp-server'

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