lever
This 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.
lever
Code Mode for any MCP client. The model writes one piece of JavaScript. lever runs it with shell, file, search and MCP helpers, and only what the code returns goes back to the model.
lever is tested with Claude Code 2.1.330 (claude -p and a background session) and with Codex (codex exec). Other clients that start MCP servers over stdio use the same protocol, but they are not tested yet. lever has no dependencies and needs Node 20.11 or newer.
Why
Most of an agent's tokens go to tool output that it reads once and then ignores: a whole file to find one line, a full test log to find one failure, one search result per name. Every step is also one more model turn. With lever the model writes the steps as code. Loops, filters and counts run in Node, and the model reads only the answer.
This is a real call from the benchmark below. Claude Haiku was asked for the three longest source files and sent one run call:
const files = await glob('src/**/*.mjs');
const counts = [];
for (const f of files) {
const text = await read(f);
counts.push({ f, n: text.split('\n').length });
}
counts.sort((a, b) => b.n - a.n);
return counts.slice(0, 3).map(c => `${c.f}: ${c.n}`).join('\n');lever read 15 files (126.6 KB) and sent back 73 bytes:
src/helpers/mcp.mjs: 390
src/helpers/search.mjs: 361
src/session.mjs: 318
---
1 glob, 15 read · read 126.6 KB, returned 73 B · 180 msRelated MCP server: codemode-mcp-gateway
Measurements
In real Claude Code
node bench/live.mjs haiku 3 gives Claude Code the same four requests three ways: with only the built-in tools (Glob, Grep, Read, Edit, Write, Bash), with the built-in tools and lever (a normal install), and with only lever's run. Each request works on a fresh copy of this repository, and each answer is checked. Each row is the median of three runs. Turns, tokens, cost and time come from Claude Code's own result, and input tokens include cached ones. This run used Claude Code 2.1.330 with Claude Haiku on 2026-11-23. All 36 answers were correct.
Sum of the four tasks | Turns | Tool calls | Input tokens | Output tokens | Cost (USD) | Time (s) |
Built-in tools | 15 | 11 | 592,397 | 4,523 | 0.0310 | 44.1 |
Built-in tools + lever | 11 (−27%) | 7 (−36%) | 462,520 (−22%) | 3,239 (−28%) | 0.0282 (−9%) | 38.2 (−13%) |
lever only | 12 (−20%) | 8 (−27%) | 458,358 (−23%) | 3,098 (−32%) | 0.0283 (−9%) | 36.0 (−18%) |
Task | Way | Turns | Tool calls | Used lever | Input tokens | Output tokens | Cost (USD) | Time (s) |
Three longest source files | Built-in tools | 2 | 1 | - | 80,705 | 378 | 0.0062 | 4.0 |
Three longest source files | Built-in tools + lever | 2 | 1 | 0/3 | 82,716 | 425 | 0.0063 | 4.3 |
Three longest source files | lever only | 2 | 1 | 3/3 | 74,072 | 333 | 0.0061 | 4.4 |
Where each export of format.mjs is used | Built-in tools | 4 | 3 | - | 178,318 | 1,893 | 0.0091 | 12.8 |
Where each export of format.mjs is used | Built-in tools + lever | 3 | 2 | 3/3 | 126,329 | 1,312 | 0.0075 | 12.8 |
Where each export of format.mjs is used | lever only | 4 | 3 | 3/3 | 156,481 | 1,443 | 0.0081 | 11.1 |
Rename a function everywhere | Built-in tools | 7 | 6 | - | 250,474 | 1,873 | 0.0092 | 15.1 |
Rename a function everywhere | Built-in tools + lever | 4 | 3 | 3/3 | 168,586 | 1,097 | 0.0077 | 9.0 |
Rename a function everywhere | lever only | 4 | 3 | 3/3 | 151,309 | 813 | 0.0074 | 8.6 |
Run the tests, report only failures | Built-in tools | 2 | 1 | - | 82,900 | 379 | 0.0066 | 12.1 |
Run the tests, report only failures | Built-in tools + lever | 2 | 1 | 0/3 | 84,889 | 405 | 0.0067 | 12.1 |
Run the tests, report only failures | lever only | 2 | 1 | 3/3 | 76,496 | 509 | 0.0067 | 11.9 |
What the numbers show:
With a normal install, Haiku used lever for the two tasks that take several steps (6 of 6 runs) and one built-in call for the two tasks that take one step. That is what lever's instructions ask for.
Most input tokens are the context that Claude Code sends again on every turn, so the saving comes from fewer turns: 7 → 4 for the rename and 4 → 3 for the export count.
When one shell command can do the task, lever saves nothing. lever's own description adds about 1,000 tokens to each turn.
"lever only" also removes the six built-in tool definitions, which is about 3,300 tokens less on each turn. To run Claude Code this way, start it with
claude --disallowedTools Bash Read Edit Write Glob Grep.The wording of the instructions matters. With an earlier, vaguer version ("prefer it when a task needs three or more tool calls"), Haiku did not pick lever once in 12 runs of the normal install.
Three runs for each row is a small sample, and a row can change by one turn from run to run. Run the script with your own model and project before you rely on these numbers.
Without a model
npm run bench does four tasks both ways on copies of this repository, without a model. The built-in side makes one call for each step and counts the output that Claude Code's tools return (Read with line numbers, absolute paths). The lever side makes one run call and counts its reply. Tokens are estimated as characters ÷ 4.
Task | Tool calls | Characters the model reads | ≈ Tokens | Fewer |
Three longest source files | 16 → 1 | 152,401 → 130 | 38,100 → 33 | 99.9% |
Where each export of format.mjs is used | 14 → 1 | 14,024 → 215 | 3,506 → 54 | 98.5% |
Rename a function everywhere | 5 → 1 | 27,034 → 158 | 6,759 → 40 | 99.4% |
Run the tests, report only failures | 1 → 1 | 5,500 → 415 | 1,375 → 104 | 92.5% |
All four | 36 → 4 | 198,959 → 918 | 49,740 → 230 | 99.5% |
The rename leaves the same files both ways. This is the most that lever can save, because the built-in side here takes one call for every step. A real model often finds a shorter way with the built-in tools too (for the first task, Haiku used one find … | xargs wc -l command), so the measurement in real Claude Code above shows smaller savings.
Install
npm install -g lever-code
lever install # adds lever to Claude Code and Codex, whichever is on your PATH
lever doctor # checks the setup and runs one testlever install --claudeorlever install --codexpicks one client.--scope projectadds lever to the current project only (Claude Code).For any other MCP client, add a stdio server whose command is
lever, with no arguments.From source:
git clone https://github.com/Junhan2/lever && cd lever && node bin/lever.mjs install.To remove it:
lever uninstall.
Start a new session after installing. In Claude Code, /mcp lists lever.
What the model gets
One tool, run:
Input | Meaning |
| JavaScript. |
|
|
| Seconds before the run stops (default 600; for a background job 7200). |
The tool description is about 1.4 KB. Claude Code loads it up front (anthropic/alwaysLoad), so the first call needs no tool search. Details that the model rarely needs are behind help(topic).
Helpers inside the code
Paths are relative to the project folder.
Helper | What it does |
| Runs a shell command. Interpolated values are quoted. It throws on a non-zero exit. The result is |
| Reads a file, or a range of its lines. |
| Writes a file and creates its folders. An object is written as JSON. |
| Replaces text. Without |
| Checks a path. Lists a folder. |
| Lists files, sorted. |
| Searches with ripgrep, or with Node when ripgrep is missing. Returns |
| Puts back the files that the most recent changing run wrote. |
| An object that is kept between runs. |
| Background jobs. |
| Calls another MCP server from the code: the stdio servers in Claude Code's settings, in |
| More detail on |
Node's own modules also work (import, require), but they skip lever's checks. See Safety.
The reply
What the code logged, then the result. Strings print as they are. Objects print as
key: valuelines. Arrays of objects print one JSON object per line.After
---, a summary: the steps by kind, the bytes read and returned, and the time; failed and refused steps; changed files, with a reminder thatundo()puts them back; messages from hooks.When a reply would be longer than 8,000 characters, long strings are cut in the middle and long lists are shortened, only as much as needed. The whole text is saved to a private file, and the reply gives its path.
An error names the line of the code that threw. For the common missing-semicolon mistake it also says how to fix it.
Long runs
A run stops after 10 minutes, and a background job after 2 hours. Codex stops waiting for an MCP tool after 60 seconds, so for clients other than Claude Code, lever replies after 50 seconds and lets the run go on as a job. The model then gets the result with jobs.wait(id). If a run never gives control back, as in an endless loop, lever replaces its worker thread, ends the processes that the run started, and starts with a new state.
Safety
lever checks every step inside the code under the name of the Claude Code tool that the step stands for (Bash, Read, Write, Edit, Glob, Grep, mcp__server__tool):
Guard modules that you list. See Guard modules.
Claude Code's permission rules from your settings files. A
denyrule refuses the step. Anaskrule also refuses it, and the message tells the model to make that call with the normal tool, where you get the usual prompt. lever cannot show a prompt itself.Claude Code's
PreToolUseandPostToolUsecommand hooks, with the documented input, exit codes and JSON fields.
Checks 2 and 3 are on when lever runs under Claude Code. Set LEVER_HOOKS=on to use them with other clients too (for example Codex), or LEVER_HOOKS=off to turn them off. glob, grep and ls leave out the files that your Read deny rules cover.
lever is not a sandbox. The code runs in a Node worker thread with your user's rights. It can import('node:fs') or require('node:child_process') and skip every check above. The checks catch ordinary helper calls. They do not stop code that is written to get around them, and Bash rules match command text, as in Claude Code. Give lever the trust that you give an agent's Bash tool, and run the client in a container or virtual machine when you need isolation. Claude Code's built-in Code Mode has the same limit: its documentation says that the JavaScript and its file and MCP calls run outside the sandbox.
Guard modules
A guard module exports one function. lever calls it before each step:
export default function ({ tool, input, cwd }) {
// Return a reason (a string) to refuse the step, { note } to pass a message to the model, or null to let it run.
}examples/guards/deny-paths.mjs refuses steps that touch ~/.ssh, ~/.aws, ~/.gnupg, ~/.config/gh or .env files. Load guard modules with LEVER_GUARDS=/path/a.mjs:/path/b.mjs or with the guards list in the config file.
Compared with Claude Code's built-in Code Mode
Claude Code added an experimental Code Mode in v2.1.323 (November 2026). The facts in the left column come from its documentation, read on 2026-11-21.
Built-in Code Mode | lever | |
Where it works | Interactive terminal sessions only. Not in | Any session type in Claude Code, Codex, and other MCP clients |
Models and accounts | Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.2, through the Anthropic API only (no Bedrock, Vertex, gateways or API key helpers) | Whatever the client uses |
What it turns off | Remote Control, Claude in Chrome, computer use, some plugins and mods, OpenTelemetry export | Nothing. It is one more tool next to the normal ones |
Resuming a session | A Code Mode session resumes only with Code Mode on | No effect on sessions |
Checks for each call |
|
|
Shell sandbox | Shell commands follow Claude Code's sandbox settings | Not applied |
What you see | Each tool call, such as an edit's diff. The code is in the transcript viewer | One call with the code and the reply |
Long runs | 10 minutes. In auto and bypass modes, background code for up to 2 hours | 10 minutes. Background jobs for up to 2 hours. An early reply for clients with short tool limits |
Large output | A | Kept under 8,000 characters, with the whole text in a file and a summary line |
MCP servers from code | Claude Code's own connections | lever starts its own copy of each stdio server. HTTP servers are not reachable |
Limits
lever is not a sandbox. See Safety.
There are no permission prompts. An
askrule refuses the step.mcp.<server>starts a separate copy of a stdio server. The copy does not share the client's connection, sign-in or state, and lever cannot reach HTTP servers.In Claude Code you see one tool call for each run, not one for each step.
Settings
Environment variables come first, then ~/.config/lever/config.json (or the file that LEVER_CONFIG names), then the defaults.
Variable | Config key | Default | Meaning |
|
|
| Characters that one reply can hold before the rest goes to a file |
|
|
| Time limit of a run |
|
|
| Time limit of a background job |
|
|
| When a run that is still going becomes a job |
|
|
| Permission rules and hooks: |
|
| none | Guard modules, separated by |
|
|
| The shell for |
|
|
| Where long replies are saved |
|
|
| Which server lists |
| none | More MCP servers, in the | |
| ripgrep on | The ripgrep to use, or |
The project folder is CLAUDE_PROJECT_DIR when the client sets it. Otherwise it is the folder that the client starts lever in.
Commands
Command | What it does |
| Starts the MCP server on stdin and stdout. Clients run this |
| Runs code once in the current folder and prints the reply |
| Adds lever to Claude Code and Codex, or removes it ( |
| Checks Node, ripgrep, hooks, guard modules, MCP servers and registration, and runs one test |
Development
npm test # unit tests and stdio tests
npm run bench # the measurement without a model
node bench/live.mjs haiku 3 # the measurement in real Claude Code; it uses your Claude Code accountEarlier work
CodeAct (ICML 2024) showed that agents that act through code instead of JSON tool calls succeed more often, in fewer turns.
Armin Ronacher, Your MCP Doesn't Need 30 Tools: It Needs Code (August 2025).
Cloudflare, Code Mode: the better way to use MCP (September 2025) and
@cloudflare/codemode.Anthropic, Code execution with MCP (November 2025) and programmatic tool calling.
Claude Code's Code Mode (v2.1.323) and Codex's code mode (
features.code_mode, still under development).
lever is for local coding agents: shell, files, search and MCP in one tool that works in every client and session type, with Claude Code's own permission rules and hooks applied to each step.
License
MIT
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
A paid remote MCP for AI agent browser DevTools MCP, built to return verdicts, receipts, usage logs,
One MCP URL for web search, page reading, pay-per-result data tools and a browser agent.
Build and run AI workflows, agents, data tables and 1000+ API integrations from any MCP client.
The OpenRouter for tools. One MCP connection gives any AI agent 254 hosted tools, pay per call.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceProvides secure execution of arbitrary JavaScript code within a sandboxed QuickJS WASM environment, allowing language models or other MCP clients to safely run JavaScript code snippets without compromising the host system.5-
- AlicenseNot gradedqualityBmaintenanceExposes a single execute tool so agents can discover, inspect schemas for, and compose calls to connected upstream MCP servers by writing JavaScript that runs in a fresh sandboxed QuickJS VM. Results from combined tool calls are returned as text or JSON, keeping large tool catalogs out of the agent's context.MIT
- 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.164 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.28 npm9MIT