modelcontextprotocol / modelcontextprotocol/python-sdk

Add add_resource_template() to MCPServer

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

还没有人认领这个 Issue。

v2
主要语言
Python
星标
24.3k
派生
4k
平均合并
1 天 1 小时
30 天内合并 PR
31

描述

Description

MCPServer and ResourceManager have add_resource() method for static Resources, but there is no way to handle ResourceTemplate without using @resource decorator.

I am implementing the following workaround using the decorator for my usecase, but it is a bit odd.

server = MCPServer("...")

# Configure resources (implemented in other files)
server.resource("resource://users")(resources.list_users)
server.resource("resource://users/{id}")(resources.get_user)
References

It was implemented in #3208.

贡献指南

打开贡献指南

从这里开始

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

调研方向

从 MCPServer 和 ResourceManager add_resource() 入口开始,然后阅读 #3208 中的实现。确定 ResourceTemplate 如何通过现有的装饰器路径进行处理,并定义匹配的直接 API。完成标准是调用方可以在不使用 @resource 的情况下注册 ResourceTemplate,并为新行为提供覆盖测试。

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

评估

技术栈
python
领域
backend-api-design
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
活跃
描述清晰度
基本清楚
新手友好度
68/100

把新 issue 发到你的邮箱

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