Skip to main content
Glama

extract_function

Extract a named function into a standalone program with its imports and helpers, then run it in the sandbox. Uses AST for Python, best-effort for other languages.

Instructions

Extract a named function (with its imports + referenced helpers) into a standalone program and run it in the sandbox.

python3 gets exact ast extraction; other languages best-effort block extraction (pass call to execute non-python). Returns the extracted program and per-input runs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
callNo
codeYes
languageYes
test_inputsNo
function_nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It reveals key traits: exact AST extraction for Python, best-effort for others, execution in a sandbox, and the return of the extracted program with per-input runs. This gives meaningful insight into how the tool behaves, though it does not mention error cases or side effects. Overall, it is transparent for the tool's complexity.

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, with the primary action in the first sentence and a crucial caveat in the second. Every sentence adds value, there is no filler, and the structure is front-loaded with the core purpose. It is an excellent example of conciseness.

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?

For a tool with five parameters, three required, and an output schema, the description covers the main purpose, language-specific behavior, the sandbox execution, and the return type. The presence of an output schema means return details need not be fully described. The main gap is insufficient detail on `test_inputs` and potential error conditions, but overall, the description is complete enough for an agent to select and invoke the tool correctly in most situations.

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 0%, so the description must compensate. It explicitly explains the `call` parameter ('pass `call` to execute non-python') and implies the role of `function_name` and `language`. However, it does not describe `test_inputs` format (array of strings) or how `code` is used beyond context. The description adds some semantic value but not enough to fully cover all five parameters, especially given the lack of schema descriptions.

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 tool's function: 'Extract a named function (with its imports + referenced helpers) into a standalone program and run it in the sandbox.' This uses a specific verb (extract) and resource (named function) and distinguishes it from sibling tools like execute_code or translate_code. It also mentions the return value, making the purpose unambiguous.

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 conditional usage guidance: 'python3 gets exact ast extraction; other languages best-effort block extraction (pass `call` to execute non-python).' This tells the agent when to use the `call` parameter and highlights language-specific behavior. However, it does not explicitly contrast with alternatives like execute_code or state when not to use this tool, so it falls short of full explicit 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/The-40-Thieves/codecalc'

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