Repository navigation
feat(pocketbase): MCP, app naming and approval previews in the PocketBase adapter - #53
Closed
ahmad-ajmal wants to merge 9 commits into
Closed
ahmad-ajmal wants to merge 9 commits into
ahmad-ajmal wants to merge 9 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 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.
…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.
Collaborator
Author
|
Replaced by #57, with the same code. The branch is kept. |
Collaborator
Author
|
Update: the native adapters are now on the branch |
Collaborator
Author
|
The native adapters now have one PR: #58. |
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 PocketBase adapter catches up with the reference: the app serves MCP, refuses a call meant for another app, and holds an approval to what the person was shown. Record writes also honor
Idempotency-Key, which this adapter never did. It is stacked on #45, #46 and #48: review the PocketBase commits only until those merge.What changes
transportsandmcpUrl. A malformed list, or a preview that isn't one, stops the app from starting.X-A2App-Appnaming another app:409 app_mismatch. It covers PocketBase's own record, batch, file and realtime routes too.POST /api/_a2app/mcp/<app id>: the spec's ten tools, word for word, in a new_a2app_mcp.js. MCP 2026-07-28 and the three handshake revisions, without sessions. No new dependency.Host, and the path is fixed text with each value as one segment. 200 calls at once, and 20 with 45 realtime streams open, didn't stall.reasonon every428; a key works only for the caller that asked; a refused key comes with one that works;previewon an operation, with the approval tied to its answer. A preview runs in a transaction that is always rolled back.Idempotency-Keyon create and update, over HTTP and MCP, one table. The key is written in the record's own transaction, so a failed write doesn't burn it and of several at once exactly one is made.clear-donenameslist-done.schemaVersionnow covers operations.Tests
test/e2e.mjswith PocketBase 0.39.7: 269/269. The rules and MCP self-tests pass.conformance/multi-user/run.mjs: 77/77.conformance/starter/run.mjs, both auth modes: 74 of 85. Onmainthe same file fails 12 checks on this adapter; now it fails 11. Ten are unchanged: nodataVersion(2) or viewers count, the View's own pages not checkingHost(2), and PocketBase's native error shape (5). One is new because the check is new: that same error shape, over MCP. Two that failed (repeated record writes) now pass.@modelcontextprotocol/sdk1.32.2;@modelcontextprotocol/client2.4.0 default, auto and pinned to 2026-07-28) in both modes: write, guard refusal, approval, delete.pnpm --filter @a2app/conformance test: 148/148. CI does not run this adapter's own tests.Differences from the reference
{status, message, data: {code, …}}, over MCP as over HTTP.mcpUrl.-32700: Goja's parser crashed PocketBase on a 5 MB one.