You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/blog/mcp-with-wasmcp.md
+34-3Lines changed: 34 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -234,9 +234,9 @@ You can now configure your favorite agent to use the MCP server.
234
234
*[Visual Studio Code](https://code.visualstudio.com/docs/copilot/customization/mcp-servers)
235
235
*[Zed](https://zed.dev/docs/ai/mcp)
236
236
237
-
## Unlimited Feature Composition
237
+
## Unlimited Composition
238
238
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.
Now our server has four tools: `add`, `subtract`, `reverse`, and `uppercase`! Two are implemented in Python, and two in Rust.
319
319
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
+
320
351
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).
321
352
322
353
## Publishing to OCI Registries
323
354
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/).
0 commit comments