Expand description
A2A Server Library
This library provides a generic, pluggable A2A RC 1.0 compliant JSON-RPC server
framework. Implement the MessageHandler trait to create your own agent backend.
§Generic Server Example
ⓘ
use a2a_rs_server::{A2aServer, MessageHandler, HandlerResult, AuthContext, EchoHandler};
use a2a_rs_core::{AgentCard, Message, Task};
use async_trait::async_trait;
// Use the built-in echo handler for demos
A2aServer::echo()
.bind("0.0.0.0:8080")
.run()
.await?;
// Or implement your own handler
struct MyAgent { /* ... */ }
#[async_trait]
impl MessageHandler for MyAgent {
async fn handle_message(
&self,
message: Message,
auth: Option<AuthContext>,
) -> HandlerResult<SendMessageResponse> {
// Process message with your backend
todo!()
}
fn agent_card(&self, base_url: &str) -> AgentCard {
// Return your agent's card
todo!()
}
}
A2aServer::new(MyAgent { /* ... */ })
.bind("0.0.0.0:8080")
.auth_extractor(|headers| {
// Extract auth from headers
None
})
.run()
.await?;Structs§
- A2aServer
- AppState
- Auth
Context - Authentication context passed to handlers
- Echo
Handler - A simple echo handler for testing and demos
- Retry
Config - Server
Config - Stored
Webhook Config - Stored webhook configuration with ID
- Task
Store - Thread-safe in-memory task store
- Webhook
Delivery - Webhook
Store - Thread-safe in-memory webhook configuration store
Enums§
- Handler
Error - Error type for handler operations
- Webhook
Error
Traits§
- Message
Handler - Trait for implementing A2A message handlers
Functions§
Type Aliases§
- Auth
Extractor - Boxed
Handler - Type alias for a boxed handler
- Handler
Result - Result type for handler operations