NetsuGate
OfficialThis server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
NetsuGate
NetsuGate is a code mode for MCP servers: instead of calling an app's tools one by one, an AI agent writes a short sandboxed script that calls them, and reads only the result.
The agent gets two tools. netsu_api looks up what it can call, and netsu_code runs a script:
const { files } = await nr.list_files({ limit: 1000 });
const low = files.filter((f) => f.name.startsWith("interview") && f.rating === 2);
for (const { id } of low) await nr.set_rating({ id, rating: 4 });
return low.length;That is one tool call that returns one number. With the tools alone, the agent reads the list, then makes 40 calls. In the benchmark, this task cost 0.026 to 0.028 $ in code mode and 0.081 $ with the tools.
Early version. It is not on npm: clone it, or copy its files assync.js does for NetsuRush, NetsuBoard, NetsuIcon, NetsuFont and NetsuFlow Review.
When not to use it
One call is enough. Looking up the API first costs more than it saves. The small question of the benchmark cost 0.013 $ in code mode and 0.008 $ with the tools.
The model writes poor JavaScript. Keep the tools for it. The published benchmark covers one model only.
The agent must look at each picture before it goes on. A script cannot see. It can attach up to 8 images for the model to look at afterwards.
Each action needs its own approval in the client. See the warning under what a script can do.
Related MCP server: codemodekit
Install
It needs Node.js 22 or later.
git clone https://github.com/NetsumaInfo/NetsuGate.git
cd NetsuGate
npm installPut it in front of an MCP server
The gateway is an MCP server over stdio. It connects to another MCP server, over HTTP or stdio, and offers its tools in code mode. The other server does not change.
Copy
gateway/apps.example.jstogateway/apps.local.js, which git ignores, and describe your server there. To keep that file elsewhere, setNETSUGATE_APPSto its path.Link the gateway to your agent. The last word is the name you gave the server in that file. For Claude Code, from this folder:
claude mcp add my-app-code -- node "$PWD/gateway/gateway.js" over-httpThe gateway lists its two tools even while the app is closed, and connects again after the app restarts. If a connection breaks while a call is running, it does not repeat the call: it tells the agent to check first. A token is read by connect each time the gateway connects.
Add it to your own server
src/ is CommonJS with no build step. Give createCodeMode the MCP definitions of your tools and a function that runs one:
const { createCodeMode } = require('./src');
const mode = createCodeMode({
app: 'My app',
listTools: () => definitions,
callTool: async (name, args, { script }) => run(name, args),
guide: () => 'What an agent must know to use My app.',
});callTool gives an object. { ok: false, error } is a failure, and throws in the script. script is the same for every call of one script. NetsuBoard uses it to undo all the edits of a script at once.
Then answer the MCP requests:
Request | Answer |
|
|
|
|
|
|
|
|
Create one mode per agent, because it keeps what that agent's scripts store. The other options are described in src/index.js.
The guide comes whole with the first netsu_api answer instead of in the server's instructions, which some clients cut.
For a TypeScript server built on Node's http and the MCP SDK, http/codeMode.ts is an endpoint you can copy. Put the files of src/ and http/package.json in a code folder next to the one that holds it. It keeps one mode per MCP session. The same session id still works after a restart, with an empty store. It checks nothing about who is calling: put it behind the same Host, Origin and key checks as your MCP endpoint, including any check that names an exact path.
What a script can and cannot do
Your client asks aboutnetsu_code as a whole. Allowing it allows every tool behind it, deletions included. NetsuGate does not ask for confirmation, so any check your app needs must be in callTool, or in the server behind the gateway.
A script is the body of an async function.
It calls
nr.<tool>({...}), ornr.<tool>.<action>({...})when a tool has anactionparameter with a list of values. Anetsu_prefix can be left out.Unknown tools, actions and top-level parameters are refused before they reach the app, and so are missing required ones. A refused parameter comes with the right signature. Values and nested fields are left for the app to check.
storekeeps data from one script to the next.nr.show(result)attaches the images of a result.console.logadds short notes to the answer.If a script fails, the answer lists the calls that went through. Calls waiting their turn are dropped. Those already sent are not undone.
A result over 40,000 characters is never cut. It goes into
store.last, unless the store would grow past 5 million characters.After 40 seconds, the answer gives a
runIdto follow or cancel the script. By default it can run for 10 minutes (an hour through the gateway).
Scripts run in QuickJS, compiled to WebAssembly by quickjs-emscripten. They have no files, network, timers, modules or Node API. QuickJS gets 64 MB of memory. Each script has its own worker thread, stopped when the script computes for more than 3 seconds between two tool calls, with one more second of grace. A script also cannot choose a file to attach: it gets an id for a result's images, never their paths.
This limits what a script can do to your machine, not what your tools can do. A tool that reads files can read them for a script too.
Benchmark
bench/ runs Claude Code on a made-up library of 320 files, with the tools and then in code mode. Claude Code loads the tools on demand, as it does by default. The results of the two tasks that change files are checked in the files themselves. For the question, the answer is checked too.
These are the costs reported by Claude Code 2.1.332 with Sonnet 5.5, with two runs of each. All 12 runs were right.
Task | Tools | Code mode |
Sort 240 files into 6 folders | 0.128 to 0.207 $ | 0.027 to 0.053 $ |
Change 40 files, one call each | 0.081 $ | 0.026 to 0.028 $ |
Answer a small question | 0.008 $ | 0.013 $ |
Two runs show an order of magnitude, not an average. Tokens, calls, times and limits are in bench/results.md. To run it again, you need Claude Code, signed in. It uses your quota:
node bench/run.js --runs 2Development
npm run check # types of src/
npm test
npm run sync # copies the code into the apps in the folders next to this onenode sync.js --check shows which copies are out of date without changing them. http/ is checked and tested in the apps that use it.
See CONTRIBUTING.md before opening a pull request, and AGENTS.md for the structure and rules. Report a way out of the sandbox privately, as described in SECURITY.md.
License
MIT. QuickJS and quickjs-emscripten are also under MIT. A copy in another repository follows that repository's license: for example, the copies in NetsuRush and NetsuBoard are under AGPL-3.0-only.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Governed app access for AI agents: 1,000+ apps & 12,000+ tools via Code Mode MCP.
Zero-setup MCP gateway securely connecting AI to your tools with authentication and workflows
The OpenRouter for tools. One MCP connection gives any AI agent 254 hosted tools, pay per call.
Related MCP Servers
- AlicenseAqualityBmaintenanceCode-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.27Apache 2.0
- AlicenseNot gradedqualityCmaintenanceEnables building safe, programmable Code Mode MCP servers from upstream tool sources, with model-authored TypeScript running in a sandbox and tool calls routed to trusted host-side providers.1Apache 2.0
- AlicenseAqualityBmaintenanceEnables agents to accomplish multi-step work by writing a single sandboxed JavaScript program that drives shell, filesystem, HTTP, and every tool of any configured MCP server, returning only a small summary instead of raw JSON. This collapses dozens of advertised tool schemas into one tool, cutting per-request context by roughly 26× while keeping disabled upstream servers reachable.134 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables coding agents to reach every configured MCP server through just three tools (search, describe, execute) and a sandboxed JavaScript runtime, so a model writes one short program instead of making dozens of tool calls. Runs without network, filesystem, or credential access, returning only the result.257 npm8MIT