fix: resource refresh button now bypasses cache to re-read content#1155
Open
ctonneslan wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
fix: resource refresh button now bypasses cache to re-read content#1155ctonneslan wants to merge 1 commit intomodelcontextprotocol:mainfrom
ctonneslan wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
The refresh button in the Resources tab was not working because readResource() early-returns when the URI already exists in resourceContentMap. Since the content was cached from the first read, clicking refresh had no effect. Added a force parameter to readResource() that bypasses the cache check. The refresh button passes force=true while initial reads still use the cache for performance. Also fixes the issue where switching between resource template URIs (e.g. user://1 then user://2 then back to user://1) would show stale cached content without re-reading from the server. Fixes modelcontextprotocol#1120
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.
Problem
The refresh button in the Resources tab does nothing when clicked. This is because
readResource()early-returns when the URI already exists inresourceContentMap:Since the content was cached from the first read, clicking refresh has no effect. This also affects switching between resource template URIs (e.g.
user://1->user://2->user://1) where the cached content is shown without re-reading.Regression introduced around v0.20.0 when the
resourceContentMapcache was added.Fix
Added a
forceparameter toreadResource()that bypasses the cache check:The refresh button passes
force=true. Initial reads from the resource list still use the cache for performance.Changes
client/src/App.tsx: Addedforceparameter toreadResource(), updated prop wrapperclient/src/components/ResourcesTab.tsx: Updated prop type, refresh button passesforce=trueFixes #1120