mcp: add ListResourcesHandler for dynamic resources/list#1002
Open
piyushbag wants to merge 3 commits into
Open
mcp: add ListResourcesHandler for dynamic resources/list#1002piyushbag wants to merge 3 commits into
piyushbag wants to merge 3 commits into
Conversation
Adds ServerOptions.ListResourcesHandler so gateway and template-backed servers can serve resources/list on demand. Static AddResource entries are listed first when present; handler cursors pass through when they are not. Fixes modelcontextprotocol#998
Author
|
Local verification on I kept |
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
resources/listis backed only by a static in-memory set populated viaAddResource. Gateway servers that proxy upstream catalogs and template-served skill assets cannot enumerate resources on demand: reads work viaResourceHandler, but listing does not.Approach
Add
ListResourcesHandleronServerOptions, analogous toResourceHandlerfor reads:resourceswhen the handler is set, even if no resources were added statically.resources/directory/readbacking is intentionally deferred until custom-method support (#956) lands.Why this helps
resources/listin middleware.AddResourcebehavior when no handler is configured.Test plan
go test ./mcp/ -run TestListResourcesHandlergo test ./...go test -race ./mcp/ -run TestListResourcesHandlerFixes #998