File size: 3,877 Bytes
d086025 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | # A2A Rust SDK — Usage Guide (cleanroom)
`a2a-rs` is a Rust workspace for the A2A v1 protocol. It provides core protocol
types, async client and server libraries, protobuf definitions, and gRPC/SLIMRPC
bindings for building interoperable A2A agents and clients.
## Supported transports
- JSON-RPC 2.0 over HTTP
- REST / HTTP+JSON
- gRPC (tonic)
- SLIMRPC (slim_bindings)
- Server-Sent Events for streaming responses
- Protobuf-based interop with other SDKs and runtimes
Binding support matrix:
| Binding | Client | Server |
| --- | --- | --- |
| JSON-RPC | `a2a-client` | `a2a-server` |
| HTTP+JSON / REST | `a2a-client` | `a2a-server` |
| gRPC | `a2a-grpc` | `a2a-grpc` |
| SLIMRPC | `a2a-slimrpc` | `a2a-slimrpc` |
## Requirements
- Rust 1.85 or newer (stable `rustup` toolchain recommended)
- Optional: `just` for common project commands
## Build and run
```sh
cargo build --workspace
cargo test --workspace
```
With `just`: `just build`, `just test`, `just lint`, `just fmt-check`, `just ci`.
## Running the example agent
```sh
cargo run -p helloworld
```
When the example starts, these endpoints are available:
- Agent card: `http://localhost:3000/.well-known/agent-card.json`
- JSON-RPC endpoint: `http://localhost:3000/jsonrpc`
- REST endpoint: `http://localhost:3000/rest`
The example serves an echo-style agent over REST and JSON-RPC; it does not
start a gRPC server (the `a2a-grpc` crate provides those bindings).
## Installing the A2A CLI
Pre-built binaries exist for macOS (arm64, x86_64), Linux (x86_64, aarch64),
and Windows (x86_64).
macOS (Homebrew):
```sh
brew tap a2aproject/a2a-rs https://github.com/a2aproject/a2a-rs
brew trust a2aproject/a2a-rs
brew install a2acli
```
Linux (install script):
```sh
curl -fsSL https://raw.githubusercontent.com/a2aproject/a2a-rs/main/install.sh | bash
```
Installs to `/usr/local/bin` as root or `~/.local/bin` otherwise; override the
directory with `A2A_CLI_INSTALL_DIR`.
Windows (WinGet):
```sh
winget install a2aproject.a2acli
```
From source (crates.io):
```sh
cargo install a2a-cli
```
## Using the A2A CLI
The CLI resolves the public agent card from a base URL, negotiates JSON-RPC or
HTTP+JSON, prints responses as JSON, and manages task push notification configs.
Subcommands:
```sh
cargo run --bin a2acli -- card
cargo run --bin a2acli -- send "hello from rust"
cargo run --bin a2acli -- stream "hello from rust"
cargo run --bin a2acli -- list-tasks
cargo run --bin a2acli -- push-config list task-123
```
Flags:
- `--base-url https://host` — override the target server
(default: `http://localhost:3000`, matching the bundled hello world server)
- `--binding jsonrpc` or `--binding http-json` — pin transport selection
- `--bearer-token <token>` — bearer authentication
- `--header Name:Value` (repeatable) — extra request headers
Output format: responses are printed as JSON.
## Depending on the crates
Published on crates.io; to use the latest development version from Git:
```toml
[dependencies]
a2a = { package = "a2a-lf", git = "https://github.com/a2aproject/a2a-rs.git" }
a2a-client = { package = "a2a-client-lf", git = "https://github.com/a2aproject/a2a-rs.git" }
a2a-server = { package = "a2a-server-lf", git = "https://github.com/a2aproject/a2a-rs.git" }
a2a-pb = { package = "a2a-pb", git = "https://github.com/a2aproject/a2a-rs.git" }
a2a-grpc = { package = "a2a-grpc", git = "https://github.com/a2aproject/a2a-rs.git" }
a2a-slimrpc = { package = "a2a-slimrpc", git = "https://github.com/a2aproject/a2a-rs.git" }
```
Typical usage: `a2a` for protocol types/serde models, `a2a-client` for clients
that negotiate REST or JSON-RPC from an agent card, `a2a-server` for agent
implementations on `axum`, `a2a-grpc` for gRPC transport, `a2a-slimrpc` for
SLIMRPC transport, and `a2a-pb` for direct protobuf access or conversion helpers.
## License
Apache-2.0.
|