# ZAP Protocol

URL: https://docs.hanzo.ai/docs/zap

> Zero-Copy App Proto — High-performance Cap'n Proto RPC for AI agent communication. 10-100x faster than MCP with post-quantum security.

**ZAP** (Zero-Copy App Proto) is a high-performance communication protocol for AI agents built on Cap'n Proto. It provides full MCP compatibility with 10-100x performance improvements, post-quantum security, and native support for 11 programming languages.

```bash title="Install"
curl -fsSL https://hanzo.sh | sh && hanzo mcp launch zap
```

## Why ZAP?

- **Zero-Copy Performance** — Cap'n Proto's zero-copy serialization eliminates parsing overhead
- **MCP Compatible** — Full backward compatibility with Model Context Protocol servers
- **Post-Quantum Security** — ML-KEM and ML-DSA cryptography for future-proof security
- **Multi-Language** — Native bindings for Rust, Go, Python, JavaScript, C++, and 6 more
- **Agent Consensus** — Built-in voting mechanism for multi-agent response aggregation
- **W3C DID** — Native decentralized identity support

* [Overview](https://docs.hanzo.ai/docs/zap/overview): Architecture and core concepts
* [Getting Started](https://docs.hanzo.ai/docs/zap/getting-started): Install ZAP and build your first agent
* [Schema Language](https://docs.hanzo.ai/docs/zap/schema): Cap'n Proto schema reference
* [Protocol Spec](https://docs.hanzo.ai/docs/zap/protocol): Wire format and RPC details
* [Language Bindings](https://docs.hanzo.ai/docs/zap/bindings): SDK docs for 11 languages
* [Advanced Topics](https://docs.hanzo.ai/docs/zap/advanced): Post-quantum crypto, consensus, blockchain

## Quick Example

```c title="zap.capnp"
interface Zap {
  init @0 (client :ClientInfo) -> (server :ServerInfo);
  listTools @1 () -> (tools :ToolList);
  callTool @2 (call :ToolCall) -> (result :ToolResult);
  listResources @3 () -> (resources :ResourceList);
  readResource @4 (uri :Text) -> (content :ResourceContent);
}
```

```rust title="Rust Example"
use zap_protocol::{Zap, ClientInfo};

#[tokio::main]
async fn main() -> Result<()> {
    let client = Zap::connect("zap://localhost:9000").await?;
    let info = client.init(ClientInfo::new("my-agent", "1.0.0")).await?;

    let tools = client.list_tools().await?;
    for tool in tools {
        println!("Tool: {} - {}", tool.name, tool.description);
    }

    Ok(())
}
```

## ZAP vs MCP

| Feature           | MCP            | ZAP             |
| ----------------- | -------------- | --------------- |
| Serialization     | JSON-RPC       | Cap'n Proto     |
| Performance       | Baseline       | 10-100x faster  |
| Memory            | High (parsing) | Zero-copy       |
| Post-Quantum      | No             | ML-KEM, ML-DSA  |
| Threshold Signing | No             | Corona          |
| DID Support       | No             | W3C DIDs        |
| Agent Consensus   | No             | Built-in voting |

ZAP includes **MCP Gateway Mode** for seamless migration from existing MCP servers.

- [Overview](https://docs.hanzo.ai/docs/zap/overview): Understanding ZAP architecture and core concepts
- [Getting Started](https://docs.hanzo.ai/docs/zap/getting-started): Install ZAP and build your first AI agent
- [Schema Language](https://docs.hanzo.ai/docs/zap/schema): Cap'n Proto schema reference for ZAP
- [Protocol Specification](https://docs.hanzo.ai/docs/zap/protocol): ZAP wire format, encoding, and RPC semantics
- [The Local Router](https://docs.hanzo.ai/docs/zap/router): One ZAP router per user, embedded in every process that speaks ZAP — no daemon
- [Language Bindings](https://docs.hanzo.ai/docs/zap/bindings): ZAP SDK documentation for all supported languages
- [Advanced Topics](https://docs.hanzo.ai/docs/zap/advanced): Post-quantum cryptography, consensus, identity, and blockchain integration
