Skip to content

feat: agents reach apps by CLI, MCP or HTTP - #61

Open
ahmad-ajmal wants to merge 20 commits into
stagingfrom
feat/transport-channels
Open

ahmad-ajmal wants to merge 20 commits into
stagingfrom
feat/transport-channels

Conversation

@ahmad-ajmal

@ahmad-ajmal ahmad-ajmal commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Agents can reach an app by CLI, MCP or HTTP, and what they may do is the same on each. CLI stays first unless someone asks otherwise. One PR for the whole task: it replaces #55 to #60, whose descriptions have the full details.

Two changes to how existing apps behave

  • Approvals waiting when an app updates are asked for again. An approval key now belongs to the caller that asked.
  • An agent's HTTP call to a blocked operation is refused (409 operation_blocked) where it ran before, once the app takes the new adapter. A person using the app's page sees no change.

What changes

  • Transports. An app may declare "transports": ["cli", "mcp", "http"], in order. Agents use the first they can reach: without the CLI, that is MCP or HTTP. A refusal is the app's answer, never a reason to try another. scaffold --transport, the gate, the CLI's notice, the skills and AGENTS.md follow.
  • MCP at POST /api/_a2app/mcp/<app id>: the same ten tools in every app, on all six stacks. Each call is one request through the app's own router, so scopes, approval, guard and limits are the existing ones.
  • Safety. A call names the app it means, and another app refuses it (app_mismatch). A2APP_TOKEN can be tied to one app (A2APP_APP) and no redirect carries it. whoami says limited, and the order never raises an agent's access. Ids are encoded in the SDK, and over MCP are exactly what they say (b-1?x was read as b-1), except in describe's path and in next, where they are percent-encoded.
  • Bridge and plugins. A bridge task runs over the first of its app's transports the run can reach. Over MCP it gets the task's own credential in a file that is removed after it. The plugins' tools follow the order too, with an MCP and an HTTP client of their own.
  • Approvals cover what the person saw. A destructive operation may name a read-only preview, and the approval ends when its answer changes. Every 428 says why (reason). A preview is held to its own declaration before it runs, and shows its answer to whoever holds the destructive operation's scope (approvals.md §3).
  • Blocked operations are refused by the app itself on every transport. Before, only the CLI checked. The app's own page is not held to it.
  • Module access may be partial, so an agent that can write some of a module is no longer told "read-only".
  • Any app, any agent. Names in any script, specs in any language, a Python SDK that speaks 0.2, and conformance for apps that are not a starter.
  • PocketBase honors Idempotency-Key on record writes, which the MCP tools promise.

Spec: spec/v0_2/transports.md, approvals.md, mcp-tools.json. New fields are optional.

Out since the first version: the bridge's any-harness settings (a route's own MCP file format and server name, a JSON prompt, the task, app and address as arguments, and their environment variables). Fixed: word() in walk.ts put names and ids in quotes but did not escape them, so an id like x $(…) ran when the printed line was pasted. Every word of it that needs it is now in single quotes, which PowerShell reads as text too; on Windows an id no shell quotes safely is printed as {id}.

From review: an MCP argument that is null is one not given (ask: null parked a task, page: null answered an empty list). The plugins hold an address to the app the CLI pinned it to, read a remote app's order before choosing, and take a name two apps have for neither. The bridge sets A2APP_APP only with the task's own token, and refuses a headless route that names mcp without a way to be given the server. An app refused by A2APP_APP is not pinned. Expired approval keys are dropped.

From running real apps: the Python stack reads its manifest as UTF-8 (on Windows, an app with names that are not English did not start). Every app's AGENTS.md says that an approval is the person's and how its key is sent on each transport, and that names and ids are percent-encoded in an HTTP path.

Reviewing it

Where Lines added
toolkits/: five adapters, each standalone, so the same features written five times; a third to a half of each is its own self-test 9,836
conformance/ 1,694
adapters/ (the reference: start here, with spec/) 1,585, of which tests 478
harness-plugins/ 1,510, of which tests 78
framework/ 1,277, of which tests 611
spec/ 563
sdks/ 347
skills/ 189

In all +17,013 −1,105 in 160 files. Merge it with a merge commit.

