Skip to main content

Crate a2a_rs_server

Crate a2a_rs_server 

Source
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
AuthContext
Authentication context passed to handlers
EchoHandler
A simple echo handler for testing and demos
RetryConfig
ServerConfig
StoredWebhookConfig
Stored webhook configuration with ID
TaskStore
Thread-safe in-memory task store
WebhookDelivery
WebhookStore
Thread-safe in-memory webhook configuration store

Enums§

HandlerError
Error type for handler operations
WebhookError

Traits§

MessageHandler
Trait for implementing A2A message handlers

Functions§

run_echo_server
run_server

Type Aliases§

AuthExtractor
BoxedHandler
Type alias for a boxed handler
HandlerResult
Result type for handler operations