Skip to main content

tollbooth-wasmcp

The Spin/WASI host for tollbooth-dpyc Operators.

A DPYC Operator is business logic — a set of priced MCP tools over the tollbooth-dpyc runtime. On Prefect Horizon, FastMCP is the host that turns that logic into a running MCP server. tollbooth-wasmcp is the peer host for Fermyon Spin / Akamai Functions: it lets the same operator code deploy as a WebAssembly component, reusing the tollbooth-dpyc wheel untouched. Write the operator once; pick the host.

FastMCP's edge jobs — derive the tool schema from your typed functions, coerce inbound args, run the transport — are done here by the adapter (get_type_hints-based schema + pydantic-lite coercion + a WASI transport). Same source of truth (your tool functions' hints + docstrings), a second host projection of it. The operator never writes either.

Writing an operator

import tollbooth_wasmcp                      # FIRST import — installs the pre-init seams
from tollbooth_wasmcp import SpinOperatorHost
from tollbooth.tool_identity import ToolIdentity, capability_uuid
import weather                               # your domain client

_DOMAIN = { UUID: ToolIdentity(tool_id=UUID, capability="get_current_weather", category="read", intent="…"), … }

host = SpinOperatorHost(service_name="my-operator", slug="myslug", domain_tools=_DOMAIN)
tool = host.tool

@tool
@host.runtime.paid_tool(capability_uuid("get_current_weather"))
async def current(latitude: float, longitude: float, npub: str = "", dpop_token: str = ""):
    return await weather.get_current(latitude, longitude)

Tools = host.tools_export()                  # the wasmcp exports.Tools surface

That is the FastMCP tollbooth-sample server, line for line, with SpinOperatorHost(…) where the FastMCP operator writes FastMCP(…) and Tools = host.tools_export() where it writes mcp.run(). See examples/weather-operator for the complete, runnable version.

What the host provides

Importing tollbooth_wasmcp installs — in order, before the wheel imports — every seam the componentize-py build needs, none of which the WASI Python interpreter has natively:

  • httpx over wasi:http — every wheel HTTP call (registry, bridge, Neon, upstream APIs).
  • dpyc:crypto component — a Rust WASI component (NIP-04 ECDH, BIP-340 schnorr verify, AES-CBC/GCM) standing in for coincurve/cryptography. Shipped prebuilt as tollbooth_wasmcp/crypto.wasm.
  • nsec-only bootstrap — ensure_bootstrapped fetches the operator's encrypted config event through an HTTPS→Nostr-relay bridge Worker and decrypts it with the crypto component (the operator holds only its nsec; the Neon URL is discovered, never configured).
  • schema + coercion — tool_schema (correct JSON types even under the wheel's PEP 563 annotations) and bind_args (coerce "90" → 90 for an int param), the FastMCP/pydantic edge jobs.
  • snapshot fixes — force-bundle the wheel's lazily-imported submodules, pin the wheel version, read config from the live WASI environment (spin up --env) each call.
  • PROOF_DEBUG (opt-in, off by default) — a rejected proof explains which sub-check failed.

Building an operator (out-of-repo)

pip install tollbooth-wasmcp                 # into your build's deps/ (--target deps)
# then in your Makefile:
componentize-py --wit-path $(python -m tollbooth_wasmcp.paths wit) --world operator \
  componentize app -p . -p deps -p $(python -m tollbooth_wasmcp.paths toplevel) -o operator.wasm
wac plug operator.wasm --plug $(python -m tollbooth_wasmcp.paths crypto) -o plugged.wasm
wasmcp compose server plugged.wasm -o server.wasm

Run (the operator is nsec-only — supply the nsec + bridge URL at run time, never in the manifest):

# start the bridge in bridge/:  npx wrangler dev --port 8799 --local
spin up --env TOLLBOOTH_NOSTR_OPERATOR_NSEC=<nsec> --env BRIDGE_URL=http://localhost:8799

Requires componentize-py, wac, wasmcp, and spin on PATH. The standardized WIT world imports wasi:http, dpyc:crypto, wasi:cli/environment, and wasi:config/store; do not run componentize-py bindings separately (it clobbers the vendored poll_loop.py).

Repo layout

tollbooth_wasmcp/       the adapter (PyPI package): SpinOperatorHost, schema, binding, seams
  _toplevel/            pynostr + cryptography shims the wheel imports by top-level name
  wit/                  the standardized DPYC Spin WIT world + deps
  crypto.wasm           prebuilt dpyc:crypto component (from crypto/)
crypto/                 Rust source for the dpyc:crypto component
bridge/                 the HTTPS→Nostr-relay bridge Cloudflare Worker
examples/weather-operator/   a complete reference operator using SpinOperatorHost
tests/                  schema unit tests (incl. FastMCP parity)

Apache-2.0. Part of the DPYC ecosystem.

Metadata

Release files for tollbooth-wasmcp 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tollbooth-wasmcp 0.1.8
File Size Uploaded Provenance Actions
tollbooth_wasmcp-0.1.8.tar.gz 148.5 kB With provenance Details for tollbooth_wasmcp-0.1.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tollbooth-wasmcp 0.1.8
File Interpreter ABI Platform Actions
tollbooth_wasmcp-0.1.8-py3-none-any.whl Python 3 none any Details for tollbooth_wasmcp-0.1.8-py3-none-any.whl

Total release size: 262.9 kB

Release files / tollbooth_wasmcp-0.1.8.tar.gz

Download URL tollbooth_wasmcp-0.1.8.tar.gz
Size 148.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b196c0d61d68c25b025742611fe3efd6cdc3a0aada8d0b4c67ca6a5bafbbb863
BLAKE2b-256 checksum
How to use checksums
772458e79113cbf96ddb9e81567b739f90bbbfa5cfb9bbc81983a4f816a26c0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Release files / tollbooth_wasmcp-0.1.8-py3-none-any.whl

Download URL tollbooth_wasmcp-0.1.8-py3-none-any.whl
Size 114.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
987952669309f6a19b0489b6fa6625e1eedf6aebfaf0c4f6bd732ee174fb111d
BLAKE2b-256 checksum
How to use checksums
f69036c0361a4818283a1ba72f937ef8d7727dd866452be62b009a705652c6ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Security for tollbooth-wasmcp 0.1.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tollbooth_wasmcp-0.1.8.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page