Skip to content

fix(mcp): revoke credentials by provider session#4189

Open
bdsqqq wants to merge 1 commit into
pingdotgg:mainfrom
bdsqqq:fix/mcp-revoke-provider-session
Open

fix(mcp): revoke credentials by provider session#4189
bdsqqq wants to merge 1 commit into
pingdotgg:mainfrom
bdsqqq:fix/mcp-revoke-provider-session

Conversation

@bdsqqq

@bdsqqq bdsqqq commented Jul 20, 2026

Copy link
Copy Markdown

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

  1. #4189 — revoke credentials by provider session (this PR)
  2. #4190 — make session ownership transitions atomic
  3. #4191 — list only committed sessions

Checklist

  • This PR is small and focused
  • I explained what changed and why

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 existing revokeProviderSession behavior to the active registry so callers can drop a single provider session’s bearer token without revokeActiveMcpThread. issueUncommittedMcpCredential issues a credential without first revoking all credentials for the thread (unlike issueActiveMcpCredential), enabling tentative credentials during session replacement.

A new test confirms that revoking one providerSessionId leaves another credential for the same threadId valid.

Reviewed by Cursor Bugbot for commit 0b31e51. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add revokeActiveMcpProviderSession to revoke MCP credentials by provider session

  • Adds revokeActiveMcpProviderSession to McpSessionRegistry.ts, which revokes a single provider session by ID without affecting other sessions on the same thread.
  • Adds issueUncommittedMcpCredential, a lightweight credential issuance path that skips the commit wrapper and returns undefined when no active registry is present.
  • A new test in McpSessionRegistry.test.ts verifies that revoking one provider session leaves other sessions for the same thread intact.

Macroscope summarized 0b31e51.

@github-actions github-actions Bot added the vouch:unvouched PR author is not yet trusted in the VOUCHED list. label Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 18b51960-accb-4c88-9b11-5e97c614f465

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the size:S 10-29 changed lines (additions + deletions). label Jul 20, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ 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.

Comment thread apps/server/src/mcp/McpSessionRegistry.ts
Comment thread apps/server/src/mcp/McpSessionRegistry.ts
@macroscopeapp

macroscopeapp Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant