High-performance Cap'n Proto RPC for AI agent communication.
ZAP provides a unified protocol for connecting to and aggregating MCP (Model Context Protocol) servers, enabling efficient tool calling, resource access, and prompt management for AI agents.
- Zero-copy Serialization: Cap'n Proto for minimal overhead
- Multi-transport: Unix sockets, TCP, WebSocket, HTTP
- MCP Gateway: Aggregate multiple MCP servers behind a single endpoint
- Cross-language: Rust, Python, TypeScript implementations
- High Performance: Designed for AI workloads with low latency
| Package | Language | Install |
|---|---|---|
hanzo-zap |
Rust | cargo add hanzo-zap |
hanzo-zap |
Python | pip install hanzo-zap |
@hanzo/zap |
TypeScript | npm install @hanzo/zap |
use zap::{Client, Gateway, Config};
// Connect to a ZAP gateway
let client = Client::connect("zap://localhost:9999").await?;
// List available tools
let tools = client.list_tools().await?;
// Call a tool
let result = client.call_tool("search", json!({"query": "hello"})).await?;from hanzo_zap import Client, Gateway
# Connect to a ZAP gateway
client = await Client.connect("zap://localhost:9999")
# List available tools
tools = await client.list_tools()
# Call a tool
result = await client.call_tool("search", {"query": "hello"})import { Client, Gateway } from '@hanzo/zap';
// Connect to a ZAP gateway
const client = await Client.connect('zap://localhost:9999');
// List available tools
const tools = await client.listTools();
// Call a tool
const result = await client.callTool('search', { query: 'hello' });# List tools from a gateway
zap tools list
# Call a tool
zap call search --query "hello world"
# List resources
zap resources list
# Read a resource
zap read file:///path/to/file# Start gateway with config file
zapd --config /etc/zap/config.toml
# Start with inline servers
zapd --server "stdio://npx @modelcontextprotocol/server-filesystem"Create a zap.toml configuration file:
[gateway]
listen = "0.0.0.0"
port = 9999
log_level = "info"
[[servers]]
name = "filesystem"
transport = "stdio"
command = "npx"
args = ["@modelcontextprotocol/server-filesystem", "/path/to/files"]
[[servers]]
name = "database"
transport = "http"
url = "http://localhost:8080/mcp"
[[servers]]
name = "search"
transport = "websocket"
url = "ws://localhost:9000/ws"┌─────────────────────────────────────────────────────────────┐
│ AI Client │
│ (Claude, GPT, etc.) │
└──────────────────────────┬──────────────────────────────────┘
│
│ ZAP Protocol (Cap'n Proto RPC)
│
▼
┌─────────────────────────────────────────────────────────────┐
│ ZAP Gateway │
│ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ Server Registry │ │
│ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │
│ │ │Server A │ │Server B │ │Server C │ │Server D │ │ │
│ │ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ │ │
│ └───────┼────────────┼────────────┼────────────┼───────┘ │
│ │ │ │ │ │
└──────────┼────────────┼────────────┼────────────┼──────────┘
│ │ │ │
▼ ▼ ▼ ▼
┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐
│ stdio │ │ HTTP │ │ WS │ │ Unix │
│ MCP │ │ MCP │ │ MCP │ │ Socket │
│ Server │ │ Server │ │ Server │ │ Server │
└────────┘ └────────┘ └────────┘ └────────┘
ZAP uses Cap'n Proto for efficient serialization and RPC:
interface Zap {
# Server discovery
initialize @0 (info :ServerInfo) -> (info :ServerInfo);
# Tools
listTools @1 () -> (tools :List(Tool));
callTool @2 (name :Text, arguments :Text) -> (result :ToolResult);
# Resources
listResources @3 () -> (resources :List(Resource));
readResource @4 (uri :Text) -> (content :ResourceContent);
# Prompts
listPrompts @5 () -> (prompts :List(Prompt));
getPrompt @6 (name :Text, arguments :Text) -> (messages :List(PromptMessage));
}cd /path/to/hanzo-zap
cargo build
cargo testcd /path/to/hanzo-zap/python
uv sync
uv run pytestcd /path/to/hanzo-zap/typescript
npm install
npm run build
npm testFull documentation available at: https://hanzoai.github.io/zap
MIT OR Apache-2.0