modelcontextprotocol / modelcontextprotocol/java-sdk
Resource templates should support handlers
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 1.1k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 9
Description
Expected Behavior
There should be a ResourceTemplateSpecification, similar to (A)syncResourceSpecification, so that we can have access to an exchange and handle requests properly.
Current Behavior
Currently unlike resources or prompts, there's no way to define a handler for resource templates. The same spec is used in all contexts, but doesn't allow supplying a handler.
Context
This is a serious limitation which defeats the concept of resource templates. For example, we would like to implement something like this in Micronaut MCP:
@ResourceTemplate(uriTemplate = "file://my-resource/{item}", description="A templated resource")
String templated(String item) {
return "Hello, " + item;
}
That is, the content of the template depends on the URI parameters. Today there's no way to do this because the only thing we can do is register resource templates, but no handlers. Therefore, in order to serve the resources, we have to register all of them as regular resources, which makes the templating redundant. This also assumes that we can know in advance all the combinations of valid path elements values, which is obviously not possible.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing (A)syncResourceSpecification and the registration paths used for resources and prompts. Trace how resource-template requests are handled, then define what a handler-capable specification must expose for URI parameters. Done means templated resources can resolve request parameters and serve content without pre-registering every URI.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100