Skip to content

[rmcp] Notify credential stores when a refresh token is rejected - #1285

Open
mzeng-openai wants to merge 1 commit into
modelcontextprotocol:mainfrom
mzeng-openai:dev/mzeng/oauth-rejected-refresh-hook-3.2
Open

mzeng-openai wants to merge 1 commit into
modelcontextprotocol:mainfrom
mzeng-openai:dev/mzeng/oauth-rejected-refresh-hook-3.2

Conversation

@mzeng-openai

Copy link
Copy Markdown
Contributor

Summary

A provider can reject a refresh token with invalid_grant, but the credential store currently has no callback to retire that token. Later calls can load it again and repeat the failed exchange.

This adds an optional CredentialStore::on_refresh_token_rejected callback at the shared refresh boundary. It receives the credentials used for the exchange while the refresh guard is still held. The default is a no-op, so existing stores keep their behavior. Callback failures propagate as storage errors; other refresh failures do not invoke the callback.

Key review points:

  • crates/rmcp/src/transport/auth.rs: the callback must not reacquire the refresh guard or overwrite credentials that have been replaced.

The branch starts from RMCP 3.2.0 so downstream clients can test this hook without taking an unrelated SDK upgrade.

Test Plan

  • Command: cargo test -p rmcp --lib --features auth,client,transport-streamable-http-client,reqwest transport::auth::tests:: passed all 185 tests.
  • Tests cover the attempted credential snapshot, guard lifetime, callback failure, transient errors, and unchanged default behavior.
  • Command: git diff --check passed.

@github-actions github-actions Bot added T-core Core library changes T-transport Transport layer changes labels Sep 18, 2026
@mzeng-openai
mzeng-openai marked this pull request as ready for review September 18, 2026 19:22
@mzeng-openai
mzeng-openai requested a review from a team as a code owner September 18, 2026 19:22
@mzeng-openai
mzeng-openai force-pushed the dev/mzeng/oauth-rejected-refresh-hook-3.2 branch from 4884f93 to 76ae383 Compare September 18, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-core Core library changes T-transport Transport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant