Reusable WebAssembly components for building composable MCP tool servers
This repository contains production-ready wasmcp components organized by type and ready to publish to OCI registries.
# Build all components
make build
# Publish a component
make publish-component COMPONENT=tools/math VERSION=0.1.0
# Use published components
wasmcp compose wasmcp:math@0.1.0 wasmcp:pythagorean-middleware@0.1.0 -o server.wasmtools/
├── tools/ # Primitive tool components (protocol::tools::Guest)
│ ├── math/
│ ├── statistics/
│ ├── string-utils/
│ ├── system-info/
│ └── geospatial-*/
└── composed/ # Middleware components (server::handler::Guest)
├── pythagorean-middleware/
├── distance-calculator/
├── variance-middleware/
├── stddev-middleware/
└── route-optimizer/
Located in tools/ directory. These export wasmcp:protocol/tools and provide atomic operations.
Guest trait: use bindings::exports::wasmcp::protocol::tools::Guest;
Examples:
tools/math- Mathematical operations (add, multiply, square, etc.)tools/statistics- Statistical primitives (mean, sum, count)tools/string-utils- String manipulationtools/geospatial-distance- Distance calculations
Located in composed/ directory. These import/export wasmcp:server/handler to orchestrate downstream tools.
Guest trait: use bindings::exports::wasmcp::server::handler::Guest;
Examples:
composed/pythagorean-middleware- Composes square + square_rootcomposed/route-optimizer- Composes geospatial toolscomposed/stddev-middleware- Composes variance + square_root
make buildmake build-component COMPONENT=tools/math
make build-component COMPONENT=composed/route-optimizermake list-componentsSee PUBLISHING.md for complete publishing guide.
# Publish to GitHub Container Registry
make publish-component COMPONENT=tools/math VERSION=0.1.0
# Publish all components
make publish VERSION=0.1.0
# Custom registry
make publish-component \
COMPONENT=tools/math \
VERSION=0.1.0 \
REGISTRY=ghcr.io \
NAMESPACE=myorg# Use in compositions
wasmcp compose \
wasmcp:pythagorean-middleware@0.1.0 \
wasmcp:math@0.1.0 \
-o server.wasm
# Mix local and published
wasmcp compose \
./my-local-middleware \
wasmcp:math@0.1.0 \
-o server.wasmIMPORTANT: Middleware must come BEFORE the tools it needs.
# ✅ Correct
wasmcp compose wasmcp:pythagorean-middleware@0.1.0 wasmcp:math@0.1.0
# ❌ Wrong
wasmcp compose wasmcp:math@0.1.0 wasmcp:pythagorean-middleware@0.1.0GitHub Actions automatically builds and publishes components on:
- Tags (
v*.*.*) - Publishes all components - Pull Requests - Test builds only
- Manual dispatch - Selective publishing
Create a release:
./scripts/update-versions.sh 0.2.0
git add .
git commit -m "Bump version to 0.2.0"
git tag v0.2.0
git push && git push --tags| Component | Description |
|---|---|
tools/math |
Mathematical operations |
tools/statistics |
Statistical primitives |
tools/string-utils |
String manipulation |
tools/system-info |
System utilities |
tools/geospatial-distance |
Distance calculations |
tools/geospatial-bearing |
Bearing calculations |
tools/geospatial-point-in-polygon |
Geospatial queries |
| Component | Dependencies |
|---|---|
composed/pythagorean-middleware |
tools/math |
composed/distance-calculator |
tools/math |
composed/variance-middleware |
tools/statistics |
composed/stddev-middleware |
composed/variance-middleware, tools/math |
composed/route-optimizer |
tools/geospatial-*, tools/math |
- Create in
tools/directory - Use
bindings::exports::wasmcp::protocol::tools::Guest - Update
Makefileif needed (auto-detected)
- Create in
composed/directory - Use
bindings::exports::wasmcp::server::handler::Guest - Import
wasmcp:server/handlerfor downstream calls - Update
Makefileif needed (auto-detected)
See LICENSE for details.