The full upstream README, mirrored here for reference. Install config, tool schemas, adoption signals, and an original overview live on the MCP Js listing page.
mcp-v8 is a Model Context Protocol server,
written in Rust, that lets an AI agent run JavaScript and TypeScript in a
sandboxed V8 isolate. Instead of wiring up dozens of narrow tools, you give the
agent one tool — run_js — and it writes code: looping, branching, transforming
data, and calling other tools, often with far fewer tokens than equivalent
tool-call chains.
In its default stateful mode the V8 heap is saved as a content-addressed snapshot, so an agent can build up state across many turns. Host capabilities (network, filesystem, subprocess, WebAssembly, module imports, and calls to other MCP servers) are all off by default and unlocked only by explicit OPA/Rego policies.
fetch, filesystem, subprocess, and external imports are denied until you grant them via policy.--sandbox-manifest confines the whole process with a nono capability manifest (Landlock on Linux, Seatbelt on macOS) as defense in depth beneath the policy layer.Maintainers: see Publishing to the MCP Registry for the Docker-backed registry manifest and automated release process.
Full documentation lives at https://r33drichards.github.io/mcp-js/ (built
from site-docs/) — tutorials, how-to guides, concept
explanations, and complete reference for the CLI flags,
HTTP API, and
MCP tools.
Installs to /usr/local/bin. Supported platforms: Linux x86_64/arm64 and macOS
Apple Silicon. You can also nix run github:r33drichards/mcp-js, use Docker (see
the docker-compose.*.yml stacks), or build from source.
Prefer a hosted server? Deploy on Railway — the repo's
railway.json configures the build, healthcheck, and restart policy, and
RAILWAY.md walks through the volume, variables, and one-click
template setup.
For Claude Desktop / Cursor, add to the client's mcpServers config:
Then ask the agent: "Run this JavaScript: console.log([1,2,3].map(x => x*2))".
/api/exec accepts either a JSON body or a raw-body file upload — send the
script as the request body with a non-JSON Content-Type
(curl --data-binary @script.js -H 'Content-Type: application/javascript' .../api/exec).
The run_js MCP tool can also read a script from a path on the server itself
via an optional file parameter — off by default, enabled with
--allow-run-js-file or a run_js_file
policy.
See the Quick Start tutorials and the transports guide for more.
Every flag can also live in one TOML or JSON file passed via --config (or
MCP_V8_CONFIG), including structured sections that replace the separate
WASM / MCP-server / fetch-header / policy JSON files:
Precedence is CLI flag > MCP_V8_* env var > config file > default. See the
configuration file reference.
deno_core); TypeScript types are stripped with SWC (type removal, not type checking).setTimeout/clearTimeout.console.log/info/warn/error/debug/trace, streamed to storage and readable with line- or byte-based pagination.run_js returns an execution ID; poll status and stream output; cancel running work.WebAssembly API, plus pre-loaded modules (--wasm-module) exposed as globals and advertised to clients as runjs__wasm__<name> stub tools.npm:, jsr:, and URL imports fetched at runtime (policy-gated).fetch, filesystem (fs), and subprocess access, each checked against a Rego policy per operation; plus header/OAuth injection for fetch.mcp.callTool() / mcp.listTools().instructions and the run_js description (--instructions, --run-js-description).--config file can set every flag (precedence: CLI flag > env var > config file > default).--sse-port, served by a vendored rmcp 0.1.5), with a REST sidecar and OpenAPI spec.run_js as a task (tasks/get, tasks/result, tasks/list, tasks/cancel), ideal for long-running calls. (The legacy SSE transport does not offer tasks.)These globals are available inside run_js (capability globals require a policy):
| Global | Purpose | Gated by |
|---|---|---|
console, setTimeout | Output & timers | — |
fetch(url, opts?) | HTTP requests (Fetch API) | fetch policy |
fs.* | File I/O (readFile, writeFile, …) | filesystem policy |
child_process / Deno.Command | Run subprocesses | subprocess policy |
import (npm: / jsr: / URL) | External ES modules | --allow-external-modules + modules policy |
WebAssembly, __wasm_<name> | Run/instantiate WASM | — |
mcp.callTool/listTools/servers | Call upstream MCP servers | mcp_tools policy |
See Concepts → Security policies for the policy model.
| Tool | Mode | Description |
|---|---|---|
run_js | both | Stateful: queue execution → {execution_id}. Stateless: run and return {output, error?}. |
get_execution | stateful | Poll status/result of an execution. |
get_execution_output | stateful | Read paginated console output (line or byte). |
cancel_execution | stateful | Terminate a running execution. |
list_executions | stateful | List executions and their status. |
list_sessions, list_session_snapshots | stateful | Browse named sessions and history. |
get_heap_tags, set_heap_tags, delete_heap_tags, query_heaps_by_tags | stateful | Tag and search heap snapshots. |
Full parameters: MCP tools reference.
The server natively implements the MCP tasks utility (spec 2025-11-25 /
SEP-1319) via rmcp, over both the Streamable HTTP and stdio transports. The
initialize result advertises a tasks capability, and a client may run the
task-augmentable run_js tool as a task by adding a task object to the
request params:
The client then polls tasks/get, fetches the eventual tool result with
tasks/result (which returns exactly what the call would have returned),
enumerates work with tasks/list, and stops a run with tasks/cancel. A
tools/call without a task field is unaffected.
mcp-v8 is configured entirely through CLI flags — storage backend, transport,
execution limits, policies, fetch-header injection, WASM modules, clustering, JWKS
auth, and the prompt/tool-description overrides. The complete, always-current list
is the generated CLI flags reference.
Use --mcp-config to connect to a protected Streamable HTTP MCP server with
the OAuth 2.1 authorization-code flow. This setting is JSON-only; it is not
available through the compact --mcp-server syntax.
All fields inside auth other than type are optional. Without client_id,
the server uses OAuth dynamic client registration; otherwise it uses the
provided registered client. scope is an array of requested scopes.
Protected-resource, authorization, token, and dynamic-registration endpoints require HTTPS unless they are loopback endpoints. This permits local OAuth test servers while refusing plaintext remote authorization infrastructure.
On first use, or when no usable cached credentials exist, mcp-v8 starts a
loopback callback listener and prints the authorization URL. It then attempts
to open that URL locally. For a headless host, copy the printed URL into a
browser on another machine, complete authorization, and make sure that browser
can reach the host's http://localhost:<port>/callback URL (for example,
through an SSH port forward). Authorization waits up to five minutes. A
callback with the wrong OAuth state is ignored; an authorization denial or
timeout fails the connection.
When redirect_port is omitted, the listener selects an available local port.
Set it only when an identity provider requires a registered callback port. The
callback always binds to loopback and uses the resulting
http://localhost:<port>/callback redirect URI.
Credentials are cached at token_cache, or by default at
${XDG_CACHE_HOME:-$HOME/.cache}/mcp-js/oauth-<server-name>.json (falling back
to the system temporary directory when neither cache location is available).
The cache is bound to the MCP URL, scopes, and client configuration. OAuth
credentials are resolved on each initial connection or reconnect. A valid
refresh token renews an expired access token during that resolution without
opening a browser; interactive authorization happens only when cached
credentials cannot provide a token. An established transport keeps its bearer
token until reconnect or invalidity. It does not refresh an already-established
transport proactively.
Treat the cache as a secret: it can contain refresh tokens. On Unix, mcp-v8
writes it with mode 0600 and rejects symlinks, non-regular files, files owned
by another user, and group/world-readable files. Unsafe, wrong-owner, or
symlinked cache files are never consumed. They are treated as unusable, so
reauthorization starts and successful authorization may replace the cache
securely. Do not commit, share, or edit it. To revoke local access, revoke the
grant at the authorization server and delete the configured cache file; the
next connection starts authorization again.
mcp-v8-cli)A fully-typed client for the REST API, generated from the OpenAPI spec via progenitor:
mcp-v8-client)@mcp-v8/client)A fully-typed TypeScript client, also generated from the OpenAPI spec
(openapi-typescript types + the openapi-fetch runtime). Lives in
clients/typescript.
Regenerate types after API changes with npm run generate (reads openapi.json).
The repo is a Nix flake (it wires up the prefetched V8 archive so the build stays offline-friendly):
A plain cargo build --release inside server/ also works if your toolchain can
build deno_core/V8.
setInterval is not available — use a loop with awaited setTimeout.window/document.Comparison of single-node vs 3-node cluster at various request rates.
| Topology | Target Rate | Actual Iter/s | HTTP Req/s | Exec Avg (ms) | Exec p95 (ms) | Exec p99 (ms) | Success % | Dropped | Max VUs |
|---|---|---|---|---|---|---|---|---|---|
| cluster-stateful | 100/s | 99.9 | 301.3 | 52.42 | 53.46 | 102.44 | 100% | 1 | 11 |
| cluster-stateful | 200/s | 134.5 | 3855.4 | 1359.67 | 4062.32 | 4119.07 | 100% | 3450 | 200 |
| cluster-stateless | 1000/s | 602.2 | 1609.8 | 1377.83 | 5443.24 | 8890.83 | 99.9% | 22267 | 1000 |
| cluster-stateless | 100/s | 99.9 | 299.8 | 51.49 | 52.6 | 53.34 | 100% | 0 | 10 |
| cluster-stateless | 200/s | 199.8 | 599.5 | 51.92 | 53.43 | 55.14 | 100% | 0 | 20 |
| cluster-stateless | 500/s | 499.6 | 1498.5 | 53.2 | 56.33 | 63.75 | 100% | 0 | 50 |
| single-stateful | 100/s | 51.3 | 1970.1 | 1849.35 | 2081.54 | 2103.18 | 100% | 2823 | 100 |
| single-stateful | 200/s | 46.6 | 3828.4 | 4074.71 | 4628.01 | 4673.8 | 100% | 9020 | 200 |
| single-stateless | 1000/s | 115.4 | 430.8 | 8174.65 | 13854.8 | 16506.74 | 90% | 52654 | 1000 |
| single-stateless | 100/s | 99.9 | 299.6 | 53.31 | 55.96 | 59.52 | 100% | 4 | 14 |
| single-stateless | 200/s | 198.2 | 589.1 | 68.52 | 126.81 | 337.57 | 100% | 50 | 69 |
| single-stateless | 500/s | 138.9 | 348.3 | 3460.41 | 7332.03 | 10000.8 | 99.7% | 21416 | 500 |
| Topology | Rate | P95 (ms) | |
|---|---|---|---|
| cluster-stateful | 100/s | 53.46 | ████████████ |
| cluster-stateful | 200/s | 4062.32 | ██████████████████████████ |
| cluster-stateless | 100/s | 52.6 | ████████████ |
| cluster-stateless | 200/s | 53.43 | ████████████ |
| cluster-stateless | 500/s | 56.33 | █████████████ |
| cluster-stateless | 1000/s | 5443.24 | ███████████████████████████ |
| single-stateful | 100/s | 2081.54 | ████████████████████████ |
| single-stateful | 200/s | 4628.01 | ███████████████████████████ |
| single-stateless | 100/s | 55.96 | █████████████ |
| single-stateless | 200/s | 126.81 | ███████████████ |
| single-stateless | 500/s | 7332.03 | ████████████████████████████ |
| single-stateless | 1000/s | 13854.8 | ██████████████████████████████ |
single = 1 MCP-V8 node; cluster = 3 MCP-V8 nodes with Raft