Skip to main content
Glama

extract_constant

Extract Java expressions into static final constants at class level using zero-based coordinates to generate text edits for code refactoring.

Instructions

Extract an expression into a static final constant at class level.

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: Constant declaration and replacement edits

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
constantNameYesName for the constant (should be UPPER_SNAKE_CASE)
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
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses key behavioral traits: the tool returns 'text edits' that 'the caller should apply,' uses 'ZERO-BASED coordinates,' and has a prerequisite ('Requires load_project'). However, it lacks details on error handling, performance, or side effects, which limits the score.

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?

The description is well-structured and front-loaded, with the core purpose stated first. It uses bullet-like sections for clarity, but some redundancy exists (e.g., repeating 'extract' and coordinate details), preventing a perfect score of 5.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/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 is adequate but incomplete. It explains the purpose, usage, and output format, but lacks details on error cases, constraints, or example outputs, which are important for such a tool.

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. The description adds minimal value beyond the schema, mentioning 'start and end positions' and 'ZERO-BASED coordinates,' which are implied in the schema. This meets the baseline of 3 for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/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: 'Extract an expression into a static final constant at class level.' It specifies the verb ('extract'), resource ('expression'), and scope ('class level'), but does not explicitly differentiate it from similar sibling tools like 'extract_method' or 'extract_variable', which prevents a score of 5.

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?

The description provides clear context for usage: 'Select expression by providing start and end positions' and 'Requires load_project to be called first.' However, it does not explicitly state when to use this tool versus alternatives like 'extract_variable' or 'extract_method', which would be needed for a score of 5.

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