Skip to content

maceip/wt-mcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wtmcpL

MCP-over-WebTransport

This repository contains early attempts to implement Model Context Protocol (MCP) over WebTransport, leveraging the power of HTTP/3 and QUIC for ultra-low latency, bidirectional communication between AI systems and tools/resources.

What is MCP-over-WebTransport?

MCP (Model Context Protocol) is an open protocol that enables AI systems to securely interact with local and remote resources through a standardized interface. It provides:

  • Tools - Functions that AI can call with parameters
  • Resources - Data sources the AI can read
  • Prompts - Templates for generating contextual prompts
  • Subscriptions - Real-time updates to resources

WebTransport provides:

  • Low latency - Built on QUIC/HTTP3 for minimal round-trip times
  • Bidirectional streams - Native support for full-duplex communication
  • Multiplexing - Multiple concurrent streams over a single connection
  • Reliability - Automatic retransmission with optional unreliable delivery

By combining MCP with WebTransport, we achieve:

  • Ultra-low latency - Direct QUIC communication without HTTP/WebSocket overhead
  • True bidirectional messaging - Server can push updates without polling
  • Better performance - Reduced protocol overhead and connection setup time
  • Native browser support - WebTransport API available in modern browsers

Architecture

┌─────────────────────────────┐
│    MCP Application Layer    │  ← Tools, Resources, Prompts
├─────────────────────────────┤
│    JSON-RPC 2.0 Messages    │  ← Standard RPC protocol
├─────────────────────────────┤
│     Frame Protocol Layer    │  ← Length-prefixed frames
├─────────────────────────────┤
│   WebTransport Bidi Stream  │  ← Bidirectional data flow
├─────────────────────────────┤
│        QUIC (HTTP/3)        │  ← Modern transport layer
└─────────────────────────────┘

Frame Protocol

All messages are sent as length-prefixed frames:

[4 bytes: Big-Endian u32 length][JSON payload]

This simple framing allows efficient parsing and message boundaries without the complexity of HTTP headers or WebSocket frames.

Implementations

Production-Ready

Rust (Most Complete)

  • Full MCP protocol implementation with all core features
  • Server and client with CLI interface
  • Example tools, resources, and prompts
  • TLS 1.3 via QUIC
  • Async/await with Tokio
  • JWT authentication support
  • Details →
# Server
cd rust/server && cargo run --release

# Client
cd rust/client && cargo run --release -- tools

Python (Full MCP)

  • Complete MCP protocol implementation
  • WebTransport via aioquic
  • Tools, resources, and prompts support
  • JWT authentication
  • Frame protocol with TCP fallback
cd python && python mcp_server.py
# Or for client:
python mcp_client.py

Experimental/Partial

Go (Partial MCP)

  • WebTransport server using quic-go
  • JSON-RPC message handling
  • MCP initialization and tools support
  • JWT authentication
  • OpenAI integration example
cd go/server && go run main.go

JavaScript/TypeScript (Browser Demo)

  • Browser-based WebTransport client
  • Bun server for development
  • Basic frame protocol implementation
  • Simple ping/pong messaging
cd js/server && bun index.ts
# Open browser to http://localhost:3000

Isolated Web App (Direct Sockets)

  • Chrome IWA with Direct Sockets API
  • QUIC support via quinn-wasm
  • WebSocket server functionality
  • HTTP server with chunked transfer
  • Details →
cd server/iwa && node index.js
# Creates signed.swbn for Chrome installation
# Install via chrome://web-app-internals

Kotlin (Basic Structure)

  • Gradle multi-module structure
  • Common protocol definitions
  • JWT authentication utilities
  • Foundation for Android support

Swift (Placeholder)

  • Directory structure only
  • Planned for iOS/macOS support

Features

Protocol Features

Feature Rust Python Go JS Kotlin Swift
WebTransport 🚧
Frame Protocol 🚧
JSON-RPC 2.0 🚧 🚧
TLS/QUIC
JWT Auth 🚧

MCP Features

Feature Rust Python Go JS Kotlin Swift
Initialize
Tools
Resources 🚧
Prompts 🚧
Subscriptions 🚧 🚧
Progress 🚧 🚧
Cancellation 🚧

✅ Implemented | 🚧 Partial/In Progress | ❌ Not Implemented

📋 What's Missing

Core Functionality

  • Resource subscriptions - Full real-time update support across all implementations
  • Progress reporting - Complete implementation for long-running operations
  • Request cancellation - Full cancellation support in all languages
  • OAuth2 authentication - Beyond JWT in most implementations

Language Support

  • JavaScript/TypeScript: MCP protocol implementation (currently just WebTransport demo)
  • Go: Complete resources and prompts implementations
  • Kotlin: WebTransport integration and MCP protocol implementation
  • Swift: Any implementation beyond directory structure

Advanced Features

  • Stream multiplexing for parallel operations
  • Binary encoding (Protocol Buffers/MessagePack)
  • Server push notifications
  • WebAssembly client for universal browser support
  • Federation for multi-server routing

🚦 Getting Started

Prerequisites

  • Rust: rustc 1.70+ and cargo
  • Node.js: Bun runtime for JavaScript
  • Go: Go 1.21+ with modules
  • Python: Python 3.9+ with aioquic

Quick Start

  1. Clone the repository
git clone https://github.com/yourusername/wt-mcp
cd wt-mcp
  1. Start the Rust server (most complete)
cd rust/server
cargo run --release
  1. Test with the Rust client
cd rust/client
cargo run --release -- tools
cargo run --release -- call echo --args '{"message": "Hello MCP!"}'
  1. Try the browser client
cd js/server
bun index.ts
# Open http://localhost:3000

📊 Performance

WebTransport provides significant performance improvements over traditional approaches:

Metric WebSocket HTTP/2 WebTransport
Connection Setup ~150ms ~100ms ~50ms
Round-trip Latency ~20ms ~15ms ~5ms
Throughput Good Good Excellent
Head-of-line Blocking Yes Per-stream No
Multiplexing No Yes Yes

Security

Current implementations use self-signed certificates for development. For production:

  • Use proper TLS certificates from a trusted CA
  • Implement authentication (tokens, mTLS, etc.)
  • Add rate limiting and input validation
  • Enable certificate verification in clients

Contributing

This is an experimental project exploring the possibilities of MCP over WebTransport. Contributions are welcome!

Areas needing help:

  • Completing MCP implementation in JavaScript/TypeScript
  • Adding missing features (subscriptions, progress, cancellation)
  • Implementing Kotlin and Swift clients
  • Performance benchmarking and optimization
  • Documentation and examples

📚 Resources

📄 License

MIT License - See individual implementation directories for specific licensing.

Vision

MCP-over-WebTransport represents the future of AI-to-system communication, providing a standardized, high-performance protocol for AI agents to interact with tools and resources. This project serves as a reference implementation and testbed for this exciting new paradigm.


Note: This is an experimental implementation. The MCP specification and WebTransport API are evolving. Use in production at your own risk.

About

MCP (Model Context Protocol) over WebTransport - Ultra-low latency AI-to-system communication using HTTP/3 and QUIC

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors