| Crates.io | anet_a2a_server |
| lib.rs | anet_a2a_server |
| version | 0.1.0 |
| created_at | 2025-04-18 07:27:18.801783+00 |
| updated_at | 2025-04-18 07:27:18.801783+00 |
| description | A Rust framework for building Agent-to-Agent (A2A) protocol services |
| homepage | |
| repository | https://github.com/marekkucak/anet_a2a_server |
| max_upload_size | |
| id | 1638955 |
| size | 155,511 |
A Rust implementation of the Agent-to-Agent (A2A) protocol, designed for building agent services that can communicate with each other using a task-based approach.
The A2A Framework provides a foundation for implementing agent services that can:
The framework is built with a modular architecture, allowing for different transport mechanisms and storage backends, with NATS for transport and optional Redis for persistence.
The framework consists of several key components:
Add the dependency to your Cargo.toml:
[dependencies]
a2a-framework = "0.1.0"
use std::time::Duration;
use anyhow::Result;
use tokio::runtime::Runtime;
use uuid::Uuid;
use a2a_framework::{NatsTransportFactory, ServerBuilder};
fn main() -> Result<()> {
// Initialize logging
env_logger::init();
// Create server with NATS transport and in-memory task manager
let server = ServerBuilder::new()
.with_agent_name("Example Agent")
.with_agent_description("An example A2A agent")
.with_transport_factory(NatsTransportFactory::new(
"nats://localhost:4222",
"a2a.agent",
Duration::from_secs(5),
))
.build()?;
// Run server until shutdown signal (Ctrl+C)
server.run_until_shutdown()?;
Ok(())
}
use std::time::Duration;
use anyhow::Result;
use uuid::Uuid;
use a2a_framework::{
NatsTransportFactory,
ServerBuilder,
RedisTaskManager,
AgentCard
};
fn main() -> Result<()> {
// Initialize logging
env_logger::init();
// Create agent card
let agent = AgentCard {
id: Uuid::new_v4(),
name: "Redis-backed A2A Agent".to_string(),
description: "An example A2A agent with Redis persistence".to_string(),
metadata: None,
version: Some(env!("CARGO_PKG_VERSION").to_string()),
};
// Create Redis task manager
let task_manager = RedisTaskManager::new(
"redis://localhost:6379",
agent
)?;
// Create tokio runtime
let runtime = tokio::runtime::Runtime::new()?;
// Create server with NATS transport and Redis task manager
let server = ServerBuilder::new()
.with_task_manager(task_manager)
.with_transport_factory(NatsTransportFactory::new(
"nats://localhost:4222",
"a2a.agent",
Duration::from_secs(5),
))
.with_runtime(runtime)
.build()?;
// Run server until shutdown signal
server.run_until_shutdown()?;
Ok(())
}
See the examples/test_client.rs file for a complete example of a client that interacts with an A2A server.
The A2A framework implements the following protocol methods:
agents/getInfo: Get information about the agenttasks/create: Create a new tasktasks/get: Get a task by IDtasks/send: Process a task and get the resulttasks/sendSubscribe: Process a task with streaming eventstasks/cancel: Cancel a taskThe framework currently supports two storage backends:
In-Memory Storage (default)
Redis Storage
This project is licensed under the MIT License - see the LICENSE file for details.