Implementation:A2aproject A2a java AgentCard Validation Resolution
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Server, Validation, Caching, Multitenancy |
| Last Updated | 2026-10-30 00:00 GMT |
Overview
Concrete server-side agent card validation, resolution, request preflight, and caching infrastructure for transport validation, capability checks, and HTTP cache header generation.
Description
This implementation page groups the server-side agent card infrastructure:
- AgentCardValidator: Validates agent card transport configuration against available transport endpoints on the classpath. Logs warnings for missing transports, errors for unsupported. Supports per-transport skip properties and cached validation via `ConcurrentHashMap`.
- AgentCardResolver: Selects the effective agent card (public or extended) for a given tenant. Uses AgentCardRouter for multitenant card resolution. Falls back through public → extended → router-resolved cards.
- AgentCardRequestPolicy: Shared v1 request preflight validation — resolves the card, validates transport, validates protocol version and required extensions, checks capability, and attaches the effective card to the ServerCallContext.
- AgentCardCacheMetadata: CDI bean computing HTTP caching headers (Cache-Control, ETag via MD5, Last-Modified) for the agent card endpoint per A2A spec section 8.6. Configurable max-age via `a2a.agent-card.cache.max-age` (default 3600s).
Usage
- Startup validation: AgentCardValidator validates cards at server startup against classpath transports
- Per-request resolution: AgentCardRequestPolicy.preflight() is called by transport handlers before processing each request
- Multitenancy: AgentCardResolver + AgentCardRouter resolve tenant-specific cards
- HTTP caching: AgentCardCacheMetadata provides ETag and Cache-Control headers for conditional GET
Code Reference
Source Location
- Repository: a2a-java
- Files:
- `server-common/src/main/java/org/a2aproject/sdk/server/AgentCardValidator.java` (L21-187)
- `server-common/src/main/java/org/a2aproject/sdk/server/AgentCardResolver.java` (L13-105)
- `server-common/src/main/java/org/a2aproject/sdk/server/AgentCardRequestPolicy.java` (L13-69)
- `server-common/src/main/java/org/a2aproject/sdk/server/AgentCardCacheMetadata.java` (L46-190)
Signature
// Validates transport configuration against classpath
public final class AgentCardValidator {
public static ConcurrentMap<AgentCard, Boolean> newValidatedCardsMap();
public static void validateOnce(AgentCard card, ConcurrentMap<AgentCard, Boolean> cache,
Consumer<AgentCard> validator);
public void validate(AgentCard card);
}
// Selects effective card for tenant
public final class AgentCardResolver {
public static AgentCardResolver of(Supplier<@Nullable AgentCard> publicCard,
Supplier<@Nullable AgentCard> extendedCard,
@Nullable AgentCardRouter router);
public AgentCard resolveEffectiveCard(@Nullable String tenant);
public static @Nullable String normalizeTenantForResolution(@Nullable String tenant);
}
// Per-request preflight validation
public final class AgentCardRequestPolicy {
public AgentCardRequestPolicy(AgentCardResolver resolver);
public EffectiveAgentCard preflight(@Nullable String tenant, ServerCallContext context,
AgentCardTransportValidator validator, AgentCardOperation operation);
}
// HTTP cache headers
@ApplicationScoped
public class AgentCardCacheMetadata {
// Computes ETag (MD5), Cache-Control (max-age), Last-Modified at init
}
Import
import org.a2aproject.sdk.server.AgentCardValidator;
import org.a2aproject.sdk.server.AgentCardResolver;
import org.a2aproject.sdk.server.AgentCardRequestPolicy;
import org.a2aproject.sdk.server.AgentCardCacheMetadata;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| card | AgentCard | Yes | Card to validate/resolve |
| tenant | String | No | Tenant identifier |
| context | ServerCallContext | Yes (policy) | Request context |
| operation | AgentCardOperation | Yes (policy) | Capability check |
Outputs
| Name | Type | Description |
|---|---|---|
| preflight returns | EffectiveAgentCard | Resolved and attached card |
| resolveEffectiveCard returns | AgentCard | Tenant-resolved card |
| Cache headers | ETag, Cache-Control | HTTP response headers |
Usage Examples
Request Preflight in Transport Handler
import org.a2aproject.sdk.server.AgentCardRequestPolicy;
import org.a2aproject.sdk.server.AgentCardOperation;
// In a transport handler before processing:
EffectiveAgentCard effective = policy.preflight(
tenant, context,
AgentCardValidator::new,
AgentCardOperation.SEND_MESSAGE);
// Now context.getEffectiveAgentCard() returns the resolved card
Multitenant Card Resolution
import org.a2aproject.sdk.server.AgentCardResolver;
AgentCardResolver resolver = AgentCardResolver.of(
() -> publicCard, // default public card supplier
() -> extendedCard, // default extended card supplier
tenantRouter // multitenant router
);
AgentCard card = resolver.resolveEffectiveCard("tenant-123");
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment