Skip to main content
Glama

Get Code

get_code
Read-onlyIdempotent

Fetches the body code for a Xojo method, event handler, or other code item by location or from the active code editor so you can copy the exact old_string for edit_code.

Instructions

Returns the 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. Giving a location also selects that item in the Navigator. A path that does not exist, or an item with no code editor, is an error; an empty body says so. The code is the body only: the declaration line is not included. Window and control event handlers are reachable on Xojo 2026r3 and later; on earlier releases read the .xojo_window file instead. Copy edit_code's old_string from this output. Needs the Xojo IDE running with the project open.

Input Schema

NameRequiredDescriptionDefault
locationNoDot-separated path, e.g. 'Module1.Method1', 'Window1.Opening' or 'Window1.Controls.Button1.Pressed' (note the Controls segment). Omit for the item open in the code editor.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv3.7.1
    • changedInput schema / properties / location / description
      Previous value: -"Dot-separated path (e.g. 'Module1.Method1'). Reads current location if empty."New value: +"Dot-separated path, e.g. 'Module1.Method1', 'Window1.Opening' or 'Window1.Controls.Button1.Pressed' (note the Controls segment). Omit for the item open in the code editor."
  2. First observed

TDQS

A4.4/5.0
Behavior4/5

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

Goes well beyond readOnly/idempotent annotations: discloses the Navigator side effect of passing a location, the error case for bad paths or code-less items, the empty-body behavior, the fact the declaration line is excluded, and a version gate for window/control event handlers. Slightly short of 5 only because the exact error/return shape is described qualitatively rather than concretely.

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?

Dense and front-loaded — the core behavior leads, then errors, scope limits, sibling linkage, and prerequisites. A few clauses (the location/omitted restatement) duplicate the schema, which is minor waste but not bloat.

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?

No output schema exists, and the description compensates by explaining exactly what the returned text is (body only, no declaration line) and what an empty result means. Combined with the IDE prerequisite and version caveat, an agent has everything needed to call and interpret this correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% and the schema already documents the dot-separated format, the 'Controls' segment and the omit-for-editor behavior. The description restates the omit semantics and adds the Navigator-selection consequence, but provides no meaning beyond what the schema carries, so baseline 3 applies.

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 (returns) and resource (the code body of a method/event handler/code item) plus the scope (open Xojo project). It is clearly distinguishable from siblings like get_selected_text, set_code and edit_code without needing to open 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?

Explicitly defines the two call modes (with location vs. omitted for the editor's current item) and routes the agent to the sibling that consumes the output: 'Copy edit_code's old_string from this output.' It also names an alternative for older IDE releases (.xojo_window file) and states the runtime prerequisite (IDE running, project open).

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