The A2A JSON-RPC bridge - `sdk/src/a2a.rs`. The adapter (submit / task / cancel / Agent Card, riding the typed AGDX verbs) is behind the `a2a-bridge` feature (serde only, no HTTP). The ready-made axum `router()` is behind the additive `a2a-http` feature. Use when changing the A2A task lifecycle (TaskState), the JSON-RPC envelope, the adapter, the router, or the mapping from A2A methods onto agent topics. Sibling: the MCP bridge `McpBridge` in `sdk/src/mcp.rs` (`mcp-bridge` adapter, `mcp-http`...
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of A2a Bridge?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/laserdata-a2a-bridge)
---
name: a2a-bridge
description: The A2A JSON-RPC bridge - `sdk/src/a2a.rs`. The adapter (submit / task / cancel / Agent Card, riding the typed AGDX verbs) is behind the `a2a-bridge` feature (serde only, no HTTP). The ready-made axum `router()` is behind the additive `a2a-http` feature. Use when changing the A2A task lifecycle (TaskState), the JSON-RPC envelope, the adapter, the router, or the mapping from A2A methods onto agent topics. Sibling: the MCP bridge `McpBridge` in `sdk/src/mcp.rs` (`mcp-bridge` adapter, `mcp-http` router).
---
# A2A bridge
The TypeScript A2A, MCP, AG-UI, and hop-guard peers live under `foreign/typescript/src/bridges` and share the cross-language bridge scenarios. Python binds the same bridges as classes: `A2aBridge(laser, source, request_topic, reply_topic, capabilities=, signing_key=, target=, public_url=, description=, version=)` with `signed_card(key)`, and `McpBridge(laser, source, tool_topic, reply_topic, server_name, memory_tools=False, timeout_ms=None, signing_key=, target=)`, matching Rust `with_capabilities`, `with_signing_key`, `with_target`, `with_public_url`, `with_description`, `with_version`, `signed_card`, `with_memory_tools`, and `with_timeout` (default 30 seconds). The Go peers live under `foreign/go/bridges`.
`a2a.rs` maps A2A requests to durable AGDX records. `a2a-bridge` enables the transport-independent `submit`, `task`, `cancel`, and `card` adapter. `handle_rpc` dispatches JSON-RPC requests without HTTP. `a2a-http` adds the axum `router()`. Neither feature is enabled by default. Load [laser-sdk-overview](../laser-sdk-overview/SKILL.md) first and follow [AGENTS.md](../../../AGENTS.md).
## STOP and ask the user before
- Changing the task-state dictionary: `TaskState` is the laser-wire agent dictionary (`wire/src/agent.rs`, pinned u8 codes), only re-exported here. The JSON boundary (`task_state_json` in `a2a.rs`, `a2aStateName` in TypeScript) maps codes to the A2A v1.0 `TASK_STATE_*` names external clients match (paused reads as working, unknown and unrecognized codes as unspecified), and an unknown inbound name is a protocol error.
- Changing the topic mapping (`SendMessage` -> request topic keyed by a fresh task conversation. `GetTask` -> replay of the reply topic).
## Key symbols
- `TaskState` (re-exported from `laser_wire::agent`: submitted, working, input-required, completed, canceled, failed, rejected, auth-required, unknown, paused, plus unknown-code passthrough), `Task { id, context_id, status, artifacts }`, `TaskStatus`, `Artifact { artifact_id, parts }`, `Part { text }`, the A2A v1.0 shapes.
- `A2aMethod` (`SendMessage`, `SendStreamingMessage`, `GetTask`, `CancelTask` - the v1.0 PascalCase spellings) - the served methods as an enum with `Display`/`FromStr` (strum). Dispatch parses `request.method` into it, never match on bare method-name string literals. `ListTasks` is not served (stateless over the log) and answers `-32601`. `SendStreamingMessage` answers `-32004` because the card does not advertise streaming (chunk streams are consumed log-natively via `Laser::reassemble_channel`).
- `JsonRpcRequest` / `JsonRpcResponse` / `JsonRpcError` - the 2.0 envelope. The internal `A2aFault` maps every refusal to a named code const: `-32600`, `-32601`, `-32602`, `-32603`, and the A2A `-32001` task not found, `-32002` task not cancelable, `-32004` unsupported operation.
- `AgentCard` / `AgentCardCapabilities` - the bridge's discovery doc (name = `source`, description and version from `with_description`/`with_version`, the interface URL from `with_public_url`, `streaming: false`). `card()` is a `Result` that fails until the public URL is set.
- `A2aBridge::new(laser, source, request_topic, reply_topic)` - rides the typed AGDX verbs (`Laser::agdx`), not raw `send_agent`:
- `submit(params_json) -> Task` (`SendMessage`): publish a typed AGDX `command` tunneling the whole params JSON byte-identical (`agdx.ct = json`) on a fresh task conversation, signed with the `with_signing_key` key when set. The task identity rides `correlation`, derived from the conversation via `correlation_of` so lookup stays stateless. Returns `Submitted`. The command is addressed to the `with_target` agent, else to every agent (`agdx.to = *`). `submit_to(target, params_json)` addresses it to one agent, so only that agent handles it on a shared session topic. Over JSON-RPC a `message.taskId` continues that task in its conversation with the same correlation and the original target.
- `task(id) -> Task` (`GetTask`): scan the topics forward from the task id's ULID time less five minutes (`PollingStrategy::timestamp`, 32 bounded passes per partition), take the bridge's own command (source, and with a signing key its key id) and the answering `response`/`error` envelopes with the matching `correlation`. Under a verifier only an answer signed by the command's target (or the bridge's own cancel) counts. An unaddressed command is a broadcast, so an answer from any enrolled signer counts by definition. The first terminal answer settles the task, else the latest in progress, else `Working`. No command and no answer is an unknown task (`HandlerConfig`, `-32001` over JSON-RPC).
- `cancel(id) -> Task` (`CancelTask`): publish an AGDX `error` terminal (`Cancelled`, `task_state = Canceled`) for a task still in progress, returns `Canceled`. A task that already ended is `Rejected` (`-32002` over JSON-RPC).
- `submit_with_hops(previous, target, params_json)`: `submit` carrying the hop path of the work it came from. The JSON-RPC path reads that path from `params.metadata["laserdata.com/bridge_hops"]` (`BRIDGE_HOPS_META_KEY`). A path holding this bridge is refused before publishing.
- `submit_in(parent, root, params_json) -> Task`: `submit` as a child session of `parent` in the tree rooted at `root`. It writes the child's submitted start on `agent.sessions` with the ancestry before the command and stamps the ancestry on the command. The handling agent ends the child. Python takes `submit_in(parent, params_json, *, root=)`, TypeScript `submitIn`. `McpBridge::call_tool_in(parent, root, name, params_json)` is the MCP peer, and it ends the child by the tool result. `submit_in_to(target, parent, root, params_json)`, `McpBridge::call_tool_to(target, name, params_json)`, and `call_tool_in_to(target, ..)` are the addressed forms. Python takes `target=` on `submit`, `submit_in`, `call_tool`, and `call_tool_in`, and TypeScript a `{ target }` option. `handle_rpc` and `router()` address the `with_target` agent.
- `card() -> Result<AgentCard, LaserError>`: served at `GET /.well-known/agent-card.json`, signed with the bridge's key when it has one, 404 until the public URL is set.
- `router() -> axum::Router` (requires `a2a-http`): the JSON-RPC endpoint at `POST /` plus the card route. The adapter above is usable without it (serve it over any transport, or call `submit` / `task` / `cancel` directly).
- A worker behind the bridge reads `message.envelope` (the decoded command) and answers via `ctx.respond(..)`, or `ctx.laser().agdx(reply_topic, source, conversation).respond(correlation, body)` addressed to the bridge with `with_target`. Address every reply to its requester, as `ctx.respond` does, because shared-topic readers classify records by `agdx.to`.
## Rules specific to this area
- The bridge owns no state: truth is the log. `submit`/`task` are pure functions over `Laser`, so the HTTP layer (`router`) is a thin shell and is testable by calling `submit`/`task` directly against Apache Iggy.
- A bridge uses the stream selected by its `Laser` handle. Use `laser.with_default_stream(name)` to share one connection across stream-scoped views. Use separate connections for separate credentials. MCP reply waits use `AgentReplyReader` and `Laser::await_agdx_reply` with the target bound as `expected_signer`. The A2A task lookup is its own bounded scan from the task's minted time. Avoid repeated full scans for an active reply wait.
- `authorize_edge` in `sdk/src/edge_auth.rs` checks token audience and required scopes. `EdgeDenial::StepUp` reports additional scope through `WWW-Authenticate`. Do not forward external tokens to the log. `sign::verify_delegation` binds `on_behalf_of` to the signed envelope, checked against the observed headers and the key's validity at the record time. The server does not enforce delegation, so the application authorizes with `laser_wire::authz::delegated_allow`, which intersects agent and invoking-user grants.
- Keep model calls and business logic out of the bridge. It only translates the protocol to topic sends and log replays.
## Testing
- Pure types (the `TaskStatus` JSON boundary, JSON-RPC parsing) are unit-tested in `a2a.rs`, and the dictionary itself is tested and fixtured in laser-wire.
- The Iggy-backed flow lives in `tests/integration/a2a.rs` (gated on the feature). Run with `cargo test -p laser-sdk --features "integration a2a-bridge query"`.
## Review smells
- Business logic or model calls leaking into the bridge handlers.
- A `TaskState` or `A2aMethod` wire name drifting from the A2A spelling.
- A bare method-name string literal in the dispatch instead of `A2aMethod`.
- The router holding task state instead of replaying the log.
Both `A2aBridge` and `McpBridge` expose `handle_rpc(JsonValue)` on their adapter features. Python binds it as `handle_rpc(request)` and TypeScript as `handleRpc(input)`. `McpBridge::handle_rpc` returns `Option`: a notification (no `id`) gets no response, and the MCP router answers it 202 with no body. Both routers share the browser origin guard in `sdk/src/bridge_origin.rs` (`origin_allowed`): no `Origin` (a non-browser client) passes, an origin in `with_allowed_origins` passes, a same-origin page passes only on an IP-literal or `localhost` `Host` (a rebound page sends its own name as both origin and host, so a same-origin rule on names would pass it), everything else is 403. The A2A card path is public and unguarded. Python `serve` runs the same axum routers inside the binding: no pip dependency, but the binding crate depends on axum and tokio `net`, which link into the native module. TypeScript `serve` (`src/bridges/http.ts`, Node `http`, no new npm dependency) ports the routes, the axum answers (415 for a non-JSON content type, 400 for a malformed body, 413 over 2 MiB, 405, 404) and `originAllowed`, which must stay identical to `origin_allowed`. Both return a `BridgeServer`, take `allowed_origins=` / `withAllowedOrigins`, and the A2A `serve` takes a `caller` hook that names the `A2aCallerPrincipal` for `POST /` (401 when it throws). The MCP router also refuses an unsupported `MCP-Protocol-Version` with 400. MCP `initialize` negotiates among `MCP_SUPPORTED_PROTOCOL_VERSIONS`, `ping` answers `{}`, an unadvertised tool or unknown prompt answers `-32602`, an unknown resource `-32002`. Python `A2aBridge.submit(params_json)` and `McpBridge.call_tool(name, params_json)` take raw JSON, as do TypeScript `submit` and `callTool(name, bytes)`. HTTP routes delegate to this dispatch. Every bridge stamps its own ID in `bridge_hops`, `with_bridge_hops` continues a previous path for the whole bridge, and `submit_with_hops`, `call_tool_with_hops` and the `laserdata.com/bridge_hops` request metadata continue it per call, all rejecting loops.