fix(mcp): revoke credentials by provider session#4189
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0b31e51. Configure here.
ApprovabilityVerdict: Approved This PR adds two exported helper functions and a unit test, but the new functions are not called anywhere yet, resulting in no runtime behavior change. The review comments noting unused code are low-severity observations about code hygiene, not substantive issues. You can customize Macroscope's approvability policy. Learn more. |

What Changed
Add selective MCP credential revocation for a single provider session, without affecting other sessions owned by the same thread.
Why
provider session replacement needs to roll back credentials created by a failed attempt while preserving credentials for the committed session. i found that revoking by thread is too broad once both sessions overlap.
so scoping revocation to the provider session gives lifecycle compensation the narrow ownership primitive it needs.
(found this solution after being too aggressive and nuking the entire mcp auth when a pi session failed to persist, this lets us keep what worked and cleanup what didn't)
Stack
Checklist
Note
Medium Risk
Changes MCP auth token lifecycle primitives; incorrect use could leave stale credentials active or revoke the wrong session, though scope is limited to new exports and a focused test.
Overview
MCP credential lifecycle now supports narrower revocation and issuance paths for overlapping provider sessions on one thread.
The registry module exposes
revokeActiveMcpProviderSession, wiring the existingrevokeProviderSessionbehavior to the active registry so callers can drop a single provider session’s bearer token withoutrevokeActiveMcpThread.issueUncommittedMcpCredentialissues a credential without first revoking all credentials for the thread (unlikeissueActiveMcpCredential), enabling tentative credentials during session replacement.A new test confirms that revoking one
providerSessionIdleaves another credential for the samethreadIdvalid.Reviewed by Cursor Bugbot for commit 0b31e51. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add
revokeActiveMcpProviderSessionto revoke MCP credentials by provider sessionrevokeActiveMcpProviderSessionto McpSessionRegistry.ts, which revokes a single provider session by ID without affecting other sessions on the same thread.issueUncommittedMcpCredential, a lightweight credential issuance path that skips the commit wrapper and returnsundefinedwhen no active registry is present.Macroscope summarized 0b31e51.