Code Mode MCP
Code Mode MCP is a single-tool server that lets you write JavaScript to discover, compose, and invoke any number of upstream MCP tools in one exec call.
Discover tools – use
search(query)to find relevant tools by ranked keyword search,describe(name)to inspect exact JSON schemas, or accessALL_TOOLSandALL_SERVERSfor full inventory and connection status.Invoke upstream tools – call any connected tool via
tools.mcp__<server>__<tool>(args)or the dynamiccall(name, args)helper.Compose with full JavaScript – use loops, conditionals,
Promise.allfor parallel calls, data transformation, aggregation, and filtering within a single call.Return rich output – emit text (
text()), images (image()), or arbitrary MCP content blocks (emit()); return a fullCallToolResultto preserve text, images, audio, resources, structured content, errors, and metadata.Manage session state – store and retrieve JSON-only in-memory state across calls using
store(key, value),load(key), andclearStore().Use full Node.js authority – access
fetch, filesystem, environment variables,require(), dynamicimport(), child processes, and other Node.js APIs. This is not a security sandbox.Connect to diverse upstream servers – supports stdio, Streamable HTTP, and SSE transports with bearer token auth, OAuth client credentials, and interactive authorization-code OAuth.
Control execution – set per-call
timeout_msandmax_output_chars; use the providedAbortSignal(signal) for cooperative cancellation.Capture console output –
console.logand related methods are captured and returned as part of the result rather than written to MCP stdout.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Code Mode MCPUse exec to search GitHub for my recent issues and summarize."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Code Mode MCP
Use JavaScript to discover and compose MCP tools through one agent-agnostic stdio server.
Code Mode exposes one model-facing tool, exec. A program can search configured MCP servers, inspect exact schemas, call tools and reduce intermediate results. Upstream schemas stay out of the model's initial context.
Choose Code Mode by task shape
Use Code Mode for stages that involve:
large tool catalogs
repeated calls followed by filtering or aggregation
long deterministic chains
large intermediate results that the model does not need to inspect
Keep direct tools available for short tasks, semantic decisions, approvals, errors and rich results. A workflow can switch between direct tools and Code Mode at each stage.
The direct tools and Code Mode benchmark explains this recommendation.
Related MCP server: programmatic-mcp
How it works
MCP client
└─ exec({ code })
└─ code-mode-mcp
├─ search and describe upstream tools
├─ call tools from JavaScript
└─ return selected resultsCode Mode supports:
stdio, Streamable HTTP and legacy SSE upstream servers
bearer authentication and OAuth
cancellation, progress, elicitation, sampling, roots and logging
text, image, audio, resource and structured results
explicit JSON-only session state held in memory
Code Mode does not store tool results, screenshots, console output or intermediate values automatically.
Requirements
You need:
Node.js 22 or newer
an MCP client that can launch a stdio server
Install
Install version 0.4.0 from npm:
npm install --global @tmustier/code-mode-mcp@0.4.0
code-mode-mcp --helpConfigure upstream servers
Create ~/.config/code-mode-mcp/mcp.json:
{
"mcpServers": {
"local": {
"command": "node",
"args": ["/absolute/path/to/server.js"]
},
"remote": {
"url": "https://example.com/mcp",
"auth": "bearer",
"bearerTokenEnv": "EXAMPLE_MCP_TOKEN"
}
}
}Check the file without starting MCP:
code-mode-mcp --check-config \
--config ~/.config/code-mode-mcp/mcp.jsonThe check excludes commands, arguments, headers, tokens and environment values from its summary.
See configuration for transports, environment expansion, OAuth and config lookup.
Add Code Mode to an MCP client
Add the outer Code Mode server to your client's MCP configuration:
{
"mcpServers": {
"code-mode": {
"command": "npx",
"args": [
"-y",
"@tmustier/code-mode-mcp@0.4.0",
"--config",
"/Users/you/.config/code-mode-mcp/mcp.json"
]
}
}
}Keep the upstream config separate. Do not configure Code Mode as its own upstream server.
Use the exec tool
The code field contains a JavaScript async function body:
{
"code": "return search('app screenshot accessibility', { limit: 5 });",
"session_id": "optional-session",
"timeout_ms": 120000,
"max_output_chars": 51200
}The execution context provides:
search()for ranked tool discoverydescribe()for exact schemastools.<name>(args)andcall(name, args)for tool callsALL_TOOLSandALL_SERVERSfor bounded custom discoverytext(),image()andemit()for output selectionstore(),load()andclearStore()for in-memory JSON statesignalfor cancellation
For example:
const apps = await tools.mcp__computer_use__list_apps({});
const selected = ["Calculator", "TextEdit"];
const states = await Promise.all(
selected.map(app => tools.mcp__computer_use__get_app_state({ app }))
);
return states.map((state, index) => ({
app: selected[index],
text: state.content.find(block => block.type === "text")?.text.slice(0, 500)
}));Code Mode preserves a complete MCP CallToolResult when you return it. Filter or aggregate large results inside the program to keep model context small.
See the exec API for discovery, canonical tool names, output limits and session state.
Understand host authority
Code passed to exec has the same authority as the Node.js process. It can access the filesystem, network, environment, processes and child processes.
node:vm controls execution and interrupts synchronous loops. It is not a security sandbox. Run Code Mode inside the operating system, container, account and credential boundary you want the agent to have.
See the security model before using Code Mode with sensitive systems.
Documentation
Develop
npm ci
npm run check
npm test
npm run prepublishOnly
npm pack --dry-runMaintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Tools
- execA
Related MCP Servers
- Alicense-qualityDmaintenanceA Model Context Protocol server manager that acts as a proxy/multiplexer, enabling connections to multiple MCP servers simultaneously and providing JavaScript code execution with access to all connected MCP tools. Supports both stdio and HTTP transports with OAuth authentication, batch tool invocation, and dynamic server management.Last updated36MIT
- Alicense-qualityBmaintenanceA meta MCP server that orchestrates other MCP servers by lazily connecting to them and exposing their tools as JavaScript libraries. It allows users to execute JavaScript code that programmatically interacts with multiple MCP servers within a unified environment.Last updated541MIT
- AlicenseBqualityBmaintenanceDynamic MCP server for Node.js enabling runtime tool creation, management, and execution in isolated sandboxes (Docker or Node).Last updated8311MIT
- AlicenseAqualityAmaintenanceCode-mode MCP server (docs_search + execute_code two-tool surface) backed by a unified capability manifest across three sandbox kernels (in-process node:vm, WASM via QuickJS / Pyodide / Wasmtime, and remote microVM via E2B / Cloudflare Sandbox). At N=30 tools the bootstrap-context cost drops to 13.6% of direct tool-use. Apache-2.0.Last updated24Apache 2.0
Related MCP Connectors
Personal assistant MCP server with search, execute, packages, jobs, secrets, and integrations.
Markdown-first MCP server for Notion API with 8 composite tools and 39 actions.
Hosted AgentLux MCP server for marketplace, identity, creator, services, and social flows.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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