Open
Description
Description
When using ResourceTemplate with optional parameters (e.g., {param?}
), if a user selects <Empty>
from the completion dropdown, the resulting URI doesn't match the template pattern, causing the resource to fail to load.
The resource kubernetes://resources/nodes/ was not found.
Steps to Reproduce
- Create a ResourceTemplate with an optional parameter:
"scheme://path/{required}/{optional?}"
- User selects a value for
required
parameter - User selects
<Empty>
for theoptional
parameter from the completion dropdown - The resulting URI becomes something like
scheme://path/required/<Empty>
- This URI doesn't match the original template pattern and fails validation
Expected Behavior
When a user selects <Empty>
for an optional parameter, the URI should either:
- Omit that path segment entirely (e.g.,
scheme://path/required
) - Map
<Empty>
to an empty string and handle it gracefully in the URI parsing
Current Workaround
We have to manually handle both cases in our readCallback:
scheme://path/required
(when optional param is truly omitted)scheme://path/required/<Empty>
(when user explicitly selects<Empty>
)
Impact
This makes ResourceTemplates with optional parameters brittle and requires additional error-prone parsing logic in every implementation.
Environment
- MCP TypeScript SDK version: latest
- Context: ResourceTemplate with pattern like
kubernetes://resources/{resourceType}/{namespace?}
Metadata
Metadata
Assignees
Labels
No labels