Skip to main content
Glama

local_to_field

Promote a local variable in a method to an instance field with a dry-run preview. Apply changes safely using LSP coordinates; expected_symbol prevents stale edits.

Instructions

Promote a local variable inside a method to an instance field: the local becomes self. everywhere in the class. Point at the local variable's name (0-based LSP line/character, UTF-16 units). Defaults to a Dry Run preview; set apply=true to write. Supply expected_symbol when edits may have intervened since your LSP answer, so a stale Position fails safely. Locate the variable with your LSP first; this tool only changes code.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYes
lineYes
rootNo
applyNo
characterYes
expected_symbolNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior5/5

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

With no annotations, the description carries the full burden and does so thoroughly: it discloses dry-run vs apply behavior, 0-based LSP line/character coordinates in UTF-16 units, the expected_symbol safety mechanism for stale positions, and the class-wide scope of the change. This is rich, actionable behavioral context.

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 description is three sentences with no filler. It front-loads the purpose and then adds necessary technical and safety details in a tightly structured manner.

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?

Given no annotations and no schema descriptions, the description is complete enough for correct use: it explains the operation, coordinate system, dry-run preview, apply behavior, stale-position safety, and the LSP prerequisite. The presence of an output schema makes omission of return-value details acceptable.

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 0%, but the description compensates for the key parameters: line/character coordinates, apply, and expected_symbol. It does not clarify the 'root' parameter, which is a minor gap, but the most important invocation details are well explained.

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?

The description clearly states it promotes a local variable inside a method to an instance field, transforming the local into self.<name> everywhere in the class. This specific verb+resource combination distinguishes it from siblings like extract_variable or introduce_parameter.

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?

It provides clear workflow context: locate the variable with LSP first, use dry-run preview by default, and set apply=true to write. However, it does not explicitly name alternative tools or state when not to use this tool, so exclusion guidance is missing.

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/andrewesweet/ropey'

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