Skip to main content
Glama

Edit Code

edit_code
Destructive

Apply a targeted source-code edit by replacing an exact substring and leaving the rest unchanged; use it for existing-code changes instead of resending the whole item.

Instructions

Makes a targeted edit to an item's source code by replacing an exact substring, leaving everything else untouched. Reads the current code, replaces old_string with new_string, and writes it back — so you do not need to resend the whole item to change a few lines. old_string must match the existing code exactly (including whitespace and indentation) and, unless replace_all is true, must occur exactly once. Prefer this over set_code for edits to existing code. If old_string is missing or ambiguous nothing is written, and when the only difference is whitespace the error returns the exact text to retry with. Reaches the same items as get_code. The change stays in the IDE until save_project. Needs the Xojo IDE running with the project open.

Input Schema

NameRequiredDescriptionDefault
locationNoDot-separated path (e.g. 'Module1.Method1'). Edits the current location if empty.
new_stringYesText to replace old_string with.
old_stringYesExact text to find. Must match the existing code verbatim, including whitespace and indentation.
replace_allNoReplace every occurrence. If false (default), old_string must occur exactly once.

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 destructive=true and idempotent=false; the description goes further and explains atomicity ('If old_string is missing or ambiguous nothing is written'), whitespace-failure recovery ('returns the exact text to retry with'), and that the change lives in the IDE until save_project. Those are the exact operational facts an agent needs before invoking a destructive edit.

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?

Dense and front-loaded: purpose, mechanism, matching constraint, sibling preference, failure behavior, persistence, and prerequisite in six tight sentences. No filler and no repetition of the name/title.

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?

For a destructive mutation with no output schema, the description covers failure modes, persistence, and prerequisites well, and even hints at error return content. It doesn't say what a successful response looks like (e.g., confirmation, diff, or new code), which is the one remaining gap.

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, but the description adds behavioral consequence beyond the schema: the exact-match/occurrence rule and what happens (nothing is written) when old_string fails to match or is ambiguous. The location parameter's 'current location if empty' behavior is left entirely to the schema, which keeps it from a 5.

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?

Opens with a specific verb+resource and mechanism: 'targeted edit ... by replacing an exact substring, leaving everything else untouched.' It also explicitly distinguishes itself from siblings by naming set_code and stating that it reaches the same items as get_code.

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 routing rule — 'Prefer this over set_code for edits to existing code' — plus a prerequisite: 'Needs the Xojo IDE running with the project open.' Together with the note that changes persist only after save_project, the when/how is fully covered.

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