Skip to main content
Glama

extract_function

Extracts a selected block of code into a new helper function by detecting parameters with regex, and returns the call site. Use dry_run=false to apply changes.

Instructions

Extract a contiguous block of lines into a new helper function.

Brace-counting + regex param detection — not a full AST parser. Returns the proposed helper, call site, and parameter list. Set dry_run=False to write.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceYes
line_startYes
line_endYes
new_nameYes
return_typeNovoid
target_fileNo
dry_runNo
Behavior4/5

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

With no annotations, the description carries the full burden. It discloses the use of brace-counting and regex (non-AST), states that it returns helper, call site, and parameter list, and mentions the dry_run flag. This provides good behavioral context, though more details on edge cases (e.g., mismatched braces) would improve transparency.

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 brief (three sentences) and front-loaded with the main action. It efficiently conveys key behavioral traits without superfluous details. Minor improvement: could be more structured, but conciseness is good.

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

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 7 parameters (4 required) with no schema descriptions and no output schema, the description is incomplete. It omits essential context such as what source represents (file path? code string?), line indexing (0 or 1 based?), constraints on new_name, and default behavior for target_file.

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

Parameters1/5

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

Schema coverage is 0%, yet the description only explains the dry_run parameter. It does not clarify source, line_start, line_end, new_name, return_type, or target_file. This is a critical gap, leaving agents to guess parameter meanings.

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 action: 'Extract a contiguous block of lines into a new helper function.' It uses a specific verb and resource, and distinguishes from siblings like extract_doc and extract_inputs by the function extraction context.

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

Usage Guidelines2/5

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

No explicit guidance on when to use this tool versus alternatives (e.g., AST-based extraction tools). The description mentions 'not a full AST parser' but does not name specific tools or provide when-not-to-use advice.

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/PHUICMT/mcp-mt5'

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