code-mode
Reviewed
at commit eea4077
Caution: Lets one approval of a run_code program cover every MCP call inside it that no permission rule decides, so those calls run without their own prompt.
Sends data to The MCP servers you have connected, called by the programs Claude writes
Code mode for MCP: the model writes one JavaScript program that calls MCP tools in a sandbox, instead of one tool call per step.
0 upvotes
Log in to upvote or save- Made by
- gpavanello
- Pinned commit
-
eea4077bd8428ce77251211baf9c04106e1d4f55 - What we checked
-
Adds tools that let Claude write one JavaScript program that calls your MCP tools in a separate local Node process. Only the program's result goes back into the chat. By default your approval of the program also covers the MCP calls inside it. Approved usage hints, saved functions, files the program saves, and learned tool field names are kept in ~/.claude/code-mode.
Review details
Static review of the source at the pinned commit; not run. A SessionStart shell hook only prints a fixed instruction to use run_code. The hooks module registers six tools with $.tool.register on session.start (run_code, search_tools, add_hint, remove_hint, edit_hint, save_function) and handles them in tool.call hooks. run_code makes a temp folder with mktemp, then starts the configured node (default node on PATH) through /bin/sh with ulimit -t, env -i (no environment variables), Node --permission with read access only to runner.mjs and the exchange folder, and no network through sandbox-exec on macOS or unshare -rn on Linux where available. Elsewhere it relies on a vm context with code generation from strings off, so there is no network block there. The program reaches the host only through call, recall, saveFile, readFile, resources and readResource messages. Each nested MCP call is checked with $.tool.check. A deny rule refuses it, and an allow rule, an ask rule or an organization ceiling sends it through $.tool.call. With no matching rule and the default approval option program, it runs through $.mcp.call without its own prompt. The per-call option turns that off, and the docs disclose it, although the README feature list says every nested call gets the normal check. readFile serves only files from saveFile or files that $.tool.check allows Read for without asking. saveFile writes to ~/.claude/code-mode/files/<session id>/, and those files persist. Results Claude Code saved to tool-results are read back only from the session's own folder. Runs record tool result shapes (field names only) and argument names in ~/.claude/code-mode/shapes.json and args.json. Optional metrics, off by default, record sizes and counts. Hint and function proposals are written to pending folders under ~/.claude/code-mode (and the project's .claude/code-mode/hints only when projectHints is on). They load only after the person presses Approve in a ui.render ToolResult card or the AbovePrompt band, and a SHA-256 ledger in $.store makes files changed outside an Approve wait for approval again. Bundled hints (Datadog, Jira) load only when their hash matches hints/sha256.json. add_hint and edit_hint call $.model.classify to label the hint, which uses tokens. tool.call hooks on Write, Edit and NotebookEdit deny writes into the hint and function folders and the installed plugin folder. An optional blockDirectMcp hook, off by default, denies direct MCP calls. The plugin deletes only its own files (rm -f on proposals and hint files, rm -rf on its temp folder). register.tsx, runtime/runner.mjs, session-start.sh, functions.ts, paths.ts, tools.ts and the bundled hints were read in full. hints.ts and protocol.ts are pure helpers and were checked by targeted search: no fs, process or network calls, and the prompt texts were read. The dev-only script scripts/bundled-hints.mjs is not loaded at runtime. The MCP servers it calls were not reviewed.
- What it uses
-
- Reads your prompts: no
- Sees tool calls: yes
- Blocks or changes tool calls: yes
- Reads or writes files: yes
- Runs programs on your machine: yes
- Calls the model (uses tokens): yes
- Sends data over the network: yes
- Stores data: yes
- Shows something on screen: yes
Made this mod? Add a badge to your README
Paste this into your README. The badge says reviewed once the current version has been reviewed, and links readers to this page.
[](https://modsforclaude.com/mods/code-mode/)