Things to know

  • React-Node needs a release. Its apps install @a2app/adapter-core from npm, and 0.2.1 there has no MCP. Until then scaffold --transport mcp succeeds on it, but the app serves no MCP, shows no preview and runs blocked operations; the gate fails it only where MCP is first.
  • Release the CLI with the adapters. 0.2.5 and before print "no access" for partial, refuse names in other scripts, and refuse an app that has transports (their toolkit-sync removes the key). scaffold writes none by default.
  • An adapter-core app that declares nothing starts serving MCP when it updates. It grants nothing HTTP doesn't.
  • An app on an older adapter still writes ids in next as they are. A spaced one prints safely, but as several words, so that line does not run as it is.
  • A preview is not a lock: a change between it and the run is not seen unless the app does both in one transaction.
  • The built-in codex, gemini and aider routes stay CLI only: how each takes an MCP server for one run could not be confirmed.
  • Not here, other repos: CraftBot's own a2app_command is CLI only, and the Marketplace kit copies have no transports or MCP. CraftBot's public links refuse the MCP path, while a newer app's identity would still advertise mcpUrl there: an agent that meets that refusal has no other way to go.
  • OAuth sign-in for MCP hosts is not part of this.

Tests

  • CI now covers the transports: choosing and the order, limited, A2APP_APP, the MCP endpoint (144 checks), the bridge's runs over each, the scaffold and gate checks, the plugins' order, and an adopted app over MCP. They were tried against 37 deliberate breakages of the built code, all noticed.
  • CI still does not cover: the tests of approval previews, partial and the describe cache (left out; conformance has checks for the first two), and the five adapters' own self-tests, starting a Python app on Windows, and the real-app runs below, which were done by hand on Windows (Rails in a Linux container).
  • On this code: pnpm -r build, typecheck, test; conformance 160/160; PocketBase e2e 269/269; the Hermes and CraftBot tests (24 of Hermes' skipped); the Python SDK's own tests (in CI); each adapter's self-test. Each code fix's scenario was replayed, the bridge's token one on the environment it builds and not in a run. Of all of these, only the AGENTS.md text has tests of its own.
  • Real apps after the review's fixes, scaffolded and served by the framework (React-Node on this adapter, not npm's; Rails started by hand in its container), the starter checks in both auth modes:
Stack Self-test conformance/starter conformance/multi-user Sharing
React-Node (the reference) suites above 100/100 77/77 40/40
Python ok 100/100 77/77 40/40
Go ok 100/100 77/77 40/40
Rust ok 100/100 77/77 40/40
Rails (Ruby 3.3) ok 100/100 77/77 40/40
PocketBase 0.39.7 ok, e2e 269/269 89/100 77/77 40/40
  • PocketBase's 11: no dataVersion (2) or viewers count (1), Host on the View's own pages (2), and its own error shape (5), all as on main; and that error shape over MCP (1).
  • Sharing: a script, not in this PR. Two people, their agents, over CLI, MCP and HTTP: private records, a read-only agent, approvals nobody else can use, work queued and run as the one who asked, device sign-in, taking an agent or a person away. Also 40/40 behind an https public address (Python, React-Node, PocketBase), and on a copy a second user installed from an exported package, which had its own identity and none of the first's data or tokens.
  • Names in any script: Cyrillic modules and operations on Python (entities and fields too), React-Node, Go and Rust: starter 101/101 each. PocketBase failed only what it already fails. Not tried on Rails.
  • The official TypeScript MCP client connects to every stack but Rails (not tried). A harness of no known kind did bridge tasks over HTTP and MCP, as the person who asked.
  • A real agent with only AGENTS.md and the operator skill did a task over HTTP and stopped at the approval. What it found missing in AGENTS.md is fixed; it was not run again.
  • The bridge, on a running app with a stub harness: CLI, MCP and HTTP first in turn, each task completed over that one.

CraftOS-dev and others added 6 commits November 18, 2026 22:02
The walk-verify skill change and the built-in Claude Code route change go out
together in agent-app-framework 0.2.4 (protocol 0.2). The other packages are
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0.2.4 was published with npm instead of pnpm, so its @a2app/sdk and
@a2app/rules dependencies went out as workspace:* and npm could not install
it. 0.2.5 carries the same changes with both pinned at 0.2.1. The Hermes
plugin's install note now points at 0.2.5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: ahmad-ajmal <ahmadajmal1514@gmail.com>
…oose more

The account page every starter ships now ticks "Only let it read" by
default when a person approves an agent's sign-in, and offers "Only read"
first when they give an agent access themselves. An agent that only reads
cannot change anything by mistake; the person unticks the box (or picks
"Do everything you can do") to let it make changes. The ceiling is
unchanged: an agent never does more than its person can.
…efault

