erlang_wasm_tools: design

View Source

This page is the design of erlang_wasm_tools, the repository of the wasm_tools application: a library that lets an Erlang or Elixir application load a WebAssembly component, call its exports with native values, and optionally expose them as MCP tools through barrel_mcp. Read it before you change the architecture or the public API, or to know why a choice was made. It was written before any code, on 2026-11-29, and approved as the plan for the first release; it now holds the decisions and their reasons. What erlang_wasm and barrel_mcp offered on that date, and the phased plan that built 0.1.0, are kept as written in the 2026-11-29 proposal. Where the code later departs from this page, the code and its guides win, and this page should be updated.

Sources: erlang_wasm 0.14.0 (main at f47af10), barrel_mcp 4.8.1 (main at 1eec6e3), microsoft/wassette 85048c4 (v0.8.1), Extism manifest docs (extism 1.21), hex.pm API. The first draft was reviewed adversarially and its objections are folded in (holder processes, map-only arguments, MCP name shadowing, a separate HTTP grant, guest docs off for MCP, cuts for 0.1).

Decisions taken by the maintainer:

  • Tool names are joined with _ (calculator_ops_add).
  • Observability: an observer callback plus per-registry counters. No new dependency.
  • erlang_wasm changes land first (released in 0.15.0); wasm_tools 0.1 requires 0.15.1, which also fixes the component linker for components that embed an interpreter.

1. Starting point

What erlang_wasm 0.14.0 and barrel_mcp 4.8.1 offered on 2026-11-29, verified in their source, is in the proposal as written. Section 10 lists the gaps wasm_tools needed closed; erlang_wasm 0.15.0 and barrel_mcp 4.9.0 closed them.

