
mcp-v8
io.github.r33drichards由 GitHub 帳號 r33drichards 發布v0.22.0更新於 Oct 30, 2026
Run JavaScript and TypeScript in sandboxed V8 isolates with policy-controlled host capabilities.
概覽
一個沙箱化的 V8 JavaScript/TypeScript 執行環境,讓助理撰寫並執行程式碼,主機能力僅在策略授權後開放。
- 可以做什麼
- 在隔離的 V8 環境中執行 JavaScript 或 TypeScript,支援有狀態與無狀態模式
- 輪詢、列出、分頁讀取主控台輸出並取消執行工作
- 瀏覽工作階段與堆積快照,並為快照加上標籤或依標籤查詢
- 使用 console、計時器、WebAssembly,以及在策略允許下的 fetch、檔案系統、子程序、模組匯入和呼叫其他 MCP 伺服器
- 適用情境
- 適合需要助理用程式碼完成運算、資料轉換或迴圈處理,而不是串接大量窄工具呼叫的情境,也適合希望以明確策略約束這些程式碼的情況。有狀態模式適合跨多輪累積變數的工作。
- 執行需求
- 以本機 stdio 程序執行,通常使用已發布的 Docker 映像,或在 Linux x86_64/arm64、macOS Apple Silicon 上原生安裝。未宣告需要帳號、金鑰或環境變數;透過命令列參數、TOML/JSON 設定檔或 MCP_V8_* 變數設定。可選的 HTTP 傳輸、S3 堆積儲存、JWKS 驗證和上游 MCP 伺服器需要額外設定。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 mcp-v8,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
mcp-v8 — a JavaScript/TypeScript runtime for AI agents
[Docs] [Release] [License: AGPL v3] [Discord]
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-manifestconfines 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.
Community
Join the mcp-js Discord community for questions, examples, and project discussion.
Quick start
Install
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
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))".
Run over HTTP
/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:
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_jsreturns 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
WebAssemblyAPI, plus pre-loaded modules (--wasm-module) exposed as globals and advertised to clients asrunjs__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 forfetch. - Compose other MCP servers — connect upstream MCP servers and call them from JS via
mcp.callTool()/mcp.listTools(). - Customizable surface — override the server
instructionsand therun_jsdescription (--instructions,--run-js-description). - Single-file configuration — one TOML/JSON
--configfile 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 — the native MCP tasks extension (
io.modelcontextprotocol/tasks, SEP-2663) over Streamable HTTP / stdio: clients that declare the extension runrun_jsas a task (tasks/get,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):
See Concepts → Security policies for the policy model.
MCP tools
Full parameters: MCP tools reference.
Long-running calls as tasks
The server natively implements the MCP tasks extension
(io.modelcontextprotocol/tasks, SEP-2663) via rmcp, over both the Streamable
HTTP and stdio transports. The initialize result advertises the extension
under capabilities.extensions, and a client that declares the same extension
in its own capabilities gets task execution for run_js:
The client then polls tasks/get (a completed task carries the tool result
inline, exactly what the call would have returned) and stops a run with
tasks/cancel. Clients that do not declare the extension get a synchronous
result, 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.
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.
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:
Rust client (mcp-v8-client)
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.
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):
A plain cargo build --release inside server/ also works if your toolchain can
build deno_core/V8.
Limitations
setIntervalis not available — use a loop with awaitedsetTimeout.- 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
MCP-V8 Load Test Benchmark Report v0.18.1
Comparison of single-node vs 3-node cluster at various request rates.
Results
P95 Latency
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
Dynamic HTTP handlers can be registered without restart. See HTTP functions for opt-in setup, conditional updates, authentication, and the request/response contract.
Scheduler and HTTP documentation
The Diátaxis documentation map links guided tutorials, operational how-to guides, reference, and explanations for the experimental scheduler and dynamic HTTP functions. It records the #284 hardening integrated through #287, #293, and #295, without implying a main merge or deployment.
Optional DynamoDB metadata backend
Use --dynamodb-table TABLE --dynamodb-namespace NAME for shared session history,
heap tags, and filesystem label/reflog metadata. Sled remains the default;
snapshot content stays in the independently selected S3/directory backend. See
metadata backends and integration tests for table
schema, IAM, limits, and LocalStack/Testcontainers setup.
來源:README.md,提交 2a8a88a
工具
0版本歷史
5- v0.22.0最新Oct 9, 2026
- v0.21.0-rc.5Oct 4, 2026
- v0.21.0-rc.4Oct 3, 2026
- v0.21.0-rc.3Oct 1, 2026
- v0.21.0-rc.2Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分