Package org.a2aproject.sdk.client.http
Class A2ACardResolver
java.lang.Object
org.a2aproject.sdk.client.http.A2ACardResolver
Utility for fetching agent cards from A2A agents.
Retrieves agent cards from the standard /.well-known/agent-card.json endpoint
with support for tenant-specific paths and authentication headers.
Features
- Standard agent card endpoint discovery (
/.well-known/agent-card.json) - Tenant-specific path support (
/tenant/.well-known/agent-card.json) - Custom card path support for non-standard agent card locations
- Custom authentication header injection
- Pluggable HTTP client via
A2AHttpClientFactory
Usage Examples
// Basic usage - fetch the agent card from a base URL
A2ACardResolver resolver = A2ACardResolver.builder()
.baseUrl("http://localhost:9999")
.build();
AgentCard card = resolver.getAgentCard();
// With tenant path
A2ACardResolver resolver = A2ACardResolver.builder()
.baseUrl("http://localhost:9999")
.tenant("my-tenant")
.build();
AgentCard card = resolver.getAgentCard();
// With custom HTTP client and authentication
A2AHttpClient httpClient = A2AHttpClientFactory.create();
A2ACardResolver resolver = A2ACardResolver.builder()
.httpClient(httpClient)
.baseUrl("http://localhost:9999")
.tenant("my-tenant")
.authHeader("Authorization", "Bearer token")
.build();
AgentCard card = resolver.getAgentCard();
// With a custom agent card path
A2ACardResolver resolver = A2ACardResolver.builder()
.baseUrl("http://localhost:9999")
.agentCardPath("/custom/agent.json")
.build();
AgentCard card = resolver.getAgentCard();
// Using a complete URL (e.g., with path prefix like /spec03)
A2ACardResolver resolver = A2ACardResolver.builder()
.baseUrl("https://example.com/spec03")
.build();
AgentCard card = resolver.getAgentCard();
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for creating A2ACardResolver instances with a fluent API. -
Method Summary
Modifier and TypeMethodDescriptionstatic A2ACardResolver.Builderbuilder()Creates a new builder for constructing an A2ACardResolver.Fetches the agent card for this resolver's configured agent.
-
Method Details
-
builder
Creates a new builder for constructing an A2ACardResolver.- Returns:
- a new builder instance
-
getAgentCard
Fetches the agent card for this resolver's configured agent.Fetches from the custom
agentCardPathwhen one was supplied, otherwise fetches from the standard/.well-known/agent-card.jsonendpoint. No automatic fallback is performed; errors are propagated directly to the caller.- Returns:
- the agent card
- Throws:
A2AClientHTTPError- If the server returns a non-2xx response (carries status, body, and headers)A2AClientError- If a network error occurs fetching the cardA2AClientJSONError- If the response body cannot be decoded as JSON or validated against the AgentCard schema
-