A comprehensive Rust implementation of the Agent-to-Agent (A2A) Protocol, providing both a robust framework library and practical agent examples. This project demonstrates production-ready agent communication with modern Rust practices and hexagonal architecture.
See the A2A protocol in action with our reimbursement agent - a complete example that handles expense reimbursement requests:
# Clone the repository
git clone https://github.com/emillindfors/a2a-rs.git
cd a2a-rs
# Run the reimbursement agent
cd a2a-agents
cargo run --bin reimbursement_server
The reimbursement agent showcases:
- π¬ Interactive conversations with users about expenses
- π Dynamic form generation for expense submissions
- β Request validation and approval workflows
- π Structured responses with proper task state management
- π Real-time updates via the A2A protocol
Try it out: Send a POST request to http://localhost:3030/sendMessage
with a reimbursement question!
This repository contains a complete A2A ecosystem:
π¦ a2a-rs - Core Framework Library
The main library published on crates.io:
- π Complete A2A Protocol Implementation
- π HTTP & WebSocket Support with streaming
- ποΈ Hexagonal Architecture with clean separation
- π§© Modular Features - use only what you need
- π Comprehensive Documentation with examples
π€ a2a-agents - Production Agent Examples
Real-world agent implementations demonstrating best practices:
- π° Reimbursement Agent - Handles expense requests with interactive workflows
- π§ Modern Architecture using the a2a-rs framework
- π Full Documentation with setup guides
π a2a-mcp - MCP Integration
Bridges A2A agents with the Model Context Protocol ecosystem:
- π Bidirectional Integration - A2A agents as MCP tools and vice versa
- π Protocol Translation between A2A and MCP formats
- π οΈ Developer Tools for cross-protocol communication
π» a2a-client - Web Interface
Browser-based client for interacting with A2A agents:
- π Web UI for agent communication
- π¬ Chat Interface with real-time updates
- π± Responsive Design for all devices
- Type-Safe Protocol - Rust's type system ensures protocol compliance
- Async-First Design - Built on Tokio with full async/await support
- Multiple Transports - HTTP, WebSocket with automatic fallback
- Streaming Support - Real-time task updates and progress tracking
- Authentication - JWT, OAuth2, OpenID Connect, API keys
- Storage Backends - SQLx integration for PostgreSQL, MySQL, SQLite
- Observability - Structured logging and tracing throughout
- Production Ready - Complete implementations following best practices
- Interactive Workflows - Dynamic form generation and multi-step processes
- Business Logic Examples - Real use cases like expense reimbursement
- Framework Integration - Shows how to use a2a-rs effectively
- Comprehensive Documentation - API docs, guides, and examples
- Working Examples - Copy-paste code that actually works
- Test Coverage - Integration tests and property-based testing
- Error Handling - Structured errors with helpful messages
Add to your Cargo.toml
:
[dependencies]
a2a-rs = "0.1.0"
# For HTTP client
a2a-rs = { version = "0.1.0", features = ["http-client"] }
# For HTTP server
a2a-rs = { version = "0.1.0", features = ["http-server"] }
# Everything
a2a-rs = { version = "0.1.0", features = ["full"] }
use a2a_rs::{HttpClient, Message};
use a2a_rs::port::AsyncA2AClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = HttpClient::new("http://localhost:3030".to_string());
let message = Message::user_text("I need to submit a $50 lunch expense".to_string());
let task = client.send_task_message("task-123", &message, None, None).await?;
println!("Response: {:?}", task);
Ok(())
}
use a2a_rs::{HttpServer, SimpleAgentInfo, DefaultRequestProcessor};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let server = HttpServer::new(
DefaultRequestProcessor::new(),
SimpleAgentInfo::new("my-agent".to_string(), "1.0.0".to_string()),
"127.0.0.1:3030".to_string(),
);
server.start().await?;
Ok(())
}
use a2a_rs::{WebSocketClient, Message};
use a2a_rs::services::StreamItem;
use futures::StreamExt;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = WebSocketClient::new("ws://localhost:3030/ws".to_string());
let message = Message::user_text("Process my reimbursement request".to_string());
let mut stream = client.subscribe_to_task("task-456", &message, None, None).await?;
while let Some(result) = stream.next().await {
match result? {
StreamItem::Task(task) => println!("Initial task: {:?}", task),
StreamItem::StatusUpdate(update) => {
println!("Status: {:?}", update);
if update.final_ { break; }
}
StreamItem::ArtifactUpdate(artifact) => {
println!("New artifact: {:?}", artifact);
}
}
}
Ok(())
}
The project follows hexagonal architecture principles:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Application Layer β
β βββββββββββββββββββ βββββββββββββββββββββββββββββββ β
β β JSON-RPC β β HTTP/WebSocket β β
β β Handlers β β Transport β β
β βββββββββββββββββββ βββββββββββββββββββββββββββββββ β
βββββββββββββββββββ¬ββββββββββββββββββββββββ¬ββββββββββββββββ
β β
βββββββββββββββββββΌββββββββββββββββββββββββΌββββββββββββββββ
β Port Layer β
β ββββββββββββββββββββ ββββββββββββββββββββββββββββ β
β β MessageHandler β β StreamingHandler β β
β β TaskManager β β NotificationManager β β
β β Authenticator β β RequestProcessor β β
β ββββββββββββββββββββ ββββββββββββββββββββββββββββ β
βββββββββββββββββββ¬ββββββββββββββββββββββββ¬ββββββββββββββββ
β β
βββββββββββββββββββΌββββββββββββββββββββββββΌββββββββββββββββ
β Domain Layer β
β ββββββββββββββββ ββββββββββββββββ βββββββββββββββββββ β
β β Message β β Task β β AgentCard β β
β β Artifact β β TaskStatus β β Capabilities β β
β β Part β β History β β Skills β β
β ββββββββββββββββ ββββββββββββββββ βββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Core Library Docs - Complete API documentation
- Reimbursement Agent Guide - Building production agents
- MCP Integration Guide - Cross-protocol communication
- Web Client Setup - Browser-based interfaces
# Test the core library
cd a2a-rs && cargo test --all-features
# Test agent examples
cd a2a-agents && cargo test
# Test MCP integration
cd a2a-mcp && cargo test
# Run integration tests
cargo test --workspace
- Core Protocol - Complete A2A specification implementation
- Documentation - Comprehensive docs and examples
- Agent Examples - Production-ready reimbursement agent
- MCP Integration - Cross-protocol compatibility
- More Agent Types - Additional domain examples
- Performance Optimization - Benchmarking and improvements
- Advanced Auth - Enterprise authentication patterns
We welcome contributions! Please see our Contributing Guide for details.
git clone https://github.com/emillindfors/a2a-rs.git
cd a2a-rs
cargo build --workspace
cargo test --workspace
This project is licensed under the MIT License - see the LICENSE file for details.
Built with a2a-rs? We'd love to feature your project! Open an issue to let us know.
Ready to build intelligent agents? Start with our reimbursement agent example or dive into the core library documentation!