Repository navigation
fix(j5): lowering an Owner ends the MCP clients they approved - #714
Conversation
J5's MCP approval gate now reads who approves an MCP client (the person a pairing code was made for, or the person whose browser approves) and the access gate records the issued session as theirs in a J5 table keyed by session id. Lowering or removing that Owner revokes those sessions in the same transaction as the change of level. Clients approved before this, or with a code that names no one, have no recorded approver and keep working until an Owner ends them. An approval still waiting when the Owners change stays refused. Closes #639 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Validate pairing-link creators apps/server/src/j5/sharing/PairingIntents.ts, apps/server/src/j5/sharing/PairingIntents.test.ts |
Connections-link recording checks whether an unidentified creator’s session is active. It fails with no_person when the session is inactive and records no intent for an unclaimed device. |
Store approvers for issued sessions apps/server/src/j5/a2a/migrations/045_McpClientApprovers.ts, apps/server/src/j5/a2a/Migrations.ts, apps/server/src/j5/a2a/Migrations.test.ts, apps/server/src/j5/sharing/Access.ts |
Migration 45 adds a table keyed by session ID with approver and expiration fields. Access accepts an approval record and associates a named approver with an issued session. |
Resolve approvers and pass approval records apps/server/src/j5/sharing/McpApproval.ts, apps/server/src/j5/sharing/AccessGate.ts, apps/server/src/j5/sharing/McpApproval.test.ts, apps/server/src/j5/sharing/Access.test.ts |
MCP approval resolves the approver from a pairing intent or authenticated browser session. Code exchange passes the approver and Owners generation to session issuance, which rejects stale approvals. |
Revoke sessions after Owner status changes apps/server/src/j5/sharing/Access.ts, apps/server/src/j5/sharing/AccessGate.ts, apps/server/src/j5/sharing/Access.test.ts, docs/j5/product/upstream.md, FORK.md |
Lowering or removing an Owner revokes only that person’s recorded MCP sessions. Unbinding and upstream session revocation run in a SQL transaction. Documentation describes the behavior and identifies legacy or unnamed sessions for manual cleanup. |
Priority:
Estimated code review effort: 4 (Complex) | ~45 minutes
Change: Bug fix · Severity of issue fixed: Medium
Sequence Diagram(s)
sequenceDiagram
participant McpApproval
participant AccessGate
participant Access
McpApproval->>AccessGate: Provide approver and Owners generation at code exchange
AccessGate->>Access: Issue session with approval record
Access->>Access: Record session for named approver
Access->>Access: Revoke recorded sessions when approver loses Owner status
Suggested reviewers: asianham
Merge Risk: 
Low · up to 0ecc0
-
A failed Owner change could disconnect an affected client even though its session remains valid. This is a narrow, recoverable risk that can be accepted with owner awareness.
Pre-merge checks: 
4
-
Full details: Description check
-
Explanation
The description includes the required problem, implementation, live testing, upstream impact, checklist, issue reference, test results, and model/harness details. It correctly omits UI-specific details because the PR has no UI changes.
Full details: Linked Issues check
-
Explanation
The PR meets the coding requirements in [
#639].McpApproval.layerGatedMcpOAuthcaptures the Owners generation and the approver for pairing-code and browser approvals.Access.issueMcpClientverifies the issued session, records non-null approvers inj5_a2a_mcp_client_approver, and removes expired rows. The access-change transaction increments the Owners generation and, when a person loses Owner status, deletes and revokes only that person's recorded MCP sessions. Sessions without a recorded approver remain unaffected. Focused tests cover stale waiting approvals, both approval paths, owner lowering and removal, and isolation from another Owner's clients.
Full details: Out of Scope Changes check
-
Explanation
The changes stay within [
#639]. Migration 45 supports the approver table.PairingIntentschanges prevent a removed or concurrently ended maker from creating an unowned approval path. Transaction changes prevent a race between device unbinding and revocation. The added tests and updates toFORK.mdand upstream product documentation describe or verify the requested behavior. No unrelated product or upstream-owned code change is demonstrated.
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
A Connections link minted by an Owner who was removed before J5 recorded whose it was read as made by no one, so its code could approve an MCP client with no approver. `recordForCreator` now refuses a maker that is no one's and no longer live; upstream's handler then revokes the link. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A link made on an Owner's device while another device ended it could see the device unbound but still live, record it as no one's, and keep approving MCP clients after the Owner was removed. The gate's four revoke paths now unbind and revoke in one transaction, as People.revokeDevice and Access.removePerson already do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # apps/server/src/j5/sharing/AccessGate.ts
# Conflicts: # apps/server/src/j5/a2a/Migrations.test.ts # apps/server/src/j5/a2a/Migrations.ts # docs/j5/product/upstream.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problem
Only an Owner can approve an MCP client (#638), but when that Owner is lowered or removed, the MCP clients they approved keep working. Upstream doesn't record which session approved a client, so J5 couldn't tell which clients were whose. Closes #639.
What changed
McpApproval.layerGatedMcpOAuth) already reads the Owners generation before upstream'sapprove. It now also reads the approver at that point: the person the pairing code's intent names (read before upstream spends the code), or the person whose browser session approves. It ties both to the code and hands them to the exchange.Access.issueMcpClientissues the session under the existing lock. It then recordssession_id → person_idin a new J5 table,j5_a2a_mcp_client_approver(J5 migration 45). The session id comes from upstream'sSessionStore.verifyon the token it just issued. Rows for expired sessions are pruned on each insert.PairingIntents.recordForCreatornow refuses a maker whose session is no one's and is no longer live, and upstream'spairingCredentialhandler then revokes the link. A device no one has claimed is still live, so its links still work and are recorded as no one's.authorization_code(no refresh token), so a client's session never gets a new id. MCP sessions aren't person devices, so J5's session renewal doesn't touch them either. FORK.md case 70 now gives the pin-advance check: if upstream adds a refresh grant, the record has to move to the new session.Upstream impact
No upstream-owned file is edited. FORK.md case 70 is rewritten to describe the tie, the new table, and the refresh check above. Register D33 in
docs/j5/product/upstream.mddrops "Later (#639)" and states the new behavior, with a history line. The decision is Jackson's, in #639.Live testing
GPT-6-Astra ran it live in its round-2 review, at
32bf755835, on a dev server with a throwaway home. Two Owners each approved MCP clients, one through browser consent and one with a Connections code. The first Owner was then lowered over the app's own WebSocket call. That Owner's two clients got 401 on their next requests, and the other Owner's client kept getting 200.Since then,
08eb921401makes the gate's unbind and revoke one transaction, and later commits mergej5/main(the approver migration is now 45, after #715's 44). Neither changes anything a person or an agent sees, so I didn't re-run the live check. Astra's round-3 review exercised all four revoke paths against the real auth and session services on a file-backed database.Not exercised live: an MCP request already running when its session is revoked. That's an accepted limit: the request finishes, and the next one is refused.
Checklist
Reviews
Tests (
vp test run):Access.test.ts,McpApproval.test.ts,AccessGate.test.ts,PersonAccess.test.ts,a2a/Migrations.test.tsall passed (53 tests). After round 1:PairingIntents.test.ts,McpApproval.test.ts,Access.test.tsandauth/http.test.tsall passed (26 tests); with the refusal removed, the newPairingIntentscase fails. After round 2:PairingIntents,McpApproval,Access,AccessGate,People,cliPairing,firstOwnerDevices,GuestArtifactsandGuestProjectIconstests all passed (60 tests). Server typecheck is clean and targeted lint passes. As a mutation check, disabling the revoke makes the new Access and McpApproval cases fail, and so does dropping the browser-path approver.Built by Claude Opus 5.5 in Claude Code.
🤖 Generated with Claude Code