mcpA2aBridge

fun mcpA2aBridge(clientFor: (Request) -> A2AClient, random: Random = SecureRandom()): ServerCapability(source)

Exposes an A2A agent as a set of MCP tools (send_message, get_task, cancel_task, list_tasks), suitable for composing into any http4k MCP server. The agent's card is fetched eagerly (with an empty request, so any caller-provided auth wiring runs with no Authorization header) so the skill catalog can be folded into the send_message tool description — fails fast if the card cannot be retrieved.

clientFor is invoked per tool call with the inbound MCP HTTP request, so the caller controls how each per-call A2A client is built (e.g. forwarding the caller's Authorization header).


fun mcpA2aBridge(client: A2AClient, random: Random = SecureRandom()): ServerCapability(source)

Convenience overload for a fixed pre-built A2AClient — every tool call goes out under the same credentials baked into the client. Use the clientFor form if you need per-call auth.


fun <T> mcpA2aBridge(baseUri: Uri, http: HttpHandler = JavaHttpClient(responseBodyMode = Stream), tenant: Tenant? = null, protocolVersion: ProtocolVersion = LATEST_VERSION, random: Random = SecureRandom(), authLens: LensInjectorExtractor<Request, T?>): ServerCapability(source)

Convenience overload that forwards the inbound MCP request's Authorization header to the A2A agent. The agent card is fetched without auth (typically .well-known/ is public).