fix: store resource in session storage #632
Open
+41
−1
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.
Fixes a bug where the
resource
URL was lost during the OAuth redirect, causing aresource parameter mismatch
error during the token exchange.Motivation and Context
During the end-to-end OAuth flow in the Inspector's debug UI, the final token exchange step was failing with a
resource parameter mismatch
error.The root cause was that the
resource
URL, determined during the initial metadata discovery step, was only being stored in the component's volatile in-memory state. When the user is redirected to the authorization server and then back to the Inspector, the page reloads, wiping out this in-memory state.As a result, the final
/token
request was being sent withresource=undefined
, which the authorization server correctly rejected. This change fixes the bug by ensuring theresource
URL is persisted across the redirect.How Has This Been Tested?
This has been tested by running the full end-to-end OAuth flow within the MCP Inspector's debug UI against a live resource server.
resource parameter mismatch
error.resource
URL is correctly retrieved fromsessionStorage
and included in the/token
request, and valid tokens are received.Breaking Changes
None. This is a bug fix internal to the Inspector's state management and does not alter any public APIs or user-facing configurations.
Types of changes
Checklist
Additional context
The fix follows the existing pattern for persisting OAuth state in the
DebugInspectorOAuthClientProvider
.RESOURCE_URL
key was added toconstants.ts
.saveResource
andgetResource
methods were added to theDebugInspectorOAuthClientProvider
, usingsessionStorage
as the persistence layer.saveResource
after discovery andgetResource
before initiating the token exchange.This ensures the
resource
URL reliably survives the page reload inherent in the OAuth redirect flow.