Title: mcpx: WebAssembly as a sandboxed tool source — wazero, and the component model as the tool boundary · Issue #1970 · developing-today/code · GitHub
Open Graph Title: mcpx: WebAssembly as a sandboxed tool source — wazero, and the component model as the tool boundary · Issue #1970 · developing-today/code
X Title: mcpx: WebAssembly as a sandboxed tool source — wazero, and the component model as the tool boundary · Issue #1970 · developing-today/code
Description: 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/ni...
Open Graph Description: 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 referenc...
X Description: 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 refe...
Opengraph URL: https://github.com/developing-today/code/issues/1970
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mcpx: WebAssembly as a sandboxed tool source — wazero, and the component model as the tool boundary","articleBody":"Relocated from dezren39/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).\n\nParent: #173\n\n## Summary\n\nmcpx runs scripts in JavaScript runtimes and notes its own problem with that:\n\"Only Deno has a permission model to speak of; bun and node run with the\"\ncaller's full authority (`internal/runner/runner.go:43`). So the sandbox is a\nflag set on one of three runtimes, and absent on the other two.\n\nA WebAssembly module is the opposite default. It can reach *nothing* — no files,\nno network, no clock, no environment — until a host hands it an import. And\n**wazero** is a WASM runtime written in pure Go with no cgo, which means mcpx\ncould gain capability-based sandboxing without the toolchain cost that sinks\nmost such proposals in this codebase.\n\nTwo uses follow, and they are worth separating: a `.wasm` module as a **tool\nsource** (a server in a sandbox), and WASM as a **script runtime** (an untrusted\nscript that is safe by construction rather than by flag).\n\nThis is distinct from #84, which is about compiling *mcpx itself* to WASM.\n\n## Original notes\n\n> you can imagine what i might want build out your dreams\n\nArising from the same capability argument as the Roc platform proposal: the\ninteresting property is not the language, it is that the host decides what the\nguest can reach, and the type system or the module boundary enforces it.\n\n## Current state\n\n**Three JS runtimes, one of which can be restrained.**\n`runner.Detect` resolves `deno`, `bun`, `node` (`internal/runner/runner.go:73`),\nand the package comment records the asymmetry at `:43`. #293 covers configurable\npermission flag sets, which makes the Deno case better and does nothing for the\nother two.\n\n**Tool sources are processes or declarations.** An upstream MCP server is a\nspawned process or an HTTP endpoint (`internal/mcpclient/stdio.go:67`,\n`http.go`); an adapter is an `exec` of a binary\n(`internal/adapter/adapter.go:237`); an OpenAPI document is HTTP calls. Every\none of them runs with the daemon's authority or the binary's own. #83 is\ndesigning the tool-source interface that would let a fourth kind exist.\n\n**WASM appears twice on the tracker, neither as this.** #84 is \"embedding mcpx\n-- a public Go API, the C ABI, WASM, and mcpx as its own upstream\", i.e. mcpx\ncompiled *to* WASM. #156 mentions WASM for a runnable example on the docs home\npage. Nothing proposes WASM as something mcpx *runs*.\n\n**Why wazero specifically.** It is a pure-Go WASM runtime with no cgo and no\nexternal dependency, which is the property that makes this proposal cheap where\nthe iroh and Roc-platform proposals are expensive. `nix build` keeps\ncross-compiling for free and the release matrix (#158) does not grow.\n\n## Approaches\n\n### Approach A — least recommended: a WASI-preview-1 script runtime, and nothing else\n\nAdd `wasm` to the runtime list; `mcpx exec foo.wasm` runs it with WASI p1 and a\npreopened directory.\n\nCheap and nearly pointless as stated. WASI p1 gives file and stdio access and no\nnetworking, so the module cannot call a tool, which is the entire reason to run a\nscript under mcpx. Without a host import for `call`, a WASM script is a\ncalculator. Worth doing only as the substrate for B or C, never as the feature.\n\n### Approach B — middle: a `.wasm` module as a tool source\n\nA module exports `list_tools` and `call_tool`; mcpx instantiates it with wazero\nand registers it as a namespace through #83's tool-source interface.\n\nThis is the smallest shape with a real payoff. A tool source that is a single\nfile, cannot read your home directory, cannot phone home, and runs\ndeterministically — compared with today's alternative, which is spawning\nsomebody's `npx` package with your full user authority. For the \"I found an MCP\nserver on the internet\" case, that difference is the whole ballgame.\n\nIts limit is that WASM's ecosystem story for *writing* such a module is still\nrough, so in practice the author is in Rust, Go, Zig or C, and the convenience\ngap against writing a Node MCP server is large. It is a security feature people\nwill adopt only when they are already nervous.\n\n### Approach C — recommended: the component model as the tool boundary, with B as the first slice\n\nWASI preview 2 and the **component model** give typed, language-agnostic\ninterfaces defined in WIT, and `wasmtime`'s Go bindings or wazero's evolving\nsupport can host them. Define the mcpx tool-source contract *as a WIT world*:\nthe guest exports tool listing and invocation; the host imports are exactly the\ncapabilities mcpx chooses to grant — `call` another tool, `log`, `emit`,\n`artifact`, and nothing else unless declared.\n\nWhat that buys over B:\n\n- **The capability set becomes a declaration, per module.** A module's manifest\n states it needs `call` and `artifact`; the daemon grants that and no more, and\n the grant is reviewable in config. This is the same shape as the daemon\n permission model and should share its vocabulary.\n- **Any source language.** Rust, Go, C, Zig, and increasingly Python and\n JavaScript, all compile to components. A tool source stops being tied to\n whoever writes Node.\n- **The same world serves scripts.** An untrusted *script* is a component with\n the same imports, so the script-runtime and tool-source cases collapse into one\n mechanism rather than two.\n- It composes with #83's tool-source interface instead of being a fifth special\n case, and with the daemon permission model (#298) as the thing that decides which\n modules get which imports.\n\nThe honest costs: the component model tooling is young and moving; wazero's\ncomponent support is less mature than wasmtime's, and wasmtime's Go bindings\nreintroduce cgo, which would forfeit the main advantage — so **\"pure Go\" and\n\"component model\" may not both be available yet**, and that tension is the first\nthing to resolve. Start with B on wazero and core WASM, with the interface shaped\nso the component world can replace the ABI underneath.\n\n## Open questions\n\n- Can wazero host components today at an acceptable maturity, or does C require\n wasmtime and therefore cgo? This decides whether C is reachable at all, and is\n the one piece of research that gates the rest.\n- Performance: is per-call instantiation acceptable, or does a module need\n pooling like a server does? Instantiation is cheap but not free, and the pool\n already exists for processes (`internal/pool`).\n- Does a WASM tool source go in the pool? Same question #83 asks about adapters,\n which have no long-lived process either. The answers should match.\n- Distribution: a `.wasm` is content-addressable and would sit naturally in\n #187's cache. Is a module referenced by path, by URL, by hash, or by an OCI\n registry reference (the emerging convention)?\n- Does an untrusted *script* in WASM actually help, given the script is usually\n the user's own? The threat model is sharper for third-party tool sources than\n for scripts, which argues for B's framing over A's.\n- Debuggability: a panicking WASM module gives a worse diagnostic than a\n panicking process. What does `mcpx doctor` say about a module that will not\n instantiate?\n\n## Ease · Impact · Related\n\n**Ease:** M for B on wazero with core WASM; L–XL for C, with a hard research\ngate on component-model hosting in pure Go. **Impact:** medium now, high later —\nit is the only proposal on the tracker that makes \"run somebody else's tool\nsource\" safe by construction, and the cheapest of the three capability-sandbox\nideas (this, Roc's platform, a process sandbox) because it costs no new\ntoolchain.\n\n**Depends on / related:** #83 (the tool-source interface this plugs into — do\nnot add a fifth `Extra` path), #173 (parent tracker: extensibility), #84 (mcpx\n*as* WASM — the mirror image, and shares the C ABI question), #293 and\n`internal/runner/runner.go:43` (the Deno-only permission model this is an answer\nto), #175/#105/#106 (runtimes and languages, if WASM becomes a script runtime),\n#187 (content-addressed cache — a natural home for modules), #158 (distribution),\n#80/#82 (plugins — a WASM module is a strong candidate for the plugin contract,\nsince a plugin is the thing you least want running unsandboxed), #298 (a\npermission vocabulary this could reuse later — not a dependency).\n\n## Acceptance criteria\n\n- A written decision separates the two uses — `.wasm` as a tool source vs WASM as a script runtime — with a recommendation for each.\n- 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.\n- Pure-Go constraint holds: no cgo introduced into the build.\n- Existing JS-runtime script behaviour and process/HTTP tool sources are unchanged.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-28T22:50:27Z","url":"https://github.com/developing-today/code/issues/1970"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1ad78b73-8242-2a5b-176a-806d986361df |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 87B6:1E1784:7D8FA2:A64C54:6B062D8E |
| html-safe-nonce | dd345b69d0fff2f8689773e319fca113eba5dff7d401684aec435a0e7a16a17f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4N0I2OjFFMTc4NDo3RDhGQTI6QTY0QzU0OjZCMDYyRDhFIiwidmlzaXRvcl9pZCI6Ijg3NjUzMzg2Nzg3NTIzMjUwMDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0f89bafccc9d1cfa1cb2885c421da04f308ab6bb9353bc6646a1dde183f4cc96 |
| hovercard-subject-tag | issue:6088952839 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/1970/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7be66d939626094376f8f42658f9a3f47ea0eaa6f4a289f5e2f5c265917ec834/developing-today/code/issues/1970 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7be66d939626094376f8f42658f9a3f47ea0eaa6f4a289f5e2f5c265917ec834/developing-today/code/issues/1970 |
| og:image:alt | 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 referenc... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7f961de5dd5c5d4aca24d33f8b3ffb3fb8b2ef53d0a4f32f01f0a790e512f6d3 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 494ea0bb1e0feef734a83e2628697647755e8864 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width