Logo vun mcp-v8

mcp-v8

Communautéit
r33drichards

MCP server that exposes a V8 JavaScript runtime as a tool for AI agents like Claude and Cursor. Supports persistent heap snapshots via S3 or local filesystem, and is ready for integration with modern AI development environments.

Editeurr33drichards
Repositorymcp-js
SproochRust
Forks
11
Stären
57
Disponibel Tools
0
Transporttypstdio
Kategorien
LizenzAGPL-3.0
Linken
  • Tools mat KI-Workflows verbannen

    mcp-v8 stellt MCP-Funktioune bereit, déi vu kompatibele KI-Clienten a KI-Agente kënne benotzt ginn.

  • 0 disponibel Tools

    Kuckt Iech déi opruffbar Aktiounen hei drënner un, mat Nimm a Beschreiwungen, wa se vum Server geliwwert ginn.

  • Konfiguratioun fir ze kopéieren

    Benotzt d'Installatiounsbeispiller, fir dëse Server an Ärem bevorzugte MCP-Client ze konfiguréieren.

  • Indicateure fir Open Source

    57 Stären an 11 Forks aus dem verlinkte Repository.

mcp-v8 — a JavaScript/TypeScript runtime for AI agents

Docs Release License: AGPL v3

Deploy on Railway

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.

Why mcp-v8

  • One tool, unbounded capability. The agent runs a program, not a fixed menu of tools.
  • Durable state. Heap snapshots persist variables and objects across calls.
  • Secure by default. fetch, filesystem, subprocess, and external imports are denied until you grant them via policy.
  • Kernel-enforced confinement. Opt-in --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.
  • Production-ready. stdio / Streamable HTTP / SSE transports, a REST sidecar, async execution with pagination, JWKS auth, and Raft-replicated clustering.

Documentation

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.

Quick start

Install

bash
# Server
curl -fsSL https://raw.githubusercontent.com/r33drichards/mcp-js/main/install.sh | sudo bash

# Optional CLI client
curl -fsSL https://raw.githubusercontent.com/r33drichards/mcp-js/main/install-cli.sh | sudo bash

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.

Connect an MCP client

bash
# Claude Code (stdio)
claude mcp add mcp-v8 -- mcp-v8 --directory-path /tmp/mcp-v8-heaps   # stateful
claude mcp add mcp-v8 -- mcp-v8 --stateless                          # stateless

For Claude Desktop / Cursor, add to the client's mcpServers config:

json
{ "mcpServers": { "js": { "command": "mcp-v8", "args": ["--stateless"] } } }

Then ask the agent: "Run this JavaScript: console.log([1,2,3].map(x => x*2))".

Run over HTTP

bash
mcp-v8 --stateless --http-port 8080
# MCP endpoint: POST http://localhost:8080/mcp
# REST sidecar: POST http://localhost:8080/api/exec  (JSON body, or a raw-body file upload)

/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.

Configure with a single file

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:

toml
# server.toml — run with: mcp-v8 --config server.toml
http_port = 8080
heap_store = "dir"
heap_dir = "/var/lib/mcp-v8/heaps"

[policies.fetch]
policies = [{ url = "file:///etc/mcp-v8/fetch.rego" }]

Precedence is CLI flag > MCP_V8_* env var > config file > default. See the configuration file reference.

Features

  • JavaScript & TypeScript in an isolated V8 engine (via deno_core); TypeScript types are stripped with SWC (type removal, not type checking).
  • Async/await & timers — Promises and the event loop, plus setTimeout/clearTimeout.
  • Console capture — console.log/info/warn/error/debug/trace, streamed to storage and readable with line- or byte-based pagination.
  • Async execution model — run_js returns an execution ID; poll status and stream output; cancel running work.
  • Content-addressed heap snapshots — persist/restore V8 state across calls (local FS, S3, or S3 + write-through cache), or run stateless.
  • WebAssembly — the standard WebAssembly API, plus pre-loaded modules (--wasm-module) exposed as globals and advertised to clients as runjs__wasm__<name> stub tools.
  • ES module imports — optional npm:, jsr:, and URL imports fetched at runtime (policy-gated).
  • Policy-gated capabilities — fetch, filesystem (fs), and subprocess access, each checked against a Rego policy per operation; plus header/OAuth injection for fetch.
  • Compose other MCP servers — connect upstream MCP servers and call them from JS via mcp.callTool() / mcp.listTools().
  • Customizable surface — override the server instructions and the run_js description (--instructions, --run-js-description).
  • Single-file configuration — one TOML/JSON --config file can set every flag (precedence: CLI flag > env var > config file > default).
  • Auth & clustering — JWKS-based JWT verification, and optional Raft clustering with replicated session metadata and horizontal scaling.
  • Multiple transports — stdio, Streamable HTTP (MCP 2025-03-26+), and a legacy HTTP+SSE transport (--sse-port, served by a vendored rmcp 0.1.5), with a REST sidecar and OpenAPI spec.
  • Tasks — native MCP tasks (SEP-1319) over Streamable HTTP / stdio: task-enabled clients can run 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.)

