Skip to content

fix(j5): lowering an Owner ends the MCP clients they approved - #714

Merged
Jacksondr5 merged 6 commits into
j5/mainfrom
j5code/revoke-owner-approved-mcp
Oct 25, 2026
Merged

Jacksondr5 merged 6 commits into
j5/mainfrom
j5code/revoke-owner-approved-mcp

Conversation

@Jacksondr5

@Jacksondr5 Jacksondr5 commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

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

  • Who approved is recorded when the session is issued. J5's approval gate (McpApproval.layerGatedMcpOAuth) already reads the Owners generation before upstream's approve. 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.issueMcpClient issues the session under the existing lock. It then records session_id → person_id in a new J5 table, j5_a2a_mcp_client_approver (J5 migration 45). The session id comes from upstream's SessionStore.verify on the token it just issued. Rows for expired sessions are pruned on each insert.
  • Lowering or removing an Owner ends only their clients. This happens in the same transaction that changes the level or removes the person. That transaction already voids waiting approvals. It now also deletes that person's rows and revokes those sessions upstream. Other Owners' clients are untouched.
  • Approvals still waiting stay refused, whoever gave them, as feat(j5): people and access: everyone is a person with a level at a scope, and several people work with one agent #638 does now.
  • Clients with no recorded approver keep working until an Owner ends them. That covers clients approved before this change, and those approved with a code that names no one (the first owner's startup link, or a device no one has claimed). There is no backfill: upstream never recorded the approver, so there's nothing to backfill from.
  • A link made as its maker is removed approves nothing. If an Owner makes a Connections link and is removed before J5 records whose it is, their session is no longer bound and reads as no one's. PairingIntents.recordForCreator now refuses a maker whose session is no one's and is no longer live, and upstream's pairingCredential handler 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.
  • Refresh and renewal: upstream's MCP sign-in only supports 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.md drops "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, 08eb921401 makes the gate's unbind and revoke one transaction, and later commits merge j5/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

  • One concern: the description has no "also"
  • Tests cover the changed behavior (backend changes ship with focused tests)
  • UI changes: before/after screenshots above, and a video for motion or interaction — no UI change
  • Live testing: the section above says what ran live and what did not
  • Upstream-owned files: none edited; FORK.md case 70 text updated for the J5-side change
  • Upstream product: no change to what upstream's product does; D33 updated
  • Surfaces: server-only. Both approval paths (pairing code and browser session) and both ways of losing Owner (a change of level or leaving, and removal) are covered. Contracts, clients and providers are unchanged. Reverse state: promoting someone back to Owner doesn't revive their ended clients; they are approved again.
  • Docs: D33 and FORK.md rewritten. The People and access definition never mentioned MCP clients, so it is unchanged.

Reviews

  • Round 1, Claude Fable 5.1: nothing blocking.
  • Round 1, GPT-6-Astra: two P1s.
    1. A Connections code minted by an Owner who was removed before J5 recorded the maker could approve an MCP client with no approver. Fixed as described above. The regression test removes the maker between minting and recording, and fails without the fix.
    2. An MCP request already running when its session is revoked finishes. Accepted limit, not fixed: a request already running when the session is revoked finishes, and the next one is refused. This is upstream's revoke behavior for every MCP session: each request checks its bearer token again, and there is no long-lived socket to close.
  • Round 2, GPT-6-Astra: one P1. Ending a device by another device cut it loose from its person and then revoked it in two commits, so a code minted on that device in between was recorded as no one's and approved MCP clients after the Owner was removed. Fixed: the gate's four ways of ending a session now cut it loose and revoke it in one transaction, as removing a person and ending a device from People already did. The regression test pauses upstream's revoke after the cut and records the code then; it fails without the fix.

Tests (vp test run): Access.test.ts, McpApproval.test.ts, AccessGate.test.ts, PersonAccess.test.ts, a2a/Migrations.test.ts all passed (53 tests). After round 1: PairingIntents.test.ts, McpApproval.test.ts, Access.test.ts and auth/http.test.ts all passed (26 tests); with the refusal removed, the new PairingIntents case fails. After round 2: PairingIntents, McpApproval, Access, AccessGate, People, cliPairing, firstOwnerDevices, GuestArtifacts and GuestProjectIcons tests 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

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>
@vercel

vercel Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
j5-code Ready Ready Preview Oct 25, 2026 4:48am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 4b57edf and 0ecc086.

Files selected for processing: 12
  • FORK.md
  • apps/server/src/j5/a2a/Migrations.test.ts
  • apps/server/src/j5/a2a/Migrations.ts
  • apps/server/src/j5/a2a/migrations/045_McpClientApprovers.ts
  • apps/server/src/j5/sharing/Access.test.ts
  • apps/server/src/j5/sharing/Access.ts
  • apps/server/src/j5/sharing/AccessGate.ts
  • apps/server/src/j5/sharing/McpApproval.test.ts
  • apps/server/src/j5/sharing/McpApproval.ts
  • apps/server/src/j5/sharing/PairingIntents.test.ts
  • apps/server/src/j5/sharing/PairingIntents.ts
  • docs/j5/product/upstream.md

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.

Walkthrough

MCP approvals now carry the approving person and Owners generation through session issuance. The server records named approvers for issued sessions and revokes their sessions when they lose or leave the Owner role. Connections-link recording also checks whether an unidentified creator’s session remains active.

Changes: MCP approver tracking

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: Normal

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
Loading

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: Passed 4
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: MCP clients approved by a lowered Owner are ended.
Description check Passed 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 detail…
Linked Issues check Passed The PR meets the coding requirements in [#639]. McpApproval.layerGatedMcpOAuth captures the Owners generation and the approver for pairing-code and browser approvals. Access.issueMcpClient verifie…
Out of Scope Changes check Passed The changes stay within [#639]. Migration 45 supports the approver table. PairingIntents changes prevent a removed or concurrently ended maker from creating an unowned approval path. Transaction cha…
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.layerGatedMcpOAuth captures the Owners generation and the approver for pairing-code and browser approvals. Access.issueMcpClient verifies the issued session, records non-null approvers in j5_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. PairingIntents changes 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 to FORK.md and 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.

@github-actions github-actions Bot added size:L 100-499 effective changed lines (test files excluded in mixed PRs). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Oct 25, 2026
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
Jacksondr5 and others added 2 commits October 25, 2026 00:46
# 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>
@Jacksondr5
Jacksondr5 merged commit e80ea25 into j5/main Oct 25, 2026
32 checks passed
@Jacksondr5
Jacksondr5 deleted the j5code/revoke-owner-approved-mcp branch October 25, 2026 05:02

This branch was successfully deployed

1 active deployment
Preview — 0ecc0860 Deployed Oct 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 effective changed lines (test files excluded in mixed PRs). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

End an Owner's MCP clients when that Owner is lowered or removed

1 participant