Skip to main content
Glama

Replace Selected Text

set_selected_text
Destructive

Replaces the selected text in the Xojo IDE code editor or inserts new text at the cursor, optionally selecting a specific range first.

Instructions

Replaces the selection in the Xojo IDE's code editor with text, or inserts it at the cursor when nothing is selected. Pass selection_start to select a range first; otherwise it acts on whatever the user or an earlier call left selected. Fails if no code editor is active. For a change you can describe by its content, edit_code is more reliable because it does not depend on offsets. The change stays in the IDE until save_project. Needs the Xojo IDE running with the project open.

Input Schema

NameRequiredDescriptionDefault
textYesText to put in place of the selection
selection_startNoCharacter offset, from the start of the item's code, to select from before replacing. Omit (or -1) to use the current selection.
selection_lengthNoCharacters to select from selection_start. Default 0, which inserts without replacing anything. Ignored without selection_start.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv3.7.1
    • changedInput schema / properties / selection_length / description
      Previous value: -"Characters to select before replacing"New value: +"Characters to select from selection_start. Default 0, which inserts without replacing anything. Ignored without selection_start."
    • changedInput schema / properties / selection_start / description
      Previous value: -"Character offset to set before replacing. Skipped if -1."New value: +"Character offset, from the start of the item's code, to select from before replacing. Omit (or -1) to use the current selection."
    • changedInput schema / properties / text / description
      Previous value: -"Replacement text to insert"New value: +"Text to put in place of the selection"
  2. First observed

TDQS

A4.7/5.0
Behavior4/5

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

Annotations already flag destructiveHint=true and idempotentHint=false, but the description adds real value: the edit stays in the IDE until save_project, the IDE must be running with the project open, and it fails when no code editor is active. Doesn't describe the return value, but no output schema exists so this is a minor gap.

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?

The primary behavior is front-loaded in the first sentence, followed by parameter behavior, alternative tool, and prerequisites. Every sentence carries actionable information with no 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 3-parameter mutating tool with full schema coverage and no output schema, the description covers behavior, selection semantics, alternative tools, prerequisites, and persistence. Nothing an agent needs to invoke 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%, so the baseline is 3. The description goes slightly beyond the schema by explaining the two modes (pass selection_start to select a range, otherwise act on the current selection), reinforcing the offset-vs-selection semantics.

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 ('Replaces the selection in the Xojo IDE's code editor with text') plus the fallback behavior when nothing is selected. It is clearly distinguishable from siblings like set_code and edit_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?

Explicitly names the alternative ('edit_code is more reliable because it does not depend on offsets') and the condition that selects it (content-describable change vs offset-based). Also states prerequisites and the failure condition.

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