Execute JavaScript over MCP tools
execRun custom JavaScript to discover, compose, and execute tools from any MCP server in a single call.
Instructions
Run JavaScript to discover and compose upstream MCP tools in one call.
The code is an async function body: use top-level await and return a final value. Global APIs:
search(query, options?): recall-oriented ranked discovery over tool names, descriptions, servers, titles, and top-level input property names. Options: { server?, limit? }. Use search and describe when tool names or schemas are unknown; call known names directly.
describe(name): full metadata and JSON input/output schemas for one normalized or unambiguous raw tool name.
ALL_TOOLS: frozen complete { name, server, tool, title?, description } inventory for deterministic recovery when ranked search is insufficient.
ALL_SERVERS: frozen { server, status, toolCount, error? } summaries. Check tool counts before enumerating a server.
tools.(args) or call(name, args): invoke a tool. Names are normalized as mcp____ and returned by search or ALL_TOOLS.
text(value), image(dataUrlOrMcpImage, detail?), emit(contentBlock): select MCP output blocks.
store(key, value), load(key), clearStore(key?): explicit JSON-only in-memory session state.
signal: AbortSignal for this execution.
When vocabulary is uncertain, run several short search phrasings in one script and union the results. If search misses, filter ALL_TOOLS by name/description and slice the result; do not return the whole inventory or conclude a capability is absent from one empty search. You can return a few search results mapped through describe() to inspect their schemas in one discovery call.
Nested calls can be looped, branched, or run with Promise.all. Return a complete MCP CallToolResult to preserve all its text, image, audio, resource, structured content, error, and metadata fields. Otherwise returned values become text/JSON; use image() or emit() to select rich blocks.
This is ordinary host-authority Node JavaScript, not a security sandbox. process, require(), dynamic import(), fetch(), filesystem, network, environment, and child-process APIs have the same authority as this MCP server. node:vm supplies execution context and synchronous timeout control only. Standard output is reserved for MCP; console output is captured and returned.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Raw JavaScript function body. Use top-level await and return the final value. Do not wrap it in JSON or markdown fences. | |
| session_id | No | Optional in-memory store namespace. Defaults to default. | default |
| timeout_ms | No | Optional execution timeout. Defaults to the server setting. | |
| max_output_chars | No | Optional returned-text limit. Filter large results in code instead. |