Skip to content

feat(transports): apps are reached by CLI, MCP or HTTP, in the order they ask for - #56

Closed
ahmad-ajmal wants to merge 14 commits into
mainfrom
feat/agent-transports
Closed

ahmad-ajmal wants to merge 14 commits into
mainfrom
feat/agent-transports

Conversation

@ahmad-ajmal

@ahmad-ajmal ahmad-ajmal commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

An app can say how agents reach it: CLI, MCP or HTTP, in order. CLI stays first unless someone asks otherwise, and an agent without the CLI uses MCP or HTTP. Replaces #45, #46 and #54: the same code, without the new test files. Their descriptions have the full details.

What changes

  • Declaration and choosing (was feat(transports): an app declares how agents reach it (CLI, MCP, HTTP) #45). manifest.json may carry "transports": ["cli", "mcp", "http"]; absent means that order. Entries are kinds, never addresses. Agents use the first they can reach, and a refusal is the app's answer on every transport. scaffold --transport, validate, inspect and the skills follow.
  • MCP in every adapter-core app (was feat(transports): apps serve MCP, and every transport names its app #46). POST /api/_a2app/mcp/<app id>, ten tools, the same in every app. Each call is one request through the app's own router, so scopes, approval, guard and limits are the existing ones. It takes a token, never a session.
  • Naming the app. X-A2App-App, or the id in the MCP address. Another app answers 409 app_mismatch. The CLI reads the identity document without its credential.
  • Bridge and plugins (was feat(bridge): run each task over the transport its app asks for #54). A bridge task runs over the first of the app's transports the run can reach, with a prompt written for it. Over MCP the harness gets a config file for that run with the task's own credential, never on the command line. Plugins say what to do when the CLI is missing. The account page shows the MCP address beside a new token.

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

  • After an independent audit. Agents that come by MCP are told the app's order (instructions, whoami, the first describe). a2app says it on every screen of an app that puts another first. A 401 says where a credential comes from instead of pointing at .agent-token, and HTTP counts as reachable only with a credential in hand. dev, the skills and AGENTS.md say that only a2app moves to the candidate. scaffold writes transports only when it is a choice, and refuses --transport mcp on a blueprint that serves none; the gate and serve check it too.

  • After a second audit.

    • The order never raises access. whoami says limited: true to a credential that gives less than the owner's, 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 is sent to no other app. A redirect never carries it.
    • Ids are encoded in the SDK, and over MCP an id is exactly what it says. b-1?x was read as b-1, and over MCP p%41 as pA: a delete could hit the wrong record.
    • a2app says nothing of the live app's transports while it answers from a dev candidate.
    • Any harness can be described: arguments per transport (argsFor), its own MCP file format (mcpConfig), a JSON prompt, and the run's values in the environment.
    • Plugin tools follow the app's order, over MCP or HTTP without the CLI (TypeScript engine, Hermes, CraftBot).
    • One table of transports in TypeScript; what must name each is keyed by it.

Things to know

  • The built-in codex, gemini and aider routes stay CLI only: how each is given an MCP server for one run could not be confirmed from their docs. A profile says it. No built-in route grants the network for HTTP.

  • An older agent-app (0.2.5 and before) accepts an app with no transports, which is what scaffold now writes by default. It refuses one that has the key, and its toolkit-sync removes it: raise the CLI's version with this release.

  • An app on adapter-core that declares nothing starts serving MCP when it updates. It grants nothing HTTP doesn't.

  • The Python, Go, Rust, Rails and PocketBase adapters are in feat(adapters): MCP, app naming and approval previews in Python, Go, Rust, Rails and PocketBase #58. Until it lands agents there use CLI, then HTTP.

  • CraftBot's public links refuse the MCP path, and must until its gateway reads the call in the body.

  • OAuth sign-in for MCP hosts is not part of this.

Tests

  • The new .test files are left out of this PR, on request. Existing ones change only where they would fail against the new code (bridge, install, manifest-merge). What was left out stays on the old branches (feat/transports-mcp, feat/transports-bridge).
  • So CI covers MCP through the conformance suites (class D, and the new class A checks). It does not cover choosing a transport, the bridge's MCP runs or the scaffold and gate checks.
  • pnpm -r build, typecheck and test pass on this branch. Before the files were left out, all of them passed against this same code.
  • Agents, measured on running apps, read from each app's own log (Sonnet and Haiku). Default order with the CLI and MCP both at hand: 4 of 4 used the CLI (the audit: 3 of 5). HTTP first with everything at hand: 4 of 4 used HTTP, after 3 of 4 before the CLI notice (the audit: 2 of 4). Only HTTP: 3 of 3 finished (the audit: 1 of 3). HTTP first with no credential: used the next transport and finished. Small samples: this is a rate, not a guarantee. After the access rule: read-only over MCP with the CLI installed, 4 of 4 stopped (one under time pressure, one with no skill; the audit: 1 of 2); full access over MCP, 3 of 3 used the CLI.
  • Real MCP clients (both official SDKs, the Inspector), 13 agents on running apps, a browser on the account page, and three real bridge tasks (MCP, CLI, HTTP). Details in feat(transports): apps serve MCP, and every transport names its app #46 and feat(bridge): run each task over the transport its app asks for #54.
  • Not run: a native claude run over MCP (not logged in on this machine); Hermes' 24 dashboard tests (no FastAPI here).

…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.
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.
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.
…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.
@ahmad-ajmal

Copy link
Copy Markdown
Collaborator Author

Replaced by #61, which has this same code. The branch is kept.

@ahmad-ajmal ahmad-ajmal closed this Dec 1, 2026
@ahmad-ajmal
ahmad-ajmal deleted the feat/agent-transports branch December 2, 2026 11:18
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.

1 participant