Proposal: dynamic/lazy resources/list (and directory-read) backing for gateway/proxy and template-served catalogs
维护者通常 1 天内回复
评估
调研方向
从 (*Server).listResources 和 ServerOptions 注册路径开始,然后比较现有的 ResourceHandler、AddResourceTemplate 以及分页行为。检查 Middleware workaround 及其与 resources/directory/read 自定义方法支持之间的关系;当已约定的动态列表设计以清晰的优先级或组合语义实现时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Problem
resources/list can only be served from a static, in-memory set. Resources are materialized up front via AddResource (removed via RemoveResources), and (*Server).listResources enumerates that featureSet directly — there is no handler/callback that computes the list on demand. For two important classes of server this isn't just inconvenient, it's a structural mismatch.
1. Gateway / proxy servers (the important case)
A skill (or resource) gateway fronts one or more upstream catalogs it does not own — another registry, a remote index, or several backend MCP servers. The authoritative list lives elsewhere and changes independently of this process. To serve resources/list from a static set, the gateway would have to mirror the entire upstream catalog into memory at startup and keep it continuously in sync — which defeats the purpose of being a gateway, doesn't scale to large/unbounded upstreams, and is racy against upstream changes.
What a gateway actually needs is to answer resources/list by querying upstream on demand, passing the client's pagination cursor through. There is no first-class way to do that today.
2. Template-served assets are non-enumerable by construction
Skills are served as a directory of files. A server typically exposes a skill's files via a resource template (skill://<skill>/{+path}) plus one read handler, so it doesn't have to AddResource every individual file. But a URI template matches infinitely many URIs — you cannot derive the file list from the template definition. So those assets are fully readable yet absent from any static set: resources/list won't show them, and resources/directory/read (below) backed by the static set returns empty.
Relationship to resources/directory/read (#956 / SEP-2640)
The Skills-over-MCP WG is adding a resources/directory/read method (SEP-2640) so hosts can enumerate the files within a skill directory — e.g. to materialize a skill to disk. Implementing that verb in this SDK depends on custom-method support (#956). But even once the verb exists, it hits exactly this problem: for a template-served or gateway-proxied skill, the directory's children cannot come from the static set — resources/directory/read must be backed by a server-provided dynamic listing.
So the two are a pair:
- #956 — adds the
resources/directory/readverb (custom method). - this issue — gives
resources/list/ directory-read a dynamic backing so template-served and gateway-proxied entries can actually be enumerated.
Neither alone lets a Go skills/gateway server both serve and enumerate a catalog whose contents aren't pre-materialized.
What already works (to scope precisely)
resources/read is already dynamic — content comes from a ResourceHandler, and resource templates (AddResourceTemplate + ResourceTemplate.Matches) let one handler serve an unbounded URI space. The asymmetry is the whole point: templates make reads unbounded, but nothing makes listing/enumeration unbounded or on-demand.
Workarounds today (and why they fall short)
- Receiving middleware.
MiddlewarewrapsMethodHandler func(ctx, method string, req Request)(Result, error), so middleware can interceptresources/listand synthesize a*ListResourcesResult, short-circuiting the static handler. It works, but it's untyped (switch on a string method, type-assertreq/Result), bypasses the SDK's built-in pagination, and sits awkwardly beside the otherwise-typed registration model. - Per-session server via the
getServercallback (as suggested in #216). Good for per-connection configuration, but it still requires materializing a concrete set per server — it doesn't help a catalog that is upstream, generated, or too large to enumerate eagerly.
Proposal
Add a first-class way to serve resources/list (and back resources/directory/read) from a handler, with cursor-based pagination handled by the SDK — analogous to how ResourceHandler/templates already make reads dynamic. Illustrative shape (not prescriptive):
// Serves resources/list on demand; receives the request (incl. pagination cursor)
// and returns a page of resources plus the next cursor.
type ListResourcesHandler func(context.Context, *ListResourcesRequest) (*ListResourcesResult, error)
opts := &mcp.ServerOptions{
ListResourcesHandler: func(ctx context.Context, req *mcp.ListResourcesRequest) (*mcp.ListResourcesResult, error) {
// e.g. proxy upstream using req.Params.Cursor, or enumerate a template's namespace ...
},
}
When set, the handler would take precedence over (or compose with) the registered static set, and the same mechanism would back directory enumeration for a directory URI.
Questions for maintainers
- Was the static-set model for
resources/lista deliberate choice (uniformity with tools/prompts feature sets), and would a dynamic list handler be acceptable — or is middleware / per-session-server the intended long-term answer for gateway and unbounded catalogs? - If a handler is acceptable: should it replace or merge with the registered set, and should the same backing apply to
resources/directory/read(#956) and, for consistency,prompts/list/tools/list?
Happy to prototype if there's interest in the direction.
- 主要语言
- Go
- 星标
- 5.4k
- 派生
- 623
- 平均合并
- 22 小时 10 分钟
- 30 天内合并 PR
- 30
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelcontextprotocol/go-sdk 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
modelcontextprotocol/go-sdk#1557 ·
维护者通常 1 天内回复
-
Streamable HTTP (2026-07-28): tools/call with an out-of-range number in arguments fails because extractName decodes Arguments into any可能重新可做 @beiryu 于 10 天前认领,目前没有进行中的 PR。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
modelcontextprotocol/go-sdk#1534 · 1 条评论 ·
维护者通常 1 天内回复
-
Expose generic `SendNotification` on `ServerSession` for custom protocol extensions可能重新可做 关联的 PR 已关闭且未合并。 未关闭needs investigation
难度 2/5 1-3 小时 新手友好度 72/100
modelcontextprotocol/go-sdk#745 · 13 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 18/100
modelcontextprotocol/go-sdk#1555 ·
维护者通常 1 天内回复
-
mcp: 2026-07-28 client runs elicitation and sampling handlers for standalone server requests可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 3/5 1-2 天 新手友好度 35/100
modelcontextprotocol/go-sdk#1552 ·
维护者通常 1 天内回复
查看 modelcontextprotocol/go-sdk 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 86/100
apache/dubbo-admin#1659 ·
维护者通常 8 天内回复
-
taskmanager: a failed v1alpha1 backup leaves the partial backup behind可能已有人在做 @arshil42 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100