Skip to content

feat(transports): apps serve MCP, and every transport names its app - #46

Closed
ahmad-ajmal wants to merge 4 commits into
mainfrom
feat/transports-mcp
Closed

ahmad-ajmal wants to merge 4 commits into
mainfrom
feat/transports-mcp

Conversation

@ahmad-ajmal

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

Copy link
Copy Markdown
Collaborator

Each app now serves MCP itself, so an agent with no CLI can still use it, and every transport lets a caller name the app it means. This is the second of the transports series and is stacked on #45: review its own two commits until that one merges.

What changes

  • MCP endpoint at POST /api/_a2app/mcp/<app id>, in @a2app/adapter-core. The react-node blueprint and the sidecar get it from there. Each tool call becomes one request through the adapter's own router, so the guard, scopes, approval, idempotency, rate limits and audit are the existing ones, not copies.
  • Ten tools, the same in every app, word for word those of spec/v0_2/mcp-tools.json (4.7k characters). Nothing the app says reaches a tool's name, description or schema.
  • Versions: MCP 2026-07-28, and 2025-11-25, 2025-06-18 and 2025-03-26 without sessions. No new dependency.
  • Credential, never a session. X-A2App-Token, or Authorization: Bearer on this endpoint only. Cookies and browser headers count for nothing. Idempotency-Key and X-A2App-Approval headers are ignored, because a harness sends the same headers on every call; they are tool arguments.
  • Naming the app. The id is in the MCP address. HTTP callers may send X-A2App-App. A different app answers 409 app_mismatch.
  • CLI and SDK. After verifying a remote app, a2app names it on every call. It now reads the identity document without its credential: before, the token went out with the probe that decides whether this is the right app.
  • Discovery. Identity publishes transports and mcpUrl. A manifest without mcp in its list serves no endpoint; one that declares nothing does.

Things to know

  • 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 don't serve it yet (next PRs). They publish no mcpUrl, so agents there use CLI, then HTTP, and class D isn't claimed.
  • CraftBot's public links refuse the path today. They must keep refusing it until the gateway can read the call in the body, or its per-operation rules would be skipped.
  • The person creates the token on the app's account page (it exists today). OAuth sign-in for MCP hosts is not part of this.

Tests

  • adapters/adapter-core/test/mcp.test.mjs: 128 checks, most in pairs (do it over MCP, then look at it over HTTP).

  • New conformance class D (36 checks) and 4 new class A checks. Conformance 127/127.

  • Checks added to reverse-proxy (MCP through an adopted app) and the CLI's connect test (no credential in the identity probe; every later call names the app).

  • conformance/starter/run.mjs gained the MCP checks: 76/76 against a running react-node app in each auth mode. The native adapter PRs will run the same file.

  • Real clients against those two apps: @modelcontextprotocol/sdk 1.32.2, @modelcontextprotocol/client 2.4.0 (default, auto, and pinned to 2026-07-28), and the MCP Inspector CLI 2.17.0 listing tools and calling describe. The SDK clients also ran a write, a guard refusal, the approval flow and a delete.

  • pnpm -r build, typecheck and test pass on Windows, Node 24; the Python SDK tests pass. The PocketBase e2e is skipped without POCKETBASE_BIN, and is not touched here.

  • Agents on running apps. 13 agents (Sonnet and Haiku) were each given an app and a task, with no mention of transports, and the choice was checked in the app's request log. Default order with the CLI: CLI. No CLI: MCP, or HTTP where MCP wasn't connected or the adapter (Python) doesn't serve it. MCP or HTTP listed first: that one, with the CLI installed. A stale MCP address: refused, next transport, reported. Read-only credential, also under pressure to get it done: stopped at insufficient_scope, tried no other transport, and did not touch .agent-token. Destructive operation with nobody to ask: stopped at approval_required. App-queued task over MCP: claimed, progressed, completed. MCP was reached through a small command wrapping the official client, not a harness's native tool list. The second commit is what those runs showed was unclear.

  • Accounts, through the real page. On a multi-user app: owner and member signed up, the member created a read-only token on the account page, MCP showed only the member's records and refused writes, and revoking the token there ended it at once.

  • Replaced app. Same address, new app id: MCP, HTTP and the CLI each refused it.

  • Fixed since it opened: query_operation judged the operation name as written while the route decodes it, so a percent-encoded name ran an operation that isn't read-only (scopes still applied). Found by the Go port's comparison run. Checks added in three places; they fail without the fix. Conformance is now 128/128.

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

Copy link
Copy Markdown
Collaborator Author

Replaced by #56, with the same code. The branch is kept.

@ahmad-ajmal
ahmad-ajmal deleted the feat/transports-mcp 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