a2a.server.apps.jsonrpc package¶
Submodules¶
a2a.server.apps.jsonrpc.fastapi_app module¶
- class a2a.server.apps.jsonrpc.fastapi_app.A2AFastAPIApplication(agent_card: AgentCard, http_handler: RequestHandler, extended_agent_card: AgentCard | None = None, context_builder: CallContextBuilder | None = None, card_modifier: Callable[[AgentCard], AgentCard] | None = None, extended_card_modifier: Callable[[AgentCard, ServerCallContext], AgentCard] | None = None)¶
Bases:
JSONRPCApplication
A FastAPI application implementing the A2A protocol server endpoints.
Handles incoming JSON-RPC requests, routes them to the appropriate handler methods, and manages response generation including Server-Sent Events (SSE).
- add_routes_to_app(app: FastAPI, agent_card_url: str = '/.well-known/agent-card.json', rpc_url: str = '/', extended_agent_card_url: str = '/agent/authenticatedExtendedCard') None ¶
Adds the routes to the FastAPI application.
- Parameters:
app – The FastAPI application to add the routes to.
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.
- build(agent_card_url: str = '/.well-known/agent-card.json', rpc_url: str = '/', extended_agent_card_url: str = '/agent/authenticatedExtendedCard', **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.jsonrpc.jsonrpc_app module¶
- class a2a.server.apps.jsonrpc.jsonrpc_app.CallContextBuilder¶
Bases:
ABC
A class for building ServerCallContexts using the Starlette Request.
- abstractmethod build(request: Request) ServerCallContext ¶
Builds a ServerCallContext from a Starlette Request.
- class a2a.server.apps.jsonrpc.jsonrpc_app.DefaultCallContextBuilder¶
Bases:
CallContextBuilder
A default implementation of CallContextBuilder.
- build(request: Request) ServerCallContext ¶
Builds a ServerCallContext from a Starlette Request.
- Parameters:
request – The incoming Starlette Request object.
- Returns:
A ServerCallContext instance populated with user and state information from the request.
- class a2a.server.apps.jsonrpc.jsonrpc_app.JSONRPCApplication(agent_card: AgentCard, http_handler: RequestHandler, extended_agent_card: AgentCard | None = None, context_builder: CallContextBuilder | None = None, card_modifier: Callable[[AgentCard], AgentCard] | None = None, extended_card_modifier: Callable[[AgentCard, ServerCallContext], AgentCard] | None = None)¶
Bases:
ABC
Base class for A2A JSONRPC applications.
Handles incoming JSON-RPC requests, routes them to the appropriate handler methods, and manages response generation including Server-Sent Events (SSE).
- abstractmethod build(agent_card_url: str = '/.well-known/agent-card.json', rpc_url: str = '/', extended_agent_card_url: str = '/agent/authenticatedExtendedCard', **kwargs: Any) FastAPI | Starlette ¶
Builds and returns the JSONRPC 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 JSONRPC application instance.
- class a2a.server.apps.jsonrpc.jsonrpc_app.StarletteUserProxy(user: BaseUser)¶
Bases:
User
Adapts the Starlette User class to the A2A user representation.
- property is_authenticated: bool¶
Returns whether the current user is authenticated.
- property user_name: str¶
Returns the user name of the current user.
a2a.server.apps.jsonrpc.starlette_app module¶
- class a2a.server.apps.jsonrpc.starlette_app.A2AStarletteApplication(agent_card: AgentCard, http_handler: RequestHandler, extended_agent_card: AgentCard | None = None, context_builder: CallContextBuilder | None = None, card_modifier: Callable[[AgentCard], AgentCard] | None = None, extended_card_modifier: Callable[[AgentCard, ServerCallContext], AgentCard] | None = None)¶
Bases:
JSONRPCApplication
A Starlette application implementing the A2A protocol server endpoints.
Handles incoming JSON-RPC requests, routes them to the appropriate handler methods, and manages response generation including Server-Sent Events (SSE).
- add_routes_to_app(app: Starlette, agent_card_url: str = '/.well-known/agent-card.json', rpc_url: str = '/', extended_agent_card_url: str = '/agent/authenticatedExtendedCard') None ¶
Adds the routes to the Starlette application.
- Parameters:
app – The Starlette application to add the routes to.
agent_card_url – The URL path for the agent card endpoint.
rpc_url – The URL path for the A2A JSON-RPC endpoint (POST requests).
extended_agent_card_url – The URL for the authenticated extended agent card endpoint.
- build(agent_card_url: str = '/.well-known/agent-card.json', rpc_url: str = '/', extended_agent_card_url: str = '/agent/authenticatedExtendedCard', **kwargs: Any) Starlette ¶
Builds and returns the Starlette application instance.
- Parameters:
agent_card_url – The URL path for the agent card endpoint.
rpc_url – The URL path for the A2A JSON-RPC endpoint (POST requests).
extended_agent_card_url – The URL for the authenticated extended agent card endpoint.
**kwargs – Additional keyword arguments to pass to the Starlette constructor.
- Returns:
A configured Starlette application instance.
- routes(agent_card_url: str = '/.well-known/agent-card.json', rpc_url: str = '/', extended_agent_card_url: str = '/agent/authenticatedExtendedCard') list[Route] ¶
Returns the Starlette Routes for handling A2A requests.
- Parameters:
agent_card_url – The URL path for the agent card endpoint.
rpc_url – The URL path for the A2A JSON-RPC endpoint (POST requests).
extended_agent_card_url – The URL for the authenticated extended agent card endpoint.
- Returns:
A list of Starlette Route objects.
Module contents¶
A2A JSON-RPC Applications.
- class a2a.server.apps.jsonrpc.A2AFastAPIApplication(agent_card: AgentCard, http_handler: RequestHandler, extended_agent_card: AgentCard | None = None, context_builder: CallContextBuilder | None = None, card_modifier: Callable[[AgentCard], AgentCard] | None = None, extended_card_modifier: Callable[[AgentCard, ServerCallContext], AgentCard] | None = None)¶
Bases:
JSONRPCApplication
A FastAPI application implementing the A2A protocol server endpoints.
Handles incoming JSON-RPC requests, routes them to the appropriate handler methods, and manages response generation including Server-Sent Events (SSE).
- add_routes_to_app(app: FastAPI, agent_card_url: str = '/.well-known/agent-card.json', rpc_url: str = '/', extended_agent_card_url: str = '/agent/authenticatedExtendedCard') None ¶
Adds the routes to the FastAPI application.
- Parameters:
app – The FastAPI application to add the routes to.
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.
- build(agent_card_url: str = '/.well-known/agent-card.json', rpc_url: str = '/', extended_agent_card_url: str = '/agent/authenticatedExtendedCard', **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.
- class a2a.server.apps.jsonrpc.A2AStarletteApplication(agent_card: AgentCard, http_handler: RequestHandler, extended_agent_card: AgentCard | None = None, context_builder: CallContextBuilder | None = None, card_modifier: Callable[[AgentCard], AgentCard] | None = None, extended_card_modifier: Callable[[AgentCard, ServerCallContext], AgentCard] | None = None)¶
Bases:
JSONRPCApplication
A Starlette application implementing the A2A protocol server endpoints.
Handles incoming JSON-RPC requests, routes them to the appropriate handler methods, and manages response generation including Server-Sent Events (SSE).
- add_routes_to_app(app: Starlette, agent_card_url: str = '/.well-known/agent-card.json', rpc_url: str = '/', extended_agent_card_url: str = '/agent/authenticatedExtendedCard') None ¶
Adds the routes to the Starlette application.
- Parameters:
app – The Starlette application to add the routes to.
agent_card_url – The URL path for the agent card endpoint.
rpc_url – The URL path for the A2A JSON-RPC endpoint (POST requests).
extended_agent_card_url – The URL for the authenticated extended agent card endpoint.
- build(agent_card_url: str = '/.well-known/agent-card.json', rpc_url: str = '/', extended_agent_card_url: str = '/agent/authenticatedExtendedCard', **kwargs: Any) Starlette ¶
Builds and returns the Starlette application instance.
- Parameters:
agent_card_url – The URL path for the agent card endpoint.
rpc_url – The URL path for the A2A JSON-RPC endpoint (POST requests).
extended_agent_card_url – The URL for the authenticated extended agent card endpoint.
**kwargs – Additional keyword arguments to pass to the Starlette constructor.
- Returns:
A configured Starlette application instance.
- routes(agent_card_url: str = '/.well-known/agent-card.json', rpc_url: str = '/', extended_agent_card_url: str = '/agent/authenticatedExtendedCard') list[Route] ¶
Returns the Starlette Routes for handling A2A requests.
- Parameters:
agent_card_url – The URL path for the agent card endpoint.
rpc_url – The URL path for the A2A JSON-RPC endpoint (POST requests).
extended_agent_card_url – The URL for the authenticated extended agent card endpoint.
- Returns:
A list of Starlette Route objects.
- class a2a.server.apps.jsonrpc.CallContextBuilder¶
Bases:
ABC
A class for building ServerCallContexts using the Starlette Request.
- abstractmethod build(request: Request) ServerCallContext ¶
Builds a ServerCallContext from a Starlette Request.
- class a2a.server.apps.jsonrpc.DefaultCallContextBuilder¶
Bases:
CallContextBuilder
A default implementation of CallContextBuilder.
- build(request: Request) ServerCallContext ¶
Builds a ServerCallContext from a Starlette Request.
- Parameters:
request – The incoming Starlette Request object.
- Returns:
A ServerCallContext instance populated with user and state information from the request.
- class a2a.server.apps.jsonrpc.JSONRPCApplication(agent_card: AgentCard, http_handler: RequestHandler, extended_agent_card: AgentCard | None = None, context_builder: CallContextBuilder | None = None, card_modifier: Callable[[AgentCard], AgentCard] | None = None, extended_card_modifier: Callable[[AgentCard, ServerCallContext], AgentCard] | None = None)¶
Bases:
ABC
Base class for A2A JSONRPC applications.
Handles incoming JSON-RPC requests, routes them to the appropriate handler methods, and manages response generation including Server-Sent Events (SSE).
- abstractmethod build(agent_card_url: str = '/.well-known/agent-card.json', rpc_url: str = '/', extended_agent_card_url: str = '/agent/authenticatedExtendedCard', **kwargs: Any) FastAPI | Starlette ¶
Builds and returns the JSONRPC 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 JSONRPC application instance.