Skip to main content
Glama

extract_function

Destructive

Extract a block of MQL4/MQL5 source lines into a new helper function, detecting parameters and call site. Use dry-run to preview changes before applying.

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
sourceYesAbsolute Windows path to the .mq4/.mq5/.mqh source file.
dry_runNotrue = preview the change and write nothing; false = apply it to the files.
line_endYesLast line (1-based, inclusive) of the block to extract.
new_nameYesName of the new helper function.
line_startYesFirst line (1-based, inclusive) of the block to extract.
return_typeNoReturn type of the helper, e.g. void or double.void
target_fileNoOptional .mqh path to append the helper to; defaults to inserting above the enclosing function.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed8 schema fields changedv0.5.0
    • addedInput schema / properties / dry_run / description
      Added value: +"true = preview the change and write nothing; false = apply it to the files."
    • addedInput schema / properties / line_end / description
      Added value: +"Last line (1-based, inclusive) of the block to extract."
    • addedInput schema / properties / line_start / description
      Added value: +"First line (1-based, inclusive) of the block to extract."
    • addedInput schema / properties / new_name / description
      Added value: +"Name of the new helper function."
    • addedInput schema / properties / return_type / description
      Added value: +"Return type of the helper, e.g. void or double."
    • addedInput schema / properties / source / description
      Added value: +"Absolute Windows path to the .mq4/.mq5/.mqh source file."
    • addedInput schema / properties / target_file / description
      Added value: +"Optional .mqh path to append the helper to; defaults to inserting above the enclosing function."
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "additionalProperties": true,
      +  "title": "extract_functionDictOutput",
      +  "type": "object"
      +}
  2. First observedv0.4.1

TDQS

A3.6/5.0
Behavior4/5

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

The description discloses meaningful behavioral traits beyond the annotations: it uses brace-counting and regex rather than a full AST parser, returns a proposed helper/call site/parameter list, and requires explicitly setting dry_run=False to write. This adds real context beyond the destructiveHint annotation.

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 compact and front-loaded: purpose first, then limitations, return content, and modification behavior. Every sentence contributes useful information without unnecessary verbosity.

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?

The description covers the key operational aspects: what the tool does, its algorithmic limitations, what it returns, and how to trigger a write. An output schema exists to explain return values. It could be slightly richer about failure modes or preconditions, but is largely complete for a destructive refactoring 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 all parameters are already documented clearly. The description adds minimal extra parameter semantics beyond restating the dry_run toggle, which the schema already explains. Baseline 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 states a specific verb and resource: 'Extract a contiguous block of lines into a new helper function.' This is clear and unambiguous. It does not explicitly differentiate from sibling tools like extract_doc or extract_inputs, though 'helper function' provides useful 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?

The description gives no explicit guidance on when to use this tool versus alternatives. 'Set dry_run=False to write' explains how to apply changes, and 'not a full AST parser' hints at a limitation, but no alternative tool is named or contrasted.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.