modelcontextprotocol / modelcontextprotocol/java-sdk

Resource templates should support handlers

未关闭
#534 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

enhancement feature/repositories P2
主要语言
Java
星标
3.7k
派生
1.1k
平均合并
1 天 15 小时
30 天内合并 PR
9

描述

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.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先定位现有的 (A)syncResourceSpecification,以及资源和 prompts 使用的注册路径。跟踪 resource-template 请求的处理方式,然后定义一个具备 handler 能力的 specification 必须为 URI 参数公开哪些内容。完成标准是:模板化资源能够解析请求参数并提供内容,而无需预先注册每个 URI。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
api, backend-api-design
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。