[rmcp] Notify credential stores when a refresh token is rejected - #1285
Open
mzeng-openai wants to merge 1 commit into
Open
mzeng-openai wants to merge 1 commit into
mzeng-openai wants to merge 1 commit into
Conversation
mzeng-openai
marked this pull request as ready for review
September 18, 2026 19:22
mzeng-openai
force-pushed
the
dev/mzeng/oauth-rejected-refresh-hook-3.2
branch
from
September 18, 2026 21:20
4884f93 to
76ae383
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_rejectedcallback 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
cargo test -p rmcp --lib --features auth,client,transport-streamable-http-client,reqwest transport::auth::tests::passed all 185 tests.git diff --checkpassed.