2. Comparison

  • Wassette v0.8.1 (Rust, Wasmtime). We copy: one tool per exported function, a new instance per call, deny by default, output as {"result": ...}, variants as {"tag", "val"}. We change what its own issues call wrong: memory limit only (no fuel, no timeout, #173), a WIT err returned as success (#908), integers without ranges, collisions that fail at call time, management tools on by default, no authentication, guest docs used as descriptions unchecked.
  • Extism 1.x: a core module with its own guest ABI (bytes in, bytes out) and a manifest (allowed_hosts with wildcards, allowed_paths, memory.max_pages, timeout_ms, config). We take the experience (one call to load, one to call, a host-name allow-list, no manifest needed) and leave the ABI: a standard component needs no guest SDK.
  • Bytecode Alliance wasm-tools: a CLI to inspect, compose and validate. Used in tests and docs, never a dependency. Docs say "the wasm-tools CLI" to keep it apart from the wasm_tools application.

3. Architecture

Erlang / Elixir code            MCP clients
        |                           |
        |                       barrel_mcp
        |                           |
        |                    wasm_tools_mcp   (adapter, no process of its own)
        |                           |
        +-------- wasm_tools -------+         (load, call, registry, policy, JSON)
                      |
                 erlang_wasm                  (decode, describe, check, WASI, limits)
  • wasm_tools is a library application: no mod, no supervisor, nothing at boot. Processes exist only where something must be owned or killed: one holder per loaded component, a registry you start, and a runner plus a watchdog per call.
  • WebAssembly work stays in erlang_wasm (decode, describe, argument checks, WASI, limits). wasm_tools owns naming, lifecycle, policy, JSON and MCP mapping.
  • MCP is one consumer of the same call path; the native API knows nothing about it.

Main decisions:

  1. A loaded component is a value with an owner. load/1,2 returns an opaque term (prepared component, interface, policy) and starts a small holder process that keeps the core modules resident (hold/1), compiled at load and outside any call deadline. The holder belongs to the calling process (or owner), like an ETS table: it stops on unload/1 or when the owner exits, and a call to an unloaded component returns kind := unloaded. Any process may call it. A registry that adds it starts its own holder, so the registry does not depend on the loader's lifetime.
  2. A fresh instance per call, in a runner you can kill. The caller spawns the runner (monitored, max_heap_size with kill, reply through an alias). The runner first spawns a watchdog that monitors the caller, the runner and the registry, and kills the runner at the deadline or when one of them dies. A late reply after a cancel or timeout is dropped by the alias; a runner crash never sends an exit signal to the caller. The runner traps exits, so a helper process linked to it (an HTTP connection that the server closed, see E7) cannot kill the call; the deadline and a cancel use kill, which no process can trap. MCP's JSON conversion runs in the MCP handler, whose input barrel_mcp has already bounded; what the guest returns is bounded by the runner's heap limit before it is converted.
  3. Registries are optional gen_servers you supervise. They hold named tools, their holders, admission (max_concurrency) and counters. No global or default registry.
  4. Types come from the component. The application never writes descriptors for a component, and host interfaces take their types from its import declarations.
  5. One error shape: maps #{class, kind, msg, ctx} as wasm_error uses, with erlang_wasm's bare tuples normalized.
classkindsmeaning
invalidnot_a_component, malformed, too_large, unsupported_type, name_conflictthe component cannot be used as asked
linkmissing_import, unknown_tool, unloadedsomething it needs is absent
argumentbad_argument with path, expected, valuethe input does not fit the type
traperlang_wasm trap kinds, host_errorthe guest or a host function failed
exhaustionout_of_fuel, memory_limit, heap_limit, host_call_limit, call_stack_exhausted, result_too_largea limit was reached
timeout, cancelled, overloadeddeadline; cancel, caller_down, registry_down; max_concurrencylifecycle

4. Public API

%% Inspect without running guest code
{ok, Info} = wasm_tools:inspect({file, "calculator.wasm"}).
%% #{digest => <<"sha256:...">>, size => 41234,
%%   exports => [#{name => <<"add">>, export => <<"add">>,
%%                 params => [{<<"a">>, s32}, {<<"b">>, s32}], result => s32,
%%                 callable => true}],
%%   imports => [#{interface => <<"wasi:cli/environment@0.2.6">>, provider => wasi}]}

%% One component, no registry
{ok, Calc} = wasm_tools:load({file, "calculator.wasm"}),
{ok, 42} = wasm_tools:call(Calc, <<"add">>, #{<<"a">> => 20, <<"b">> => 22}),
{error, #{class := argument, ctx := #{path := [<<"a">>]}}} =
    wasm_tools:call(Calc, <<"add">>, #{<<"a">> => 1 bsl 40, <<"b">> => 1}),
{ok, Def} = wasm_tools:describe(Calc, <<"add">>),
{ok, #{input := In, output := Out}} = wasm_tools:schema(Calc, <<"add">>),
ok = wasm_tools:unload(Calc).

%% Deadline and cancel
{ok, Job} = wasm_tools:start_call(Calc, <<"add">>, Args, #{timeout => 500}),
{ok, 3} = wasm_tools:await(Job, 1000),
{ok, Slow} = wasm_tools:start_call(Calc, <<"add">>, Args, #{}),
ok = wasm_tools:cancel(Slow).   %% returns once the runner is gone; nothing to await

%% Many components: a registry in your supervision tree
{ok, Reg} = wasm_tools:start_link(#{max_concurrency => 64, observer => Fun}),
{ok, [<<"calculator_add">>, <<"calculator_multiply">>]} =
    wasm_tools:add(Reg, Calc, #{namespace => <<"calculator">>}),
{ok, Defs} = wasm_tools:list(Reg),
{ok, 42} = wasm_tools:call(Reg, <<"calculator_add">>, #{<<"a">> => 20, <<"b">> => 22}),
#{active := 0, calls := 1} = wasm_tools:stats(Reg),
ok = wasm_tools:remove(Reg, [<<"calculator_add">>, <<"calculator_multiply">>]).

%% Capabilities and limits: nothing is granted unless named
{ok, Http} = wasm_tools:load({file, "http-client.wasm"}, #{
    capabilities => #{http => [<<"api.example.com">>],
                      filesystem => [{<<"/data">>, "/srv/data", read_only}],
                      env => [{<<"API_KEY">>, Key}]},
    limits => #{timeout => 5000, fuel => 50000000, max_memory_pages => 512}}).

%% An application host interface: a module with handle/3, types from the component
-module(my_kv_host).
-behaviour(wasm_tools_host).
handle(<<"get">>, [Key], #{context := #{tenant := T}}) -> my_store:get(T, Key).

{ok, App} = wasm_tools:load({file, "app.wasm"}, #{host => #{<<"example:app/kv">> => my_kv_host}}),
{ok, V} = wasm_tools:call(App, <<"run">>, #{<<"input">> => <<"x">>},
                          #{context => #{tenant => <<"acme">>}}).

%% MCP: explicit, owned by the registry, same execution path
{ok, Exposed} = wasm_tools_mcp:register(Reg, #{tools => [<<"calculator_add">>]}),
ok = wasm_tools_mcp:unregister(Exposed).

Functions in wasm_tools: inspect/1, load/1,2, unload/1, call/3,4, start_call/4, await/2, cancel/1, describe/2, schema/2, list/1, check/3, start_link/1, child_spec/1, add/3, remove/2,3, stats/1, and authorize/2, what a component's http grant decides for a request (made public on 2026-11-30, so the security guide names no internal module). JSON conversion is in wasm_tools_json (args/2, value/2, schema/1), so the native path never touches JSON. Host handlers implement wasm_tools_host (handle(Func :: binary(), Args, Ctx)) or are a fun of the same arity; Ctx carries context, tool and deadline. WIT names never become atoms.

Changed from the original brief:

  • load(Registry, Source, Opts) becomes load then add: one component can go into several registries, each with its own namespace and selection (exports on add).
  • No {loader, ...} source: an application loader is any code returning bytes, passed as {binary, Bin} with an optional sha256 check.
  • Arguments are a map keyed by parameter name. A positional list is ambiguous for f(xs: list<u32>), so it is not accepted.
  • Limits keep erlang_wasm's names (timeout, fuel, max_memory_pages) and pass wasm_limits:validate/1. Per-call options are clamped with min, never raised; timeout => infinity needs explicit trusted limits.
  • A function returning result<T, E> returns {ok, {error, E}} natively, as erlang_wasm does. MCP maps the err to isError: true.

5. Naming, types and JSON

Naming depends only on the export:

  • a world export add is add; an interface export example:calc/ops@1.0.0#add is ops_add (interface local name, _, function; package and version dropped);
  • a registry namespace prefixes it: calculator_add, calculator_ops_add;
  • exports whose names collide (two ops interfaces, two versions) get no name: load still succeeds, a native call reaches them by their full export name, and a registry or MCP names them among the exports selected with exports on add, where a name that still collides, or is already in the registry, refuses the add with kind := name_conflict. No silent suffix, no overwrite;
  • names must match ^[A-Za-z0-9_-]{1,64}$, which every LLM provider accepts;
  • not callable in 0.1: resource constructors, methods and statics (a handle dies with the per-call instance), async functions, and signatures with own, borrow, stream, future or error-context. inspect lists them with callable => {false, Reason}, and load keeps them listed rather than refusing the component.

JSON mapping (wasm_tools_json, JSON Schema 2020-12):

WITJSON Schemavalue
boolbooleantrue
s8 to s32, u8 to u32integer with minimum, maximum42
s64, u64anyOf integer in range, or decimal stringnumber when within 2^53-1, else string
f32, f64numberNaN and infinities refused at the JSON boundary
charstring, one code point"a"
stringstring
list<u8>string, contentEncoding: base64"aGk="
list<T>array
recordobject, required = non-option fields, additionalProperties: falseevery field written, none as null
tuplearray, prefixItems, fixed length
variantoneOf {"tag": const, "val": T}{"tag": "circle", "val": 2.0}
enumstring with enum
flagsarray of enum strings, uniqueItems
option<T>anyOf [T, null]; option<option<T>> refused
nested result<T, E>oneOf {"ok": T}, {"error": E}
function result result<T, E>output schema of T; err is a tool error
resources, stream, future, error-contextrefused

MCP structured output is always {"result": V}, since MCP requires an object.

6. Execution model and lifecycle

  • Inspect and load decode untrusted bytes in a bounded process (heap limit and timeout) with a size cap and optional sha256. Load then prepares, describes (E1), resolves imports against WASI and the given host interfaces (a missing one fails the load, not the first call) and starts the holder.
  • Call: argument check (E2), runner and watchdog as in decision 2, instantiate with the WASI imports and host wrappers built from the policy and the call context, call, destroy, reply. The watchdog tells the caller why a runner died (deadline, heap limit, owner gone).
  • Cost: two spawns (a few microseconds) on top of instantiate and call (a WASI 0.2 component cold run is about 810 us today). The benchmarks measure it against direct erlang_wasm use; pooling or snapshots only if the numbers ask for it.
  • Admission: a registry call checks out the tool from the registry process (one message), which counts active calls against max_concurrency and refuses with class := overloaded; the slot is released when the runner ends or its caller dies. No queue in 0.1: refusal is the backpressure. A bounded queue comes if measurements or users need it. A direct component leaves concurrency to the caller.
  • State isolation: every call has its own instance; nothing is shared between calls.
  • Remove during execution: remove/2 unregisters the MCP tools, drops the names and stops the holders, so no new call starts; calls in flight keep their own claims and finish within their deadline. remove/3 with #{kill => true} kills them.
  • Shutdown: when a registry stops, its watchdogs kill their runners, and barrel_mcp drops the tools it owned (B1).

7. Security and capabilities

  • Defaults are wasm_limits:untrusted/0 (fuel 10M, timeout 1000 ms, 16 MiB, depth 256, 10k host calls). Finite fuel keeps the interpreter; the compiled tier comes later with the deadline as its bound. wasm_tools adds one limit of its own, min_heap_words (16384 words by default): the heap a call's process starts with, which measured as most of the cost of a fresh process (Benchmarks).
  • Nothing is granted unless named: filesystem mounts (read-only unless read_write); env values given explicitly, never the node's; network, an erlang_wasm grant passed through for wasi:sockets; http, a host-name allow-list (exact or *. suffix) on its own grant (E4), so wasi:sockets and guest DNS stay closed, with loopback, private, link-local and metadata addresses refused unless granted by address. Clocks and random are always on in erlang_wasm; the security guide says so.
  • Without network, wasi:sockets is still linked, under a grant that refuses everything (no address, no lookup, no socket created). Found while checking toolchains: componentize-py links sockets in every component, so refusing to link them would make every Python component need a network grant just to load. erlang_wasm already links the filesystem and HTTP this way.
  • The application is the only authority in 0.1: capabilities come from its load options; metadata, guest docs and call options never grant anything. A registry ceiling arrives with management tools, when a third party can ask for capabilities.
  • Size caps on component bytes, arguments and results.
  • Host functions exist only where the application wrote them, for the interfaces it named; they run in the runner and stop with it. Work they hand to other processes can finish after a cancel; the host guide says so.
  • The security guide states what in-process execution does not give: an Erlang process is not OS isolation, timing side channels are not addressed, host functions are the attack surface, fuel is not time. Stronger isolation means a separate node or container.
  • Guest doc comments reach a model as text, so MCP descriptions come from the application's metadata; guest docs are used only with guest_docs => true, capped.

8. MCP adapter

wasm_tools_mcp, one module, no process:

  • register(Registry, #{tools}) asks the registry process to register one barrel_mcp tool per name, so the registry is the owner (B1). register(Component, #{namespace}) needs a namespace and is owned by the caller.
  • A name held by anyone else is refused, never overwritten (B1). Only our own entries are ever unregistered.
  • Each tool carries a small reference as tool data (B5): {registry, Pid, Name}, or for a component registered directly the pid of its holder, which hands out the component; the handler resolves it at call time and fails closed if it is gone.
  • The handler converts the JSON arguments, starts the call, waits for its result while watching for {cancel, ReqId} (and stops the call at once on it), and answers {structured, #{<<"result">> => V}, [Text]}, or {tool_error, [Text]} for a WIT err, an argument error, a trap, an exhausted limit or a timeout.
  • Definitions: input and output schemas from section 5; title and description from metadata; annotations from metadata (read_only, destructive, idempotent), with openWorldHint set when network or http is granted. barrel_mcp's tool timeout is set above ours so our timeout answers first. register checks barrel_mcp:version/0.
  • barrel_mcp checks visible/4 on tools/call as on tools/list (B3), so the handler does not check again. Tenants are separated by listener, visible/4 and namespaces until scoped tool sets exist (B4).
  • B1 and B5 landed, so the adapter has no process of its own. Without them, the fallback was a small lazily started process that owns the dispatch table, monitors owners and checks names before registering.

9. Observability

  • observer => fun((Event, Measurements, Metadata) -> any()) on a registry, and in load and call options for direct use. Events: [wasm_tools, load, stop], [wasm_tools, call, start | stop | exception], [wasm_tools, http, denied]. Measurements: duration, instantiate_time. Metadata: tool, registry, digest, outcome class; never arguments or results. Same shape as a telemetry handler, so fun telemetry:execute/3 works as is; the guide shows a short instrument adapter. An exception in the observer is caught and logged once.
  • wasm_tools:stats(Registry) from an OTP counters array: active, calls, ok, errors by class, timeouts, cancelled, rejected.

10. Required changes upstream

What wasm_tools needed from erlang_wasm and barrel_mcp, and why. Each change went upstream as one commit with its tests and docs; how they were planned is in the proposal as written.

erlang_wasm, released as 0.15.0:

  • E1 wasm_component:describe/1 (bytes or prepared): exports with qualified name, interface, function, params => [{Name, Desc}], result, async, kind; imports with versions and sigs. Internally: keep parameter names, resolve (eq I) type imports and exports, recurse into composed components, read the async flag. Descriptors stay those call/4 takes. Blocking for wasm_tools.
  • E2 argument checks before lowering, for calls and for host results: integer ranges, char scalar values, UTF-8, shapes, missing or unknown record fields, with the path in ctx; plus a public check function. Fixes silent masking for every caller. Blocking.
  • E4 a wasi:http grant separate from the sockets grant, with an authorization hook called with scheme, host and port before resolution and with the checked address after, so an embedder allows by host name without opening sockets or guest DNS. Blocking for the http capability only.
  • E3 wasm_component:custom_sections/1 (package-docs, producers, component-name). Not blocking: guest docs are opt-in.
  • E5 the context of a trap that follows a memory.grow refused by max_memory_pages. Found while building the fixtures: a Rust guest past its memory limit aborts in its allocator, so the caller sees trap/unreachable, like any panic, and wasm_tools cannot report exhaustion/memory_limit without it. Not blocking; until it lands, the memory-limit test asserts a trap.
  • E6 accept erlang_h1 ~> 0.13.1. erlang_wasm 0.14.0 requires ~> 0.11.1 and barrel_mcp 4.8.1 ~> 0.13.1, so Mix cannot resolve a project that uses both, and rebar3 silently picks one. Blocking for the MCP adapter in a Mix project.
  • E7 a server closing its HTTP connection must not kill the guest's process. Found while testing the network capability: the h1 connection is linked to the guest's process and exits {shutdown, peer_closed} when the server closes after its response (connection: close), which kills a caller that does not trap exits, at any point of the call. wasm_tools is not blocked (its runner traps exits), but every other erlang_wasm caller is exposed.
  • Later: a wasi:config/store host (two Wassette examples import it); per-call fuel and host-call usage for observability.

barrel_mcp, released as 4.9.0 before the MCP phase:

  • B1 an owner option on reg_tool: the registry monitors the owner, drops its tools when it dies, and refuses a name held by another owner.
  • B5 per-tool data handed to the handler in Ctx.
  • B3 authorization of tools/call with the same rule as tools/list.
  • B2 batch reg_tools/1, unreg_tools/1: one persistent_term update, one list_changed (each reg_tool today triggers a node-wide persistent_term GC).
  • Reported separately, not blocking: scoped tool sets per listener (B4); tasks/cancel and session DELETE not killing workers; output validation failures labelled "Invalid tool input"; schema recompiled per call; a registry restart wiping tools; guide text out of date (_auth in Args, a crash becoming a JSON-RPC error).

11. Packaging

  • src/wasm_tools.app.src: {application, wasm_tools, [{pkg_name, erlang_wasm_tools}, {applications, [kernel, stdlib, wasm, barrel_mcp]}, {optional_applications, [barrel_mcp]}, ...]}, the pattern erlang_wasm already uses ({pkg_name, erlang_wasm}, optional common_test, and {h1, ..., {pkg, erlang_h1}} in its deps).
  • rebar.config: {deps, [{wasm, "~> 0.15.1", {pkg, erlang_wasm}}]}; barrel_mcp (~> 4.9) only in the test profile. rebar3_hex publishes default-profile deps only, so the package requires erlang_wasm alone. wasm_tools_mcp makes only remote calls (no include, no behaviour), so it compiles without barrel_mcp; xref and dialyzer see it through the test profile.
  • Users: rebar3 {wasm_tools, "~> 0.1", {pkg, erlang_wasm_tools}}, plus barrel_mcp for MCP; mix {:wasm_tools, "~> 0.1", hex: :erlang_wasm_tools}.
  • OTP 29 or later (erlang_wasm's minimum). License Apache-2.0, like erlang_wasm.

12. Project structure

erlang_wasm_tools/
  rebar.config  README.md  CHANGELOG.md  CONTRIBUTING.md  LICENSE
  src/wasm_tools.app.src
  src/wasm_tools.erl            public API
  src/wasm_tools_component.erl  inspect, load, holder, naming, import resolution
  src/wasm_tools_call.erl       runner, watchdog, error normalization
  src/wasm_tools_policy.erl     capabilities and limits to erlang_wasm options
  src/wasm_tools_host.erl       behaviour and import wrappers
  src/wasm_tools_registry.erl   gen_server: names, holders, admission, counters, observer
  src/wasm_tools_json.erl       JSON Schema and JSON to native and back
  src/wasm_tools_mcp.erl        barrel_mcp adapter
  test/                         suites and fixtures (Rust sources, WIT, built .wasm)
  examples/                     calculator, data_transform, http_client, custom_host, mcp, elixir
  docs/                         guides (ex_doc extras; doc/ is the generated site)

No wasm_tools_app or wasm_tools_sup. Estimate: about 2,000 lines in wasm_tools, about 700 in erlang_wasm, about 200 in barrel_mcp, tests excluded.

13. After 0.1

How 0.1.0 was planned and built, in phases, is in the proposal as written. Left for later, not 0.1: snapshots for components with heavy initialisation; stateful tools on wasm_actor; scripts and core modules with an explicit descriptor interface (same schema and codec); async and stream exports; a bounded call queue; a JSON manifest; wasi:config; OCI and remote loaders; a progress host interface; management tools over MCP with a registry ceiling (off by default, behind a scope); the compiled tier.

14. Testing strategy

  • Common Test suites per area; PropEr for JSON (native to JSON to native is identity for every type, range edges, base64) and for E2 in erlang_wasm.
  • Acceptance matrix, each a named test: calculator with no capability; data transform with complex types; several exported interfaces and a name conflict; HTTP client allowed and denied (local h1 server, plus an attempt over wasi:sockets); custom host interface; fuel exhaustion; memory limit; cancel (runner gone, checked by monitor); invalid inputs and traps; unsupported types; concurrent calls; several components; independent registries (no shared names or counters); remove during a call; registry shutdown (no runner left); unload then call; denied capability; no shared state (a global counter returns 1 twice).
  • MCP: the same components through barrel_mcp in-process (tools/list, tools/call, cancel, timeout); no stale tool after remove/2, after the owner dies, or after unregister; a name already used by a native tool is refused; authorization on call.
  • Without MCP: a CI job with the default profile (barrel_mcp not fetched) runs the native suites, and a test asserts barrel_mcp is not started.
  • Interop: the same fixtures run with wasmtime run --invoke, outputs compared; Wassette examples that import only WASI 0.2 and wasi:http run as tools.
  • Benchmarks (CT group bench, as in erlang_wasm): inspect, load, instantiate, call latency (wasm_tools against prepared plus instantiate, call, destroy, in-process and spawned), throughput at several concurrencies, memory per call, MCP adapter overhead, cold and warm. Results with machine and OTP version in Benchmarks.

15. Documentation plan

Task-oriented, second person, Erlang snippets, in docs/ built by ex_doc: README; quick start (five minutes); write your first component (Rust with cargo-component; Python and JavaScript marked tested or not); call one component; manage many with registries; embed in your supervision tree; Elixir; expose through MCP; capabilities and security; host interfaces; lifecycle and ownership; observability; JSON mapping reference; when to use wasm_tools instead of erlang_wasm directly; architecture and a map of where things are; CONTRIBUTING; Features with the tested toolchains and the support matrix.

Verification

  • erlang_wasm branches: rebar3 check (xref, dialyzer, ct with cover) and the new suites.
  • barrel_mcp branches: rebar3 eunit, rebar3 ct, dialyzer.
  • wasm_tools: rebar3 ct, rebar3 as test dialyzer, rebar3 xref, a default-profile build with no barrel_mcp, rebar3 ct --suite=test/wasm_tools_bench_SUITE --group=bench, and the doc examples run by a docs suite, as erlang_wasm does.
  • End to end: start barrel_mcp's HTTP stream server in a test, register the calculator, call tools/list and tools/call with barrel_mcp's client, cancel a long call and check the runner is gone.

Risks

  • The package-docs format comes from wit-component. Checked with wasm-tools 1.256.0: wasm-tools component new does not write it into a runnable component; it appears in an encoded WIT package (wasm-tools component wit wit/ --wasm). So most components carry no guest docs, and descriptions come from the application's metadata, which is also the safe default for MCP.
  • A WASI 0.2 component costs about 810 us per cold call; if that is too slow for a use, snapshots or reuse come later, after measurement.
  • The module cache allows 50 loads per second per node; holders keep loads at one per component, and the lifecycle guide makes the owner explicit.