What the agent's code can do

These globals are available inside run_js (capability globals require a policy):

GlobalPurposeGated by
console, setTimeoutOutput & timers—
fetch(url, opts?)HTTP requests (Fetch API)fetch policy
fs.*File I/O (readFile, writeFile, …)filesystem policy
child_process / Deno.CommandRun subprocessessubprocess policy
import (npm: / jsr: / URL)External ES modules--allow-external-modules + modules policy
WebAssembly, __wasm_<name>Run/instantiate WASM—
mcp.callTool/listTools/serversCall upstream MCP serversmcp_tools policy

See Concepts → Security policies for the policy model.

MCP tools

ToolModeDescription
run_jsbothStateful: queue execution → {execution_id}. Stateless: run and return {output, error?}.
get_executionstatefulPoll status/result of an execution.
get_execution_outputstatefulRead paginated console output (line or byte).
cancel_executionstatefulTerminate a running execution.
list_executionsstatefulList executions and their status.
list_sessions, list_session_snapshotsstatefulBrowse named sessions and history.
get_heap_tags, set_heap_tags, delete_heap_tags, query_heaps_by_tagsstatefulTag and search heap snapshots.

Full parameters: MCP tools reference.

Long-running calls as tasks

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:

jsonc
// → returns immediately with a task instead of blocking
{ "method": "tools/call",
  "params": { "name": "run_js", "arguments": { "code": "…" }, "task": { "ttl": 300000 } } }

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.

Configuration

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.

bash
mcp-v8 --help            # all flags
mcp-v8 --print-openapi   # print the REST OpenAPI spec

Browser OAuth for upstream MCP servers

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.

json
[
  {
    "name": "protected",
    "transport": "http",
    "url": "https://mcp.example.com/mcp",
    "auth": {
      "type": "oauth_browser",
      "scope": ["tools.read", "tools.call"],
      "client_id": "optional-registered-client-id",
      "client_secret": "optional-client-secret",
      "redirect_port": 48123,
      "token_cache": "/home/alice/.cache/mcp-js/oauth-protected.json"
    }
  }
]

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.

CLI client (mcp-v8-cli)

A fully-typed client for the REST API, generated from the OpenAPI spec via progenitor:

bash
mcp-v8 --stateless --http-port 3000 &
mcp-v8-cli exec "console.log('hello'); 1 + 1"
mcp-v8-cli exec --file ./script.js                # run a local file (uploaded as the code)
mcp-v8-cli executions get <execution_id>
mcp-v8-cli executions output <execution_id>
export MCP_V8_URL=https://my-server.example.com   # point at a remote server

Rust client (mcp-v8-client)

toml
[dependencies]
mcp-v8-client = { git = "https://github.com/r33drichards/mcp-js" }
rust
use mcp_v8_client::Client;
let client = Client::new("http://localhost:3000");
let body = mcp_v8_client::types::ExecRequest {
    code: "1 + 1".to_string(),
    heap: None, session: None,
    heap_memory_max_mb: None, execution_timeout_secs: None, tags: None,
};
let resp = client.exec_handler(&body).await?;
println!("execution_id: {}", resp.into_inner().execution_id);

TypeScript 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.

ts
import { createMcpV8Client } from "@mcp-v8/client";

const client = createMcpV8Client("http://localhost:3000");
const { status, output, heap } = await client.runJs("console.log('hi'); 1 + 1");

Regenerate types after API changes with npm run generate (reads openapi.json).

Build from source

The repo is a Nix flake (it wires up the prefetched V8 archive so the build stays offline-friendly):

bash
nix build github:r33drichards/mcp-js   # → ./result/bin/server
# or for development:
nix develop      # then: cargo build -p server

A plain cargo build --release inside server/ also works if your toolchain can build deno_core/V8.

