Skip to main content
Glama

Execute Code

execute_code
Destructive

Execute TypeScript/JavaScript code to batch multiple MCP tool calls in a single run, saving tokens by reducing individual operations.

Instructions

Execute TypeScript/JavaScript code to perform MCP operations efficiently.

Token Savings: 90-98% vs individual tool calls. Batch operations in a single execution.

API: mcp.server('name').call('tool', params) | mcp.searchTools('query') | mcp.log('msg')

Example: const files = await mcp.filesystem.call('list_directory', { path: '/src' }); return files;

Use passthrough_call only for debugging - it has HIGH token cost.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesTypeScript/JavaScript code to execute. Must include a return statement.
serversNoOptional: List of MCP server names to load.
timeout_msNoMaximum execution time in milliseconds. Default: 30000.
streamNoIf true, stream progress updates. Default: false.
verboseNoIf true, include detailed metrics in response. Default: false.
show_token_savingsNoIf true, attach a tokenSavings block to the response estimating how many tokens execute_code saved versus calling the same tools in passthrough mode. The estimate uses the formula: passthrough = (toolCalls × 150) + (dataBytes / 1024 × 256); execution = ceil(codeChars / 3.5) + ceil(resultBytes / 3.8). Note: 256 tokens/KB is an observed average — actual savings vary by content. For passthrough-mode tools the block carries a "not applicable" note. Can also be enabled globally via metrics.alwaysShowTokenSavings in ~/.mcp-conductor.json. Default: false.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
successYes
resultNo
errorNo
metricsNo
logsNo
tokenSavingsNo
Behavior4/5

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

Annotations already indicate destructiveHint=true and readOnlyHint=false, so the description does not contradict. It adds value by explaining the execution environment, token savings, and API usage, which are not covered by 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 structured with clear sections for token savings, API, and example. It is front-loaded with the main purpose, but could be slightly more concise without losing clarity.

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?

Given the complexity of executing code and the presence of an output schema, the description covers purpose, usage, API, token savings, and an example. It lacks explicit error handling instructions but is otherwise sufficient for an AI agent.

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?

Schema coverage is 100% with detailed parameter descriptions, baseline is 3. The description enhances understanding with an example and an explanation of the show_token_savings parameter's formula, adding context beyond the schema.

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 executes TypeScript/JavaScript code for efficient MCP operations, with a specific verb and resource. It distinguishes itself from sibling tools like passthrough_call by highlighting token savings.

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

Usage Guidelines5/5

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

Explicit guidance is provided: use for batch operations to save tokens, and use passthrough_call only for debugging due to high token cost. This helps the agent decide when to use this tool versus alternatives.

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/darkiceinteractive/mcp-conductor'

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