Skip to content

Commit ddf63fc

Browse files
committed
Add more explanation about how wasmcp composes things.
Signed-off-by: bowlofarugula <[email protected]>
1 parent 4a27fef commit ddf63fc

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

content/blog/mcp-with-wasmcp.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ You can now configure your favorite agent to use the MCP server.
234234
* [Visual Studio Code](https://code.visualstudio.com/docs/copilot/customization/mcp-servers)
235235
* [Zed](https://zed.dev/docs/ai/mcp)
236236

237-
## Unlimited Feature Composition
237+
## Unlimited Composition
238238

239-
The real power of the component model becomes apparent when adding another tool component to our server. We'll use Python this time.
239+
The real power of the component model and wasmcp's composition architecture becomes apparent when adding another tool component to our server. We'll use Python this time.
240240

241241
```
242242
$ wasmcp new python-tools –language python
@@ -317,11 +317,42 @@ Serving http://127.0.0.1:3000
317317

318318
Now our server has four tools: `add`, `subtract`, `reverse`, and `uppercase`! Two are implemented in Python, and two in Rust.
319319

320+
### Wasmcp's architecture
321+
322+
Server features like tools, resources, prompts, and completions, are implemented by individual WebAssembly components that export narrow [WIT](https://component-model.bytecodealliance.org/design/wit.html) interfaces mapped from the MCP spec's [schema types](https://modelcontextprotocol.io/specification/draft/schema).
323+
324+
`wasmcp compose` plugs these feature components into framework components and composes them together behind a transport component as a complete middleware [chain of responsibility](https://en.wikipedia.org/wiki/Chain-of-responsibility_pattern) that implements an MCP server.
325+
326+
Any of the wasmcp framework components, like the transport, can be swapped out for custom implementations during composition, enabling flexible server configurations.
327+
328+
```
329+
Transport<Protocol>
330+
331+
Middleware₀
332+
333+
Middleware<Feature>₁
334+
335+
Middleware<Feature>₂
336+
337+
...
338+
339+
Middlewareₙ
340+
341+
MethodNotFound
342+
```
343+
344+
Each component:
345+
- Handles requests it understands (e.g., `tools/call`)
346+
- Delegates others downstream
347+
- Merges results (e.g., combining tool lists)
348+
349+
This enables dynamic composition without complex configuration, all within a single Wasm binary. Think Unix pipes for MCP using Wasm components.
350+
320351
This example only scratched the surface of what we can potentially do with `wasmcp`. To see some of the more advanced patterns like custom middleware components and session-enabled features, check out the [examples](https://github.com/wasmcp/wasmcp/tree/main/examples).
321352

322353
## Publishing to OCI Registries
323354

324-
We can use [wkg](https://github.com/bytecodealliance/wasm-pkg-tools) to publish our server to an [OCI](https://opencontainers.org/) registry, like [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry), [Docker Hub](https://docs.docker.com/docker-hub/repos/manage/hub-images/oci-artifacts/), or [Amazon Elastic Container Registry](https://aws.amazon.com/ecr/).
355+
We can use [wkg](https://github.com/bytecodealliance/wasm-pkg-tools) to publish our server to an [OCI](https://opencontainers.org/) registry like [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry), [Docker Hub](https://docs.docker.com/docker-hub/repos/manage/hub-images/oci-artifacts/), or [Amazon Elastic Container Registry](https://aws.amazon.com/ecr/).
325356

326357
```
327358
$ wkg publish polyglot.wasm --package mygithub:[email protected]

0 commit comments

Comments
 (0)