Repository navigation
feat(a2a): HTTP+JSON/REST protocol binding beside JSON-RPC - #14
Open
brainsparker wants to merge 1 commit into
Open
brainsparker wants to merge 1 commit into
brainsparker wants to merge 1 commit into
Conversation
Serve the A2A v1.0 REST binding (spec section 11) over the same handlers and task store as the JSON-RPC endpoint: message:send, tasks get/list/ cancel, push notification config sub-resource, extendedAgentCard, with google.rpc.Status error bodies and the section 5.4 status mapping. The served card advertises an HTTP+JSON interface next to each JSON-RPC one. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
A2AServernow serves the A2A v1.0 HTTP+JSON/REST protocol binding (spec section 11) beside the existing JSON-RPC endpoint. Same handlers, same in-memory task store, second transport. Any REST-speaking A2A client can now talk to a youagent agent without a JSON-RPC envelope.Routes follow the v1.0 method mapping (spec section 5.3), with no
/v1prefix (1.0 removed it):POST /message:send{ "task": Task }GET /tasks/{id}?historyLength=nGET /tasks?contextId=&status=&pageSize=&pageToken=&historyLength={ tasks, nextPageToken, pageSize, totalSize }POST /tasks/{id}:cancelPOST /tasks/{id}/pushNotificationConfigsGET /tasks/{id}/pushNotificationConfigs{ configs, nextPageToken }GET /tasks/{id}/pushNotificationConfigs/{configId}DELETE /tasks/{id}/pushNotificationConfigs/{configId}POST /message:stream,POST /tasks/{id}:subscribe(GET accepted too)streaming: falseGET /extendedAgentCardErrors are
google.rpc.StatusJSON per spec section 11.6, using the section 5.4 HTTP status table, and always carry agoogle.rpc.ErrorInfodetail (reason: TASK_NOT_FOUND,domain: a2a-protocol.org, and so on) so clients can tell apart errors that share a status code. Requests may beapplication/jsonorapplication/a2a+json; anything else isContentTypeNotSupportedError. Responses areapplication/a2a+json.The served card gains an
HTTP+JSONentry insupportedInterfacesfor each JSON-RPC entry (JSON-RPC stays first, so it remains the preferred interface).restBinding: falseonA2AServerConfigturns the whole thing off, including the advertisement.Try it:
Why this, why today
youagent's A2A story so far has been JSON-RPC only. The v1.0 spec defines three bindings and the ecosystem has standardized on shipping all of them:
RestTransportclient only talks to servers that expose these routes. Source: https://github.com/a2aproject/a2a-js/releases/tag/v1.0.0supportedInterfacesfrom the card and runs anhttp_jsonsuite against every declared REST interface. A card that declares only JSONRPC gets only the JSON-RPC suite. Source: https://github.com/a2aproject/a2a-tcka2a-handleron PyPI, v0.1.25, 2026-07-23), the terminal A2A client already tracked in issue Integration tracking: Handler (alDuncanson/Handler) youagent interop guide #4, prefers REST for one-shot calls. Source: https://pypi.org/project/a2a-handler//v1/path prefix (spec issue #1269). Shipping the binding now means shipping the 1.0 shape from day one rather than carrying a compat layer later.Runner-up candidates considered today and passed on:
resultType,ttlMs/cacheScope,server/discover). Verified the spec changelog, but the Go SDK already implements all of it as of go-sdk v1.7.0 (frugal pins v1.6.1), so this is a dependency bump rather than a feature. Source: https://modelcontextprotocol.io/specification/2026-07-28/changelog and https://github.com/modelcontextprotocol/go-sdk/releases/tag/v1.8.0outputSchemaand returnstructuredContentper the same MCP revision. Real and timely, but the repo has three unreviewed daily PRs already and no merge history for them, so a fourth would sit in the same queue.The REST binding does not overlap any open youagent PR (#10 streaming, #11 auth, #12 signed cards, #13 serve from start). When #10 lands, the two streaming routes here can hand off to the SSE path; until then they answer the same
UnsupportedOperationErrorthe JSON-RPC binding does.Implementation notes
src/a2a/rest.ts: route table (REST_ROUTES,matchRestRoute), error mapping (restStatusFor,toRestErrorBody), card helper (withHttpJsonInterface), query coercion. All exported fromyouagent.A2AServer:handleRequestfalls through tohandleRestfor matched routes;restParamsbuilds the params the existing handler expects from path, query and body;sendRestResultapplies the REST response shapes (SendMessageResponse wrapper, 201 on create, 204 on delete). Handlers are invoked under the 1.0 PascalCase operation name so push config responses come back flattened, which is also what REST specifies. The path task id wins over anytaskIdin a create body.A2A_ERROR_CODESgains -32007, -32008, -32009 from the 1.0 table.src/server/express/rest_handler.tsandsrc/errors/rest.ts(status codes,REQUEST_MALFORMEDreason for structural errors, 201/204 on config create/delete, both GET and POST on:subscribe).Test status
npm run typecheck: cleannpm test: 15 files, 166 tests passing (16 new REST tests insrc/a2a/a2a-server.rest.test.tscovering the route table, the error mapping, the card helper, every route including pagination and error paths, content-type handling, the shared task store, andrestBinding: false)npm run build: tsup ESM + DTS build succeedsmessage:send200 asapplication/a2a+json; task get and list 200; unknown task 404 withTASK_NOT_FOUNDErrorInfo; push config create 201;message:stream400UNSUPPORTED_OPERATION;/v1/tasks404a2a:tckscript)🤖 Generated with Claude Code