Execute Code
execute_codeExecute 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
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | TypeScript/JavaScript code to execute. Must include a return statement. | |
| servers | No | Optional: List of MCP server names to load. | |
| timeout_ms | No | Maximum execution time in milliseconds. Default: 30000. | |
| stream | No | If true, stream progress updates. Default: false. | |
| verbose | No | If true, include detailed metrics in response. Default: false. | |
| show_token_savings | No | If 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
| Name | Required | Description | Default |
|---|---|---|---|
| success | Yes | ||
| result | No | ||
| error | No | ||
| metrics | No | ||
| logs | No | ||
| tokenSavings | No |