| Crates.io | a2a-rs |
| lib.rs | a2a-rs |
| version | 0.1.0 |
| created_at | 2025-05-31 17:47:40.046416+00 |
| updated_at | 2025-05-31 17:47:40.046416+00 |
| description | Rust implementation of the Agent-to-Agent (A2A) Protocol |
| homepage | |
| repository | https://github.com/emillindfors/a2a-rs |
| max_upload_size | |
| id | 1696514 |
| size | 594,226 |
A Rust implementation of the Agent-to-Agent (A2A) Protocol, providing a type-safe, idiomatic way to build agent communication systems.
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"] }
# Full feature set
a2a-rs = { version = "0.1.0", features = ["full"] }
use a2a_rs::{HttpClient, Message};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = HttpClient::new("https://api.example.com".to_string());
let message = Message::user_text("Hello, agent!".to_string());
let task = client.send_task_message("task-123", &message, None, None).await?;
println!("Task created: {:?}", task);
Ok(())
}
use a2a_rs::{HttpServer, Message, Task, A2AError};
use a2a_rs::port::{AsyncTaskHandler, AgentInfoProvider};
struct MyAgent;
#[async_trait::async_trait]
impl AsyncTaskHandler for MyAgent {
async fn handle_message(
&self,
task_id: &str,
message: &Message,
session_id: Option<&str>,
) -> Result<Task, A2AError> {
// Process the message and return updated task
Ok(Task::new(task_id.to_string()))
}
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let server = HttpServer::new(
MyAgent,
AgentInfo::default(),
"127.0.0.1:8080".to_string(),
);
server.start().await?;
Ok(())
}
This library follows a hexagonal architecture pattern:
client - Client-side functionalityserver - Server-side functionalityhttp-client - HTTP client implementationhttp-server - HTTP server implementationws-client - WebSocket client implementationws-server - WebSocket server implementationauth - Authentication support (JWT, OAuth2, OpenID Connect)sqlx-storage - SQLx-based persistent storagesqlite - SQLite database supportpostgres - PostgreSQL database supportmysql - MySQL database supporttracing - Structured logging and tracingfull - All features enabledSee the examples directory for complete working examples:
Full API documentation is available on docs.rs.
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.