feat(account): an agent the person approves only reads unless they choose more
…erations

The spec, its schemas, and the reference that implements them.

- An app declares `transports`, an ordered list of cli, mcp and http, and publishes
  it with `mcpUrl`. A call names the app it means (`X-A2App-App`), and another app
  answers 409 app_mismatch.
- MCP at POST /api/_a2app/mcp/<app id>: ten tools, the same in every app. Each call
  is one request through the adapter's own router, so scopes, approval, guard and
  limits are the ones HTTP callers meet. A caller is a credential, never a session.
- A destructive operation may name a read-only `preview`. The approval is the
  caller's that asked, and ends when the preview's answer changes.
- An operation that does not apply to its record is refused, 409 operation_blocked.
- A module's access may be `partial`, and whoami says `limited`.
- Names may be in any script.
Both SDKs encode ids, entities and operations as one path segment, name the app a
client is for, read identity without the credential, follow no redirect with it,
and resolve an app's order and MCP endpoint. The Python SDK speaks 0.2.
…roving

- The gate checks `transports` and previews, `scaffold --transport` puts one first,
  inspect reports the order, and a2app says it on every screen of an app that puts
  another than the CLI first.
- A2APP_TOKEN is one app's: A2APP_APP names it, and it goes to no other app.
- The walk quotes what an app's names and ids print in a command line, in a form
  PowerShell reads as text too, and shows a preview before the line that would run
  the call.
- A spec may be in any language, and a module may have a command's name.
The first of the app's transports the run can reach, with the prompt written for
it. Over MCP the harness gets a configuration file for that run, with the task's own
credential, removed when it ends. Routes gain `transports` and `argsFor`.
… python adapter

The reference's behavior: the declared order and `mcpUrl` in identity, app_mismatch,
the MCP endpoint, approvals held to their caller and preview, operation_blocked, and
`partial` access. The starter's clear-done names list-done as its preview.
…adapter

The reference's behavior: the declared order and `mcpUrl` in identity, app_mismatch,
the MCP endpoint, approvals held to their caller and preview, operation_blocked, and
`partial` access. The starter's clear-done names list-done as its preview.
…ust adapter

The reference's behavior: the declared order and `mcpUrl` in identity, app_mismatch,
the MCP endpoint, approvals held to their caller and preview, operation_blocked, and
`partial` access. The starter's clear-done names list-done as its preview.
…rails adapter

The reference's behavior, in Ruby. The adapter is built at boot, so a declaration it
refuses stops the app rather than its first request. A header value is read as text,
so an idempotency key is one key over HTTP and MCP; keys stored before are converted.
… the pocketbase adapter

The reference's behavior, in the JS hooks. Every MCP tool call is one request to the
app's own loopback address: PocketBase serves records itself, so there is no router
to hand it to. An Idempotency-Key on a record write is honored, in the same
transaction as the row.
They pass the manifest's `transports` to the adapter, the account page shows an
app's MCP address beside a new token, and react-node's clear-done names its preview.
Class D covers the MCP binding. The starter and multi-user checks run on any app,
on any stack, and say what they did not check.
…d HTTP too

With clients of their own, for where the CLI is missing or the app asks for another
first. An address is held to the app it was pinned to, and a credential is sent only
once the app there has said, without it, that it is the one expected.
The skills, the commands and the README.
@ahmad-ajmal
ahmad-ajmal force-pushed the feat/transport-channels branch from 4561bab to 7d7b365 Compare December 1, 2026 16:21
…ers approvals

From running real apps with names that are not English.

- python: the manifest is read as UTF-8. Elsewhere that is the system's choice, and
  on Windows an app with such names did not start.
- AGENTS.md says that an approval is the person's, and how the key is sent on each
  transport. Only the operator skill did.
- AGENTS.md, the skill and the describe schema say that names and ids are
  percent-encoded in a path, and that only an id in `next` is already.
@ahmad-ajmal
ahmad-ajmal changed the base branch from main to staging December 2, 2026 11:18
* The ten tools. Framework text only: nothing an app says reaches a tool's name,
* description or schema, so an app cannot put words there.
*/
const TOOLS: readonly Tool[] = [

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be careful that if these default agent app is changes in the agent app framework, their MCP counter part should also be changed. Having them in different places might cause mismatch if we forget to sync. This however, is the best solution for now, we can keep this. Just have to be mindful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants