Skip to main content
Glama

extract_method

Extract selected code into a new method by analyzing parameters and return type. Specify the code range with zero-based coordinates.

Instructions

Extract a code block into a new method.

USAGE: Select code range, provide method name OUTPUT: Text edits for method declaration and call site

The tool analyzes the selected code to:

  • Determine which variables become parameters

  • Determine return type based on variables modified

  • Generate appropriate method signature

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesPath to source file
startColumnYesZero-based start column
endLineYesZero-based end line of code to extract
startLineYesZero-based start line of code to extract
methodNameYesName for the new method
endColumnYesZero-based end column
Behavior3/5

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

With no annotations, the description must fully convey behavioral traits. It discloses zero-based coordinates, parameter and return type determination, and output type. However, it omits side effects, error handling, or impact on existing code, which are important for a mutation tool.

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 relatively concise, using bullet points for readability. It front-loads the core purpose and usage. However, it redundantly mentions zero-based coordinates after schema descriptions, and the 'IMPORTANT' line could be integrated more smoothly.

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?

For a refactoring tool with 6 parameters and no output schema, the description covers core purpose, parameters, and output. However, it lacks details on return values, error conditions, and behavioral nuances like handling of selected code that spans methods, which would be needed for full agent understanding.

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?

The input schema already provides descriptions for all 6 parameters (100% coverage). The description adds value by explaining the tool's analytical process (parameter/return type inference) and reinforcing zero-based coordinates, which helps agents use correct values.

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 extracts a code block into a new method, which is a specific verb-resource pair. However, it does not explicitly differentiate from sibling tools like extract_variable or extract_constant, which perform similar but distinct operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides basic usage instructions (select code range, provide method name) and a prerequisite (load_project first). However, it does not specify when to use this tool versus alternatives, nor does it give exclusion criteria or when-not-to-use guidance.

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