Skip to main content
Glama

Set Code

set_code
DestructiveIdempotent

Replace the entire code of a method, event handler, or code item in the open Xojo project. Overwrites all existing code; use edit_code for partial changes.

Instructions

Replaces the whole code of one method, event handler or other code item in the open Xojo project: the item at location, or the one open in the code editor when location is omitted. Everything the item held is overwritten, so for a change to existing code prefer edit_code, which sends only the part that changes. The name, parameters and return type are not part of the code; set_declaration changes those. A path that does not exist, or an item with no code editor, is an error and nothing is written. 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
codeYesThe item's new code, replacing all of it
locationNoDot-separated path, as for get_code. Omit for the item open in the code editor.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv3.7.1
    • changedInput schema / properties / code / description
      Previous value: -"Source code to write"New value: +"The item's new code, replacing all of it"
    • changedInput schema / properties / location / description
      Previous value: -"Dot-separated path to navigate to first"New value: +"Dot-separated path, as for get_code. Omit for the item open in the code editor."
  2. 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 destructiveHint=true and idempotentHint=true, but the description adds real context beyond that: everything the item held is overwritten, failures write nothing, the change lives only in the IDE until save_project, and the Xojo IDE must be running with the project open. That is exactly the operational detail an agent needs before a destructive write.

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 and scope, and every following sentence carries information (alternatives, error behavior, persistence, prerequisite). It is dense and somewhat run-on with stacked clauses, but none of the content is 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?

For a destructive two-parameter write tool with no output schema, the description covers prerequisites, failure semantics, what is destroyed, what is out of scope, and how the change persists. Nothing an agent needs to call it correctly is missing.

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% and already documents both parameters, so the description only needs to add meaning. It does add a useful cross-reference (the path format is the same as get_code, and it reaches the same items), but it does not expand on the code payload beyond what the schema states.

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 (replaces) and resource (the whole code of one method/event handler/code item) with scope (in the open Xojo project). It explicitly distinguishes itself from edit_code and set_declaration, so an agent can separate the three 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?

Names the alternatives and the conditions that select them: use edit_code for a change to existing code, set_declaration for name/parameters/return type. It also states when the tool is not appropriate (nonexistent path, item with no code editor) and what follow-up call is needed (save_project).

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