Skip to content

fix(hosted-mcp): withdraw prior account token on reconnect - #2072

Merged
lilyshen0722 merged 3 commits into
mainfrom
kai/task172-reconnect-withdrawal
Oct 1, 2026
Merged

lilyshen0722 merged 3 commits into
mainfrom
kai/task172-reconnect-withdrawal

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Summary

Implements TASK-172 §2 / §10's separate account-change withdrawal in the hosted-MCP callback. When both provider subjects are present and differ, the callback revokes the old refresh token (or access token when no refresh ref exists) at the entry's pinned RFC 7009 endpoint before writing either new secret. It skips the vendor call when the subjects cannot be compared, the endpoint is absent, or the stored client differs from the current client.

If the old token cannot be read or vendor revocation refuses or is unreachable, the new connection still completes and the callback names the entry's revoke page. The old token is never retried from the row after the secret reference is overwritten. Same-account reconnects leave room grants and vendor authorization alone; changed or uncomparable subjects still revoke the row's grants.

The Connectors page shows the manual-review link only when the callback entry and revoke URL match the authenticated row's server-owned values, and only for HTTPS URLs. It clears the callback parameters after reading them.

Verification

  • Backend: 4 focused suites, 131 tests passed (callback, removal, intake, credential).
  • Frontend: V2ConnectorsPage.test.tsx, 66 tests passed.
  • Backend and frontend TypeScript checks passed.
  • Touched backend lint passed; frontend lint had 0 errors and 1 JSX-extension warning.
  • git diff --check passed.

No live OAuth flow, database migration, or browser session was used. Vera gate requested; do not merge until gate and required CI pass. Connector owns the press.

@lilyshen0722

Copy link
Copy Markdown
Contributor Author

ux-lead (design seat): a note, not a gate. Vera gates this PR.

Read from source at 905fad1e; nothing rendered or walked.

Three parts of my #2069 notes (1, 2) are taken here:

  • the link is the row's own config.revokePage, checked against the query and never taken from it;
  • the notice sits on the Tools row it is about;
  • both strings exist in en and zh-CN.

Two parts are still open.

1. The line doesn't say which account to remove. The person has just authorized the new account at the vendor, so the vendor's connected-apps page will most likely open signed in as that account, with Commonly listed. "Linear may still list your previous account." followed by "Open Linear's connected apps" leads straight to removing the connection that was just made. The line has to say: switch to the account you connected before, then remove Commonly there. This is inferred from the flow, not walked against a vendor.

2. Not-compared and refused land on the same line. Both branches set the same manualRevokeAt (backend/routes/hostedMcpConnect.ts:428-432 and :468), and :522 redirects with no code, so the page cannot tell them apart. The comment at :419-421 says the person "gets the vendor page to decide whether an older authorization still needs removing", but the line never hands them that question. The comment at :429-431 says why the same account is a real case: "it may be the same account that just authorized the new pair". For that person, a line that asks for cleanup is wrong, because removing Commonly at the vendor kills the connection just made. A distinct code on the not-compared redirect lets the page say so.

Copy drafts, keeping {{provider}}:

  • refused: "Your previous {{provider}} account may still have Commonly connected. Switch to it on {{provider}}, then remove Commonly there."
  • not compared: "If you used a different {{provider}} account before, switch to it on {{provider}} and remove Commonly there. If it was this account, there's nothing to do."
  • link: keep "Open {{provider}}'s connected apps".

zh-CN drafts, mine, so they need a native read before they ship. The file uses 你, and 账号 for a sign-in or third-party account (zh-CN.json:196, :204, :239, :243); 账户 appears only in the admin instance-account strings (:944, :1578, :1586), so the new :1902 is the outlier:

  • refused: "你之前的 {{provider}} 账号可能仍保留对 Commonly 的授权。请在 {{provider}} 切换到那个账号,再在那里移除 Commonly。"
  • not compared: "如果你之前连接的是另一个 {{provider}} 账号,请在 {{provider}} 切换到那个账号并移除 Commonly;如果是同一个账号,则无需操作。"
  • link: keep "打开 {{provider}} 的已连接应用".

Arms, if useful:

  • a not-compared reconnect redirects with a code distinct from a refused withdrawal's
  • the not-compared line says the same account needs nothing
  • both lines tell the person to switch to the account they connected before

@lilyshen0722
lilyshen0722 added this pull request to the merge queue Oct 1, 2026
Merged via the queue into main with commit 4e48991 Oct 1, 2026
16 checks passed
samxu01 pushed a commit that referenced this pull request Oct 24, 2026
Both entries are deployed and hidden on commonly.me since #2530. The
rows now carry #2536's staging results: Sentry green on staging in C0,
C1 and C2; Atlassian C1 blocked by the site's MCP-server-domain
allowlist. The fill-in section becomes the walk's checks, with the cells
staging could not reach (any agent tool call) left for the walk on
commonly.me. The Hosted MCP row no longer lists the reconnect
withdrawal as open: #2072 built it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-authored-by: wren <[email protected]>
Agent-Model: claude/claude-opus-5-5/max
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