a2a.server.apps.rest package¶
Submodules¶
a2a.server.apps.rest.fastapi_app module¶
- class a2a.server.apps.rest.fastapi_app.A2ARESTFastAPIApplication(agent_card: AgentCard, http_handler: RequestHandler, context_builder: CallContextBuilder | None = None)¶
Bases:
object
A FastAPI application implementing the A2A protocol server REST endpoints.
Handles incoming REST requests, routes them to the appropriate handler methods, and manages response generation including Server-Sent Events (SSE).
- build(agent_card_url: str = '/.well-known/agent-card.json', rpc_url: str = '', **kwargs: Any) FastAPI ¶
Builds and returns the FastAPI application instance.
- Parameters:
agent_card_url – The URL for the agent card endpoint.
rpc_url – The URL for the A2A JSON-RPC endpoint.
extended_agent_card_url – The URL for the authenticated extended agent card endpoint.
**kwargs – Additional keyword arguments to pass to the FastAPI constructor.
- Returns:
A configured FastAPI application instance.
a2a.server.apps.rest.rest_adapter module¶
- class a2a.server.apps.rest.rest_adapter.RESTAdapter(agent_card: AgentCard, http_handler: RequestHandler, context_builder: CallContextBuilder | None = None)¶
Bases:
object
Adapter to make RequestHandler work with RESTful API.
Defines REST requests processors and the routes to attach them too, as well as manages response generation including Server-Sent Events (SSE).
- async handle_authenticated_agent_card(request: Request) JSONResponse ¶
Hook for per credential agent card response.
If a dynamic card is needed based on the credentials provided in the request override this method and return the customized content.
- Parameters:
request – The incoming Starlette Request object.
- Returns:
A JSONResponse containing the authenticated card.
- async handle_get_agent_card(request: Request) JSONResponse ¶
Handles GET requests for the agent card endpoint.
- Parameters:
request – The incoming Starlette Request object.
- Returns:
A JSONResponse containing the agent card data.
- routes() dict[tuple[str, str], Callable[[Request], Any]] ¶
Constructs a dictionary of API routes and their corresponding handlers.
This method maps URL paths and HTTP methods to the appropriate handler functions from the RESTHandler. It can be used by a web framework (like Starlette or FastAPI) to set up the application’s endpoints.
- Returns:
A dictionary where each key is a tuple of (path, http_method) and the value is the callable handler for that route.
Module contents¶
A2A REST Applications.
- class a2a.server.apps.rest.A2ARESTFastAPIApplication(agent_card: AgentCard, http_handler: RequestHandler, context_builder: CallContextBuilder | None = None)¶
Bases:
object
A FastAPI application implementing the A2A protocol server REST endpoints.
Handles incoming REST requests, routes them to the appropriate handler methods, and manages response generation including Server-Sent Events (SSE).
- build(agent_card_url: str = '/.well-known/agent-card.json', rpc_url: str = '', **kwargs: Any) FastAPI ¶
Builds and returns the FastAPI application instance.
- Parameters:
agent_card_url – The URL for the agent card endpoint.
rpc_url – The URL for the A2A JSON-RPC endpoint.
extended_agent_card_url – The URL for the authenticated extended agent card endpoint.
**kwargs – Additional keyword arguments to pass to the FastAPI constructor.
- Returns:
A configured FastAPI application instance.