# Overview

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

> Understanding ZAP architecture and core concepts

ZAP (Zero-Copy App Proto) is a next-generation communication protocol designed specifically for AI agent ecosystems. Built on Cap'n Proto, it delivers the performance and security required for production agent deployments.

## Core Concepts

### Zero-Copy Serialization

Unlike JSON-RPC used by MCP, ZAP leverages Cap'n Proto's zero-copy serialization:

- **No parsing overhead**: Data is accessed directly from the wire format
- **Shared memory**: Messages can be passed between processes without copying
- **Compact encoding**: Binary format is 2-10x smaller than JSON

```c
struct ToolCall {
  id @0 :Text;
  name @1 :Text;
  args @2 :Data;  # JSON arguments as bytes
  metadata @3 :Metadata;
}
```

### Interface-Based RPC

ZAP uses Cap'n Proto's capability-based RPC system:

```c
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);
  subscribe @5 (uri :Text) -> (stream :ResourceStream);
  listPrompts @6 () -> (prompts :PromptList);
  getPrompt @7 (name :Text, args :Metadata) -> (messages :List(PromptMessage));
  log @8 (level :LogLevel, message :Text, data :Data);
}
```

### MCP Compatibility

ZAP maintains full backward compatibility with MCP through the Gateway interface:

```c
interface Gateway extends(Zap) {
  addServer @0 (name :Text, url :Text, config :ServerConfig) -> (id :Text);
  removeServer @1 (id :Text) -> ();
  listServers @2 () -> (servers :List(ConnectedServer));
  serverStatus @3 (id :Text) -> (status :ServerStatus);
}
```

The Gateway can bridge:

- **stdio**: Standard MCP server processes
- **http**: HTTP-based MCP endpoints
- **websocket**: WebSocket connections
- **zap**: Native ZAP protocol
- **unix**: Unix domain sockets

## Architecture

```text
+------------------+     +------------------+
|   AI Agent       |     |   AI Agent       |
|   (ZAP Client)   |     |   (ZAP Client)   |
+--------+---------+     +--------+---------+
         |                        |
         v                        v
+------------------------------------------+
|              ZAP Gateway                  |
|  +--------+  +--------+  +--------+      |
|  | MCP    |  | MCP    |  | ZAP    |      |
|  | Server |  | Server |  | Server |      |
|  +--------+  +--------+  +--------+      |
+------------------------------------------+
         |                        |
         v                        v
+------------------+     +------------------+
|   Coordinator    |     |   DID Registry   |
|   (Discovery)    |     |   (Identity)     |
+------------------+     +------------------+
```

## Key Features

### Tools

Tools are functions that agents can invoke:

```c
struct Tool {
  name @0 :Text;
  description @1 :Text;
  schema @2 :Data;  # JSON Schema as bytes
  annotations @3 :Metadata;
}
```

### Resources

Resources are data sources with optional streaming:

```c
struct Resource {
  uri @0 :Text;
  name @1 :Text;
  description @2 :Text;
  mimeType @3 :Text;
  annotations @4 :Metadata;
}

interface ResourceStream {
  next @0 () -> (content :ResourceContent, done :Bool);
  cancel @1 () -> ();
}
```

### Prompts

Prompts are reusable message templates:

```c
struct Prompt {
  name @0 :Text;
  description @1 :Text;
  arguments @2 :List(Argument);
}
```

## Security Model

ZAP implements defense-in-depth security:

1. **Transport Security**: Post-quantum hybrid handshake (X25519 + ML-KEM-768)
2. **Message Authentication**: ML-DSA-65 signatures
3. **Identity**: W3C DID-based node identity
4. **Consensus**: Corona threshold signing for multi-party operations

## Next Steps

- [Getting Started](https://docs.hanzo.ai/docs/guides) - Install and run your first ZAP agent
- [Schema Language](https://docs.hanzo.ai/docs/zap/schema) - Learn the Cap'n Proto schema format
- [Protocol Specification](https://docs.hanzo.ai/docs/zap/protocol) - Understand the wire format

- [ZAP vs MCP](https://docs.hanzo.ai/docs/zap/overview/comparison): Detailed comparison between ZAP and Model Context Protocol
- [Architecture](https://docs.hanzo.ai/docs/zap/overview/architecture): ZAP system architecture and component design
