# ZAP vs MCP

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

> Detailed comparison between ZAP and Model Context Protocol

ZAP is designed as a high-performance successor to MCP while maintaining full backward compatibility. This page details the key differences.

## Performance

### Serialization

| Aspect  | MCP (JSON-RPC)      | ZAP (Cap'n Proto) |
| ------- | ------------------- | ----------------- |
| Format  | Text (JSON)         | Binary            |
| Parsing | Full parse required | Zero-copy access  |
| Size    | Larger (verbose)    | 2-10x smaller     |
| CPU     | High (parsing)      | Minimal           |
| Memory  | Allocations         | Direct access     |

### Benchmarks

Real-world measurements on typical agent workloads:

```text
Operation              MCP        ZAP        Speedup
---------------------------------------------------------
Tool list (100 tools)  45ms       0.4ms      112x
Tool call (small)      12ms       0.8ms      15x
Tool call (large)      89ms       2.1ms      42x
Resource read (1KB)    8ms        0.2ms      40x
Resource read (1MB)    156ms      4.2ms      37x
```

## Protocol Features

### MCP Features in ZAP

ZAP implements all MCP features:

| Feature        | MCP | ZAP | Notes               |
| -------------- | --- | --- | ------------------- |
| Tools          | Yes | Yes | Same semantics      |
| Resources      | Yes | Yes | + streaming         |
| Prompts        | Yes | Yes | Same semantics      |
| Logging        | Yes | Yes | Same levels         |
| Initialization | Yes | Yes | Capability exchange |

### ZAP Extensions

Features unique to ZAP:

| Feature                | Description           |
| ---------------------- | --------------------- |
| **Gateway**            | Bridge MCP servers    |
| **Coordinator**        | Agent discovery       |
| **PQ Handshake**       | Post-quantum security |
| **Corona**             | Threshold signing     |
| **Agent Consensus**    | Response voting       |
| **DID Registry**       | W3C identity          |
| **Resource Streaming** | Real-time updates     |

## Security Comparison

### Transport Security

| Aspect          | MCP        | ZAP                 |
| --------------- | ---------- | ------------------- |
| Default         | None       | PQ-TLS              |
| Key Exchange    | -          | X25519 + ML-KEM-768 |
| Authentication  | None/Basic | ML-DSA-65           |
| Forward Secrecy | -          | Yes                 |
| PQ-Resistant    | No         | Yes                 |

### Identity

| Aspect       | MCP               | ZAP                       |
| ------------ | ----------------- | ------------------------- |
| Identity     | Application-level | W3C DID                   |
| Methods      | -                 | did:lux, did:key, did:web |
| Verification | -                 | On-chain optional         |
| Staking      | No                | Yes (Lux)                 |

## Language Support

### MCP SDKs

- Python (official)
- TypeScript (official)

### ZAP Bindings

- Rust (reference)
- Go
- Python
- JavaScript/TypeScript
- C++
- C
- Java
- C#
- Erlang
- OCaml
- Haskell

## Migration Path

ZAP provides seamless migration from MCP:

```go
// Create ZAP gateway
gateway := zap.NewGateway()

// Add existing MCP servers
gateway.AddServer("filesystem", "stdio://npx -y @modelcontextprotocol/server-filesystem", &zap.ServerConfig{
    Transport: zap.TransportStdio,
})

gateway.AddServer("github", "stdio://npx -y @modelcontextprotocol/server-github", &zap.ServerConfig{
    Transport: zap.TransportStdio,
    Auth: &zap.Auth{
        Bearer: os.Getenv("GITHUB_TOKEN"),
    },
})

// Use unified ZAP interface
tools, _ := gateway.ListTools()
result, _ := gateway.CallTool(&zap.ToolCall{
    Name: "read_file",
    Args: []byte(`{"path": "/etc/hosts"}`),
})
```

## When to Use Which

### Use MCP When

- Prototyping quickly
- Limited language support is acceptable
- Performance is not critical
- No security requirements

### Use ZAP When

- Production deployments
- Performance-sensitive applications
- Multi-agent coordination
- Post-quantum security required
- Need threshold signing
- W3C DID identity needed
- Bridging multiple MCP servers

## Future Compatibility

ZAP is designed for forward compatibility:

- **Versioned schemas**: Protocol evolution without breaking changes
- **Capability negotiation**: Clients and servers declare supported features
- **Extension points**: Room for future protocol extensions
