Relocated from dezren39/darwin-nix#299 on 2026-10-28 (placement audit): mcpx's single source lives in developing-today/code (pkgs/mcpx); re-home tracked at #309. Original body below; issue references inside it are historical (dezren39/nix numbering).
Parent: #173
Summary
mcpx runs scripts in JavaScript runtimes and notes its own problem with that:
"Only Deno has a permission model to speak of; bun and node run with the"
caller's full authority (internal/runner/runner.go:43). So the sandbox is a
flag set on one of three runtimes, and absent on the other two.
A WebAssembly module is the opposite default. It can reach nothing — no files,
no network, no clock, no environment — until a host hands it an import. And
wazero is a WASM runtime written in pure Go with no cgo, which means mcpx
could gain capability-based sandboxing without the toolchain cost that sinks
most such proposals in this codebase.
Two uses follow, and they are worth separating: a .wasm module as a tool
source (a server in a sandbox), and WASM as a script runtime (an untrusted
script that is safe by construction rather than by flag).
This is distinct from #84, which is about compiling mcpx itself to WASM.
Original notes
you can imagine what i might want build out your dreams
Arising from the same capability argument as the Roc platform proposal: the
interesting property is not the language, it is that the host decides what the
guest can reach, and the type system or the module boundary enforces it.
Current state
Three JS runtimes, one of which can be restrained.
runner.Detect resolves deno, bun, node (internal/runner/runner.go:73),
and the package comment records the asymmetry at :43. #293 covers configurable
permission flag sets, which makes the Deno case better and does nothing for the
other two.
Tool sources are processes or declarations. An upstream MCP server is a
spawned process or an HTTP endpoint (internal/mcpclient/stdio.go:67,
http.go); an adapter is an exec of a binary
(internal/adapter/adapter.go:237); an OpenAPI document is HTTP calls. Every
one of them runs with the daemon's authority or the binary's own. #83 is
designing the tool-source interface that would let a fourth kind exist.
WASM appears twice on the tracker, neither as this. #84 is "embedding mcpx
-- a public Go API, the C ABI, WASM, and mcpx as its own upstream", i.e. mcpx
compiled to WASM. #156 mentions WASM for a runnable example on the docs home
page. Nothing proposes WASM as something mcpx runs.
Why wazero specifically. It is a pure-Go WASM runtime with no cgo and no
external dependency, which is the property that makes this proposal cheap where
the iroh and Roc-platform proposals are expensive. nix build keeps
cross-compiling for free and the release matrix (#158) does not grow.
Approaches
Approach A — least recommended: a WASI-preview-1 script runtime, and nothing else
Add wasm to the runtime list; mcpx exec foo.wasm runs it with WASI p1 and a
preopened directory.
Cheap and nearly pointless as stated. WASI p1 gives file and stdio access and no
networking, so the module cannot call a tool, which is the entire reason to run a
script under mcpx. Without a host import for call, a WASM script is a
calculator. Worth doing only as the substrate for B or C, never as the feature.
Approach B — middle: a .wasm module as a tool source
A module exports list_tools and call_tool; mcpx instantiates it with wazero
and registers it as a namespace through #83's tool-source interface.
This is the smallest shape with a real payoff. A tool source that is a single
file, cannot read your home directory, cannot phone home, and runs
deterministically — compared with today's alternative, which is spawning
somebody's npx package with your full user authority. For the "I found an MCP
server on the internet" case, that difference is the whole ballgame.
Its limit is that WASM's ecosystem story for writing such a module is still
rough, so in practice the author is in Rust, Go, Zig or C, and the convenience
gap against writing a Node MCP server is large. It is a security feature people
will adopt only when they are already nervous.
Approach C — recommended: the component model as the tool boundary, with B as the first slice
WASI preview 2 and the component model give typed, language-agnostic
interfaces defined in WIT, and wasmtime's Go bindings or wazero's evolving
support can host them. Define the mcpx tool-source contract as a WIT world:
the guest exports tool listing and invocation; the host imports are exactly the
capabilities mcpx chooses to grant — call another tool, log, emit,
artifact, and nothing else unless declared.
What that buys over B:
The honest costs: the component model tooling is young and moving; wazero's
component support is less mature than wasmtime's, and wasmtime's Go bindings
reintroduce cgo, which would forfeit the main advantage — so "pure Go" and
"component model" may not both be available yet, and that tension is the first
thing to resolve. Start with B on wazero and core WASM, with the interface shaped
so the component world can replace the ABI underneath.
Open questions
- Can wazero host components today at an acceptable maturity, or does C require
wasmtime and therefore cgo? This decides whether C is reachable at all, and is
the one piece of research that gates the rest.
- Performance: is per-call instantiation acceptable, or does a module need
pooling like a server does? Instantiation is cheap but not free, and the pool
already exists for processes (internal/pool).
- Does a WASM tool source go in the pool? Same question chore(deps): bump build/buck/preludes/buck2-prelude from
d956689 to 36464cf #83 asks about adapters,
which have no long-lived process either. The answers should match.
- Distribution: a
.wasm is content-addressable and would sit naturally in
Phase 4: joiner with missing pre-join control messages stalls silently #187's cache. Is a module referenced by path, by URL, by hash, or by an OCI
registry reference (the emerging convention)?
- Does an untrusted script in WASM actually help, given the script is usually
the user's own? The threat model is sharper for third-party tool sources than
for scripts, which argues for B's framing over A's.
- Debuggability: a panicking WASM module gives a worse diagnostic than a
panicking process. What does mcpx doctor say about a module that will not
instantiate?
Ease · Impact · Related
Ease: M for B on wazero with core WASM; L–XL for C, with a hard research
gate on component-model hosting in pure Go. Impact: medium now, high later —
it is the only proposal on the tracker that makes "run somebody else's tool
source" safe by construction, and the cheapest of the three capability-sandbox
ideas (this, Roc's platform, a process sandbox) because it costs no new
toolchain.
Depends on / related: #83 (the tool-source interface this plugs into — do
not add a fifth Extra path), #173 (parent tracker: extensibility), #84 (mcpx
as WASM — the mirror image, and shares the C ABI question), #293 and
internal/runner/runner.go:43 (the Deno-only permission model this is an answer
to), #175/#105/#106 (runtimes and languages, if WASM becomes a script runtime),
#187 (content-addressed cache — a natural home for modules), #158 (distribution),
#80/#82 (plugins — a WASM module is a strong candidate for the plugin contract,
since a plugin is the thing you least want running unsandboxed), #298 (a
permission vocabulary this could reuse later — not a dependency).
Acceptance criteria
- A written decision separates the two uses —
.wasm as a tool source vs WASM as a script runtime — with a recommendation for each.
- If a use proceeds: a wazero-hosted module runs with no filesystem, network, clock, or environment access except imports the host explicitly grants, demonstrated by a test module that is denied a capability it did not receive.
- Pure-Go constraint holds: no cgo introduced into the build.
- Existing JS-runtime script behaviour and process/HTTP tool sources are unchanged.