Limitations

  • setInterval is not available — use a loop with awaited setTimeout.
  • No DOM or browser APIs — there is no window/document.
  • TypeScript is type-stripped, not type-checked — invalid types are removed, not reported. JSX/TSX is not supported (it parses to a clear error).

License

GNU AGPL-3.0.

MCP-V8 Load Test Benchmark Report v0.18.1

Comparison of single-node vs 3-node cluster at various request rates.

Results

TopologyTarget RateActual Iter/sHTTP Req/sExec Avg (ms)Exec p95 (ms)Exec p99 (ms)Success %DroppedMax VUs
cluster-stateful100/s99.9301.352.4253.46102.44100%111
cluster-stateful200/s134.53855.41359.674062.324119.07100%3450200
cluster-stateless1000/s602.21609.81377.835443.248890.8399.9%222671000
cluster-stateless100/s99.9299.851.4952.653.34100%010
cluster-stateless200/s199.8599.551.9253.4355.14100%020
cluster-stateless500/s499.61498.553.256.3363.75100%050
single-stateful100/s51.31970.11849.352081.542103.18100%2823100
single-stateful200/s46.63828.44074.714628.014673.8100%9020200
single-stateless1000/s115.4430.88174.6513854.816506.7490%526541000
single-stateless100/s99.9299.653.3155.9659.52100%414
single-stateless200/s198.2589.168.52126.81337.57100%5069
single-stateless500/s138.9348.33460.417332.0310000.899.7%21416500

P95 Latency

TopologyRateP95 (ms)
cluster-stateful100/s53.46████████████
cluster-stateful200/s4062.32██████████████████████████
cluster-stateless100/s52.6████████████
cluster-stateless200/s53.43████████████
cluster-stateless500/s56.33█████████████
cluster-stateless1000/s5443.24███████████████████████████
single-stateful100/s2081.54████████████████████████
single-stateful200/s4628.01███████████████████████████
single-stateless100/s55.96█████████████
single-stateless200/s126.81███████████████
single-stateless500/s7332.03████████████████████████████
single-stateless1000/s13854.8██████████████████████████████

Notes

  • Target Rate: The configured constant-arrival-rate (requests/second k6 attempts)
  • Actual Iter/s: Achieved iterations per second (each iteration = 1 POST /api/exec)
  • HTTP Req/s: Total HTTP requests per second (1 per iteration)
  • Dropped: Iterations k6 couldn't schedule because VUs were exhausted (indicates server saturation)
  • Topology: single = 1 MCP-V8 node; cluster = 3 MCP-V8 nodes with Raft

Installatioun

TypingMind
Viraussetzungen:

Node.js 18+

{
  "mcpServers": {
    "r33drichards-mcp-js": {
      "command": "",
      "args": []
    }
  }
}

mcp-v8 MCP mat verschiddene KI-Modeller benotzen

TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Soubal mcp-v8 verbonnen ass, kënnt Dir et mat verschiddene KI-Modeller an TypingMind benotzen, amplaz et fir all Modell separat anzeriichten. Dës MCP-Integratioun leeft lokal iwwer den TypingMind-MCP-Connector op Ärem Apparat.

Ariichtungsuleedung fir de lokale Connector ze benotzen

Benotzt dës Optioun, wann den MCP-Server Zougrëff op lokal Fichieren, Appen oder privat Ressourcen op Ärem Computer brauch.

1

D'MCP-Astellungen opmaachen

Gitt an TypingMind op „Astellungen“, „Erweidert Astellungen“, dann op „Model Context Protocol“ a wielt „Connector ariichten“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Klickt op d'Astellungssymbol.
  3. Gitt op „Erweidert Astellungen“.
  4. Maacht d'Sektioun „Model Context Protocol“ op.
  5. Klickt op „Connector ariichten“ a wielt „Dësen Apparat“.
Ariichtungsbildschierm vum TypingMind-MCP-Connector mat „Dësen Apparat“ ausgewielt
2

De Connector-Befeel ausféieren

Wielt „Dësen Apparat“, kopéiert de Befeel aus TypingMind a féiert en am Terminal aus. Loosst de Prozess lafen, wärend Dir MCP benotzt.

  1. Kopéiert den Ariichtungsbefeel, deen TypingMind uweist.
  2. Maacht Terminal op macOS oder Windows Terminal op Windows op.
  3. Pescht de Befeel an a féiert en aus.
  4. Bestätegt d'Installatioun vum Package, wann den Terminal Iech freet, ob Dir weiderfuere wëllt.
  5. Loosst den Terminal an de Prozess doranner lafen, wärend Dir MCP-Tools benotzt.
3

mcp-v8 als Server derbäisetzen

Wann de Connector-Status „Prett“ ass, klickt op „Serveren änneren“ a pescht d'MCP-Serverkonfiguratioun an.

  1. Waart, bis de Connector-Status „Prett“ weist.
  2. Klickt op „Serveren änneren“.
  3. Pescht d'MCP-Serverkonfiguratioun vu mcp-v8 an.
  4. Späichert d'Serverlëscht.
  5. Aktualiséiert, wann Dir kontrolléiere wëllt, ob de Connector nach ëmmer prett ass.
MCP-Astellunge vun TypingMind mat aktivem Server an dem Knäppchen „Serveren änneren“
{
  "mcpServers": {
    "r33drichards-mcp-js": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-js"
      ]
    }
  }
}
4

D'Verbindung mat verschiddene Modeller benotzen

Späichert d'Serverlëscht, maacht „Plugins“ op an aktivéiert d'MCP-Tools vu mcp-v8. Wielt dann e belibegen ënnerstëtzte KI-Modell an TypingMind a benotzt d'Tools am Chat oder weist se engem KI-Agent zou.

  1. Maacht d'Säit „Plugins“ an TypingMind op.
  2. Aktivéiert d'MCP-Tools vu mcp-v8.
  3. Start e Chat a wielt de KI-Modell, deen Dir benotze wëllt.
  4. Benotzt d'MCP-Tools am Chat oder weist se engem KI-Agent zou.
  5. Wiesselt bei Bedarf op en anere KI-Modell, ouni MCP nei ze verbannen.
TypingMind-Chat mat aktivéierte MCP-Tools an engem ausgewielte KI-Modell
Hëlleft Dir mir bei dëser Aufgab mat mcp-v8?
mcp-v8
Jo. Ech hunn et gelies.
Dat hunn ech mat mcp-v8 fonnt.

Heefeg gestallte Froen

Fir wat gëtt de MCP-Server mcp-v8 benotzt?

mcp-v8 ass e MCP-Server, deen et kompatibele KI-Clienten erlaabt, sech mat externen Tools a Kontext ze verbannen. An TypingMind kënnt Dir dëse MCP-Server eemol derbäisetzen a seng Tools an Ärem KI-Aarbechtsberäich zur Verfügung stellen.

Kann ech mcp-v8 MCP mat méi KI-Modeller an TypingMind benotzen?

Jo. TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Sou kënnt Dir mcp-v8 mat verschiddene KI-Modeller wéi Claude, ChatGPT, Gemini oder anere Modeller benotzen, déi Dir an TypingMind konfiguréiert hutt, ouni de MCP-Server fir all Modell separat anzeriichten.

Firwat mcp-v8 MCP mat TypingMind benotzen?

TypingMind ass eng vun de beschte Benotzeruewerfläche fir LLM-Chat, well et méi KI-Modeller, Prompts, Plugins, KI-Agenten, API-Schlësselen a MCP-Tools an engem Aarbechtsberäich zesummebréngt. Wann mcp-v8 verbonnen ass, kënnt Dir seng MCP-Tools mat Äre bevorzugte Modeller benotzen a gläichzäiteg Är Chataarbecht an TypingMind organiséieren.

Wéi verbannen ech mcp-v8 MCP mat TypingMind?

mcp-v8 leeft iwwer de lokale MCP-Connector vun TypingMind. Dat eegent sech am beschten, wann de MCP-Server Zougrëff op lokal Fichieren, Desktop-Apps, Kommandozeilen-Tools oder privat Ressourcen op Ärem Computer brauch.

Wéi eng Tools stellt mcp-v8 MCP an TypingMind zur Verfügung?

mcp-v8 stellt MCP-Funktiounen zur Verfügung, déi Dir op der Plugins-Säit vun TypingMind aktivéiere kënnt, fir se am Chat ze benotzen oder KI-Agenten zouzeweisen.

Muss ech meng API-Schlëssele mat TypingMind deelen, fir mcp-v8 MCP ze benotzen?

Nee. TypingMind setzt op lokal Veraarbechtung a léisst Iech d'Kontroll iwwer Är Modellubidder, API-Schlësselen, Prompts a MCP-Konfiguratioun. Wann mcp-v8 eng Authentifizéierung verlaangt, setzt déi néideg Headeren, OAuth-Astellungen oder lokal Konfiguratioun fir dee MCP-Server derbäi, wann Dir d'Verbindung erstallt.

Änlech MCP-Serveren

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