Repository navigation
feat(adapters): MCP, app naming and approval previews in Python, Go, Rust, Rails and PocketBase - #58
Closed
ahmad-ajmal wants to merge 50 commits into
Closed
ahmad-ajmal wants to merge 50 commits into
ahmad-ajmal wants to merge 50 commits into
Conversation
…ose by that order manifest.json may carry `transports`, an ordered list of cli, mcp and http. The first is the app's primary channel and the rest are fallbacks; without it the order is cli, mcp, http. Entries are kinds, never addresses. The gate checks it, the builder may edit it, toolkit-sync keeps it, `scaffold --transport` puts one first, and inspect reports it. Identity gains optional `transports` and `mcpUrl` (published by adapters in a later change). Arriving by CLI at an app that asks for another transport first says so. Skills, AGENTS.md and the README say how to choose, and how to operate over plain HTTP when there is no CLI. Spec: spec/v0_2/transports.md.
…ame its app adapter-core serves the app as an MCP server at POST /api/_a2app/mcp/<app id>. Each tool call is one request through the adapter's own router, so the guard, scopes, approval, idempotency, rate limits and audit are the ones HTTP callers meet. Ten tools, the same in every app (spec/v0_2/mcp-tools.json); MCP 2026-07-28 and, without sessions, the three handshake revisions before it. The caller is a credential, never a browser session. HTTP callers may name the app they mean (X-A2App-App); another app answers 409 app_mismatch. The CLI names a verified remote app on every call, and reads identity without its credential. Identity publishes `transports` and `mcpUrl`. Conformance class D covers the binding, and the starter conformance checks it against a running app on any stack.
Agents given only a task and an app picked the right transport each time, and stopped at every refusal. What slowed them is fixed: tools take an entity or operation by its own name, a declared operation is preferred over a raw write, the HTTP routes are listed in full, what to do when a scope or an approval is missing and the person can't be reached, and an MCP server that answers app_mismatch is another app's.
A destructive operation may name a read-only `preview` that says what it would do. Its answer comes with the 428, and the key covers it: when the answer changes, nothing runs, and the caller is shown the new one. Anything else that changes leaves the approval standing. Two fixes for every destructive operation: a key works only for the credential that asked, and a refused key always comes with one that works. A 428 says why (`reason`: asked, changed, spent, mismatch). The gate and the adapter refuse a preview that is not one. The sidecar runs an adopted app's own read route. The CLI shows the preview before the line that would run the call. The react-node starter's clear-done names list-done. Spec: spec/v0_2/approvals.md.
The Ruby port of the reference's transports and approvals: identity publishes the declared transports and the MCP address, a call that names another app is refused, and the app answers MCP by sending each tool call through its own router. A 428 says why, its key works for the caller that asked, and a destructive operation may name a preview its approval is held to; the starter's clear-done names list-done. Header values are read as text, as Node reads them, so an idempotency key is one key over HTTP and MCP (SQLite kept the two apart); keys stored before are converted. The adapter is built at boot, so a declaration it refuses stops the app instead of failing its first request.
The Go adapter serves the app's MCP endpoint, refuses a call that names another app, and holds an approval to what the person was shown. - identity publishes `transports` and `mcpUrl`; a malformed declaration does not start; X-A2App-App of another app is 409 app_mismatch - MCP: ten tools, each one request through Handle, stateless and handshake revisions, credentials only - approvals carry a reason, are stored for the caller and the call, and cover the preview the operation names - the starter's clear-done names list-done as its preview - the self-test covers all of it
The read-only check used the name as written and the route decodes it, so a
percent-encoded name ("clear%2Ddone") passed the check and ran. The name is
decoded once, checked, and sent as that one segment. Scopes always applied; what
was missing is the promise a harness relies on when it runs a read-only tool
without asking. Found by the Go port's comparison run.
Brings the native Rust adapter up to adapter-core for spec/v0_2 transports.md and approvals.md: - identity publishes transports and mcpUrl; a malformed declaration does not start, and a list without mcp serves no endpoint - X-A2App-App refuses a call meant for another app (409 app_mismatch) - POST /api/_a2app/mcp/<app id>: ten tools, word for word the spec's, each one request through the adapter's own dispatch - every 428 says why and carries a key issued to its caller, for its call; a preview is run as the caller, shown, and covered by the key - the starter's clear-done names list-done as its preview - query_operation judges the decoded operation name, the one it runs - the selftest covers all of it
…pter The FastAPI adapter serves the app's MCP endpoint, publishes its transports, refuses a call that names another app, and asks for approval the way adapter-core does: a reason on every 428, a key held for the caller that asked, and previews that an approval is held to. The starter's clear-done names list-done as its preview.
As in the reference: the read-only check used the name as written and the route decodes it, so a percent-encoded name passed the check and ran. The name is decoded once, checked, and sent as that one segment.
…base adapter Identity publishes the declared transports and the MCP endpoint; a call that names another app is refused on every route but identity; approvals are bound to the caller and, where an operation names a preview, to what it would do. Every MCP tool call is one request to the app's own loopback address, the same path HTTP callers take: PocketBase serves records itself, so there is no router to hand the call to. The launcher says where that is, and refuses to start on a malformed transports list or preview.
The MCP tools promise it and the records API ignored it. A key already applied is a 409 naming the record, before the guard; a new one is recorded in the same transaction as the row, so a write that fails uses none and two at once with one key make one record. An app's own record hooks stay outside that transaction.
… read-only The root called a module read-only for any caller with less than everything in it, so one that could write every record was told it could not. `full` is now everything, `read-only` nothing that changes anything, and `partial` what lies between; a module with only operations is judged the same way, and PocketBase no longer says full to everyone. The CLI reads a word it does not know as some access. An older one prints "no access" for `partial`, so it is released no later than the adapters.
The bridge told every harness to use the a2app CLI. It now uses the first of the app's transports the run can reach, and writes the prompt for it. Over MCP, the harness gets a configuration file for that one run with the app's endpoint and the task's own credential: 0600, only its path in the arguments, removed when the run ends. Routes in harnesses.json gain `transports` and `mcpArgs`; the built-in claude route has the latter. An inbound route gets the app's address, order and MCP endpoint in its body. Plugins say what to do when the CLI is missing, and no longer call it the only way to operate an app. The account page shows the app's MCP address beside a new token.
- An agent that came by MCP is told the app's order: in the server's instructions, in whoami, and in the first describe (conventions.transports). The skill and AGENTS.md say to read it before the first call. - A 401 says where a credential comes from (A2APP_TOKEN, the account page), and no longer points at .agent-token. HTTP is reachable only with a credential in hand, where the work changes anything. - dev, the skills and AGENTS.md say that only a2app moves to the candidate: connected MCP tools and the usual address still reach the live app. - scaffold writes `transports` only when it is a choice, so an older agent-app accepts the app. It refuses --transport mcp on a blueprint that does not serve MCP, the gate refuses it on a running app, and serve names a malformed list. - starter conformance says what it did not check. - Docs keep the token off the command line; a missing CLI is the person's to install.
This was referenced Nov 30, 2026
…e described From the second audit. - whoami says when a credential gives less than the owner has, and such a caller is told to stay with it, not sent to a CLI that acts as the owner. - A2APP_TOKEN is one app's: A2APP_APP names it, and it goes to no other app. - a2app says nothing of the live app's transports while it answers from a dev candidate. - The SDK encodes ids, entities and operations in paths: `b-1?x` was `b-1`. - Bridge routes have arguments per transport, their own MCP configuration format and a JSON prompt; the run's values are in the environment. - Plugin tools follow the app's order, over MCP or HTTP without the CLI. - One table of transports, and what must name each is keyed by it.
Every adapter tells a caller with less than the owner's access to stay with it.
Collaborator
Author
|
Replaced by #61, which has this same code. The branch is kept. |
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.
The five native adapters catch up with the reference: MCP, app naming and approval previews in Python, Go, Rust, Rails and PocketBase. Replaces #49 to #53. Their descriptions have the per-stack details.
Merge after #55, #56 and #57 (it contains #55, whose describe changes meet these). Until then this diff includes them; see only this PR's changes.
What changes, in each adapter
transportsandmcpUrl. A malformed list stops the app from starting; a list withoutmcpserves no endpoint.X-A2App-Appnaming another app:409 app_mismatch.POST /api/_a2app/mcp/<app id>: the spec's ten tools, word for word. Each call is one request through the app's own routes. No new dependency.reasonon every428; a key works only for the caller that asked; a refused key comes with one that works;preview, with the approval tied to its answer.whoamisayslimited, and such a caller is told to stay with its credential.whoamiand the first describe, as in feat(transports): apps are reached by CLI, MCP or HTTP, in the order they ask for #56.scaffold --transport mcpaccepts it.clear-donenameslist-done.Idempotency-Keyon record writes.It is about 9,200 lines because every app is standalone: each stack ships its own full adapter, so the same two features are written five times. Roughly a third to a half of each is its own self-test. One merge commit per stack, so each can be reviewed alone.
Tests
conformance/starter, both auth modesconformance/multi-userdataVersionor viewers count,Hoston the View's own pages, PocketBase's own error shape). The other is the same error shape over MCP, so there the guard does not report every violation.pnpm -r build,typecheckandtestpass on this branch; conformance 150/150..testfiles are added. CI does not run these adapters' own tests: the table was run by hand, on Windows.Known differences from the reference
Small ones, listed per stack in #49 to #53. In short: an operation with no runner answers
501per operation; Go's maps keep no order, so a tie in a cut preview goes to the first by name; Rust reads JSON with lone surrogates or nested over 128 deep as not JSON; Rails' empty202carries a content type; PocketBase serves no MCP when it listens on one non-loopback address only.