Skip to main content
Glama

extract_variable

Extract Java expressions into local variables by specifying code positions, generating text edits for refactoring. Requires project loading first.

Instructions

Extract an expression at the given position into a local variable.

Returns the text edits needed to extract the expression. The caller should apply these edits to perform the extraction.

USAGE: Select expression by providing start and end positions OUTPUT: Variable declaration and replacement edits

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
variableNameNoName for the new variable (optional, will suggest if not provided)
endColumnYesZero-based end column of expression
filePathYesPath to source file
startColumnYesZero-based start column of expression
endLineYesZero-based end line of expression
startLineYesZero-based start line of expression
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behavioral traits: it returns text edits rather than performing the extraction directly ('Returns the text edits needed to extract the expression. The caller should apply these edits'), specifies coordinate system ('Uses ZERO-BASED coordinates'), and mentions optional parameter behavior ('variableName... will suggest if not provided'). However, it doesn't cover potential error conditions or rate limits.

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 well-structured and front-loaded with the core purpose, followed by usage instructions, output details, and important notes. Each sentence serves a distinct purpose without redundancy, and the information is presented in a logical flow that makes it easy to understand quickly.

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?

Given the complexity of a code refactoring tool with 6 parameters, no annotations, and no output schema, the description does a good job of explaining what the tool does, how to use it, and important behavioral details. It covers the prerequisite, coordinate system, and output format. However, without an output schema, it could benefit from more detail about the structure of the returned text edits.

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 description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond the schema, only reinforcing the zero-based coordinate system and the optional nature of variableName. It doesn't provide additional semantic context about parameter interactions or usage examples, meeting the baseline for high schema coverage.

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 the tool's purpose with a specific verb ('extract') and resource ('expression'), distinguishing it from siblings like 'extract_constant', 'extract_method', or 'extract_interface' by specifying it extracts into a local variable. It also clarifies the output ('text edits needed to extract the expression'), making the purpose unambiguous.

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?

The description explicitly states when to use this tool ('Select expression by providing start and end positions') and provides a crucial prerequisite ('Requires load_project to be called first'). It also distinguishes usage by specifying the output format ('Variable declaration and replacement edits'), which helps differentiate it from other extraction tools that might have different outputs or purposes.

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/pzalutski-pixel/javalens-mcp'

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