Skip to content

pulseengine/wasi-mcp

Repository files navigation

wasi-mcp

Proposed WASI API for Model Context Protocol

 

WIT WebAssembly License: Apache-2.0

 

A proposed WebAssembly System Interface API for the Model Context Protocol, providing typed operations for MCP 2025-06-18 with WASI 0.3 async support.

Note

Part of the PulseEngine toolchain. Extends WASI standardization for Model Context Protocol interoperability.

Current Phase

Phase 0 — Pre-Proposal (targeting Phase 1)

Approach

Protocol-Faithful Design: This proposal provides typed WIT interfaces that map directly to MCP protocol operations, similar to how wasi-http maps HTTP semantics. Each MCP method has a corresponding typed function with proper async patterns.

Table of Contents

Introduction

The Model Context Protocol (MCP) is an open standard that enables AI applications to connect to external data sources, tools, and workflows. This WASI proposal enables WebAssembly components to implement MCP servers and clients with full protocol support.

Why WASI for MCP?

  • Portability: Run MCP servers across any WASM runtime
  • Security: Leverage WebAssembly's capability-based security model
  • Performance: Native async operations with WASI 0.3
  • Composability: Component Model enables MCP server aggregation
  • Type Safety: Strongly-typed WIT interfaces prevent protocol errors

Protocol Coverage: This proposal implements the complete MCP 2025-06-18 specification including protocol initialization, resources with templates and subscriptions, tools with annotations, prompts with arguments, pagination, progress tokens, notifications, logging, and streaming support.

Two Versions: WASI 0.2 + WASI 0.3

Version Status Use Case Location
WASI 0.3 Aspirational Final standardization with async wit/*.wit
WASI 0.2 Available now Immediate prototyping (blocking ops) wit/preview2/*.wit

Goals

  1. Complete MCP Protocol Support in WIT
  2. Protocol-Faithful Design with direct mapping of MCP methods
  3. WASI 0.3 async with future<result<T, error>>
  4. Follow WASI Patterns from successful Phase 3 proposals
  5. Clear Path to Phase 1

Non-goals

  • Transport Implementation (handled by hosts)
  • JSON-RPC Layer (implementation detail)
  • AI Model Integration (out of scope)
  • Backward Compatibility (only targeting latest MCP spec)

API Overview

Bidirectional Interface Pattern — Components import runtime capabilities and export handlers:

// Component IMPORTS runtime to register and serve
interface runtime {
    register-server: func(info: server-info) -> future<result<_, error>>;
    register-tools: func(tools: list<tool-definition>) -> future<result<_, error>>;
    serve: func() -> future<result<_, error>>;
}

// Component EXPORTS handlers to execute operations
interface handlers {
    call-tool: func(name: string, arguments: list<u8>) -> future<result<tool-result, error>>;
    read-resource: func(uri: string) -> future<result<resource-contents, error>>;
}

Interface Structure:

wit/
├── types.wit          # Core MCP types
├── capabilities.wit   # Server/Client capabilities
├── content.wit        # Content blocks
├── runtime.wit        # Runtime API (component imports)
├── handlers.wit       # Handler interface (component exports)
├── client.wit         # Client operations
├── world.wit          # Component worlds
└── preview2/          # WASI 0.2 for immediate prototyping

Examples

See the full Examples section for MCP backend, client, and streaming usage patterns in Rust.

Implementation Status

Completed

  • Core types with all MCP protocol types
  • Complete capabilities system
  • Content type system with variants
  • Typed server and client operations
  • Notification system and streaming interface
  • World definitions with deps.toml
  • WASI 0.2 interfaces for immediate prototyping

Next Steps for Phase 1

  1. Create reference implementations (Rust, Go, C++)
  2. Gather stakeholder feedback (Anthropic, WASI Subgroup)
  3. Submit Phase 1 proposal

References

License

Apache-2.0


Part of PulseEngine — formally verified WebAssembly toolchain for safety-critical systems

About

Proposed WASI API for Model Context Protocol, targeting WASI 0.3 standardization

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors