Skip to main content
Glama

extract_function

Extract a code block from a file into a new function. Specify file path, start and end lines, and function name. Preview changes with dry-run before applying.

Instructions

DISABLED pending AST-aware rewrite — returns a structured error explaining the limitation. The previous regex-based implementation produced unparseable code on non-trivial inputs (outer-scope identifiers misclassified as parameters; enclosing function headers spliced into the new helper body). File-existence and line-range validation still run first so obviously malformed inputs keep their familiar errors. Tracking issue: extract_function-ast-rewrite.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesFile path (relative to project root)
start_lineYesFirst line to extract (1-indexed, inclusive)
end_lineYesLast line to extract (1-indexed, inclusive)
function_nameYesName for the extracted function
dry_runNoPreview changes without applying (default: true). Set to false to apply.
Behavior4/5

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

The description provides detailed behavioral information beyond the annotations: it explains the previous implementation's flaws, that it returns a structured error, and that validation still runs. This compensates for the lack of rich annotations.

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 concise (4 sentences) and well-structured, front-loading the critical 'DISABLED' status. The tracking issue reference adds useful context without being excessively verbose.

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 the tool's disabled state and lack of output schema, the description is fully complete: it explains the limitation, the reason, the validation behavior, and even provides a tracking issue. No additional information is needed for the AI to understand the tool's current behavior.

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?

The input schema already has 100% coverage with descriptions for all 5 parameters. The description adds no extra semantic detail about the parameters, so the baseline score of 3 is appropriate.

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 is DISABLED pending a rewrite, which effectively communicates its current non-functional state. It explains what it was intended to do (extract function) and why it's disabled, helping the AI avoid using it.

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 explicitly advises against using the tool by stating it is disabled and explains the limitations. It also notes that input validation still runs, providing context on when errors occur. However, no alternative tools are suggested.

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/nikolai-vysotskyi/trace-mcp'

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