Add pathVariableNames
and queryVariableNames
getters in UriTemplate
#609
+83
−0
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.
This PR adds two new getter methods to the
UriTemplate
class that distinguish between path-like variables (which identify core resources) and query-like variables (which are optional parameters). This will enable the MCP Inspector to allow resource browsing with only essential path variables filled, while treating query parameters as optional filters.Motivation and Context
The MCP Inspector currently requires all URI template variables to be filled before allowing reading of resources from resource templates, which makes it difficult to explore available resources and understand what variables are needed. Some query parameters MAY be optional. This change enables better resource discovery by distinguishing between path-like variables (which identify the core resource) and query-like variables (which are optional filters/parameters).
This addresses the need for more intuitive resource browsing in MCP Inspector, where users should be able to access resources with only essential path variables while treating query parameters as optional enhancements.
How Has This Been Tested?
database://users/{id}{?limit,offset}
Breaking Changes
No breaking changes. This is a purely additive feature that maintains full backward compatibility with existing code.
Types of changes
Checklist
Additional context
Implementation Details:
pathVariableNames
: Returns variables from path-like expansions (""
,"+"
,"#"
,"."
,"/"
operators)queryVariableNames
: Returns variables from query-like expansions ("?"
,"&"
operators)variableNames
getter for full compatibilityUse Case Example:
This change will enable MCP Inspector to allow browsing
database://users/123/posts
without requiring query parameters, while still showing what optional filters are available.RFC 6570 Compliance: