Skip to main content
Glama
tmustier

Code Mode MCP

by tmustier

Execute JavaScript over MCP tools

exec
Destructive

Run JavaScript code to discover, inspect, and invoke MCP tools dynamically.

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?): ranked tool discovery by name and description. Use a short keyword query; if no result, rephrase or remove a term. Options: { server?, limit? }. Start here, then describe one result.

  • 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 enumeration when search is insufficient.

  • ALL_SERVERS: connection status for configured upstream servers.

  • 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.

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

TableJSON Schema
NameRequiredDescriptionDefault
codeYesRaw JavaScript function body. Use top-level await and return the final value. Do not wrap it in JSON or markdown fences.
session_idNoOptional in-memory store namespace. Defaults to default.default
timeout_msNoOptional execution timeout. Defaults to the server setting.
max_output_charsNoOptional returned-text limit. Filter large results in code instead.
Behavior5/5

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

Annotations already indicate destructive and open-world behavior. The description adds critical context: it runs as ordinary host-authority Node JS with unlimited access (process, require, fetch, filesystem), console output is captured, and output blocks can be selected via image/emit. No contradiction.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is lengthy (multiple paragraphs) but well-structured and front-loaded. However, some redundancy exists (e.g., repeating parameter defaults from schema). Could be more concise, but the detail is valuable.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool with 4 parameters and no output schema, the description is thorough. It covers execution context, global APIs, session state, output handling, error/return details, and security context. Nothing essential is missing.

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 descriptions. The description adds value beyond schema by clarifying the code parameter is a raw function body, not to wrap in JSON, and that session_id and timeout are optional with defaults. While not vastly extending schema, it provides helpful usage nuance.

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 runs JavaScript to discover and compose upstream MCP tools. The verb 'Execute' and resource 'JavaScript over MCP tools' are specific. No siblings exist, so differentiation is inherent.

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?

The description provides explicit usage instructions: use top-level await, start with search, describe one result, not to wrap in fences. It explains when to use ALL_TOOLS vs search and how to handle output. This is comprehensive 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/tmustier/code-mode-mcp'

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