McpServer: dynamic registration per request (tools known only when a request arrives, and different for each caller)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
Read the McpServer registration and request handling code, then compare the proposed behavior with #10442, #10444, and #10880. The issue reports a working implementation and tests against Effect's source, but leaves the API shape and how it fits the registry open for discussion. Start by following the maintainer decision on those questions; done means an agreed design and a pull request that supports per-request, caller-specific tool listing and calls.
由索引模型根据 Issue 内容生成。
描述
Note: everything below was written by an AI agent working on the author's behalf and may not have been reviewed by a human.
This is AI-generated; I don't have strong opinions on the API or developer experience and am glad to take whatever shape you prefer, but I do need the functionality.
The problem: dynamic registration
McpServer serves what was registered with addTool or a toolkit. That fits a server whose tools are known when it is built. I am building servers whose tools are not:
- A proxy. A server that serves another MCP server's tools again, reached with the caller's own credential. The upstream's tools can only be listed as that caller, and they change between requests.
- Tools derived from a document. A server that turns an API description fetched at run time into tools.
- Tools that depend on the caller. Two callers of the same server see different tools.
All three are the same problem: what the server has registered is not fixed, and it is not even one set. MCP middleware and visibility (from #9610) can hide registered tools from a caller, but they cannot add tools the server never registered.
#10442 ("Support dynamic MCP registrations") solves the first half of this. With removeTool and its siblings, declaredFeatures and list-change notifications, a running server can change its own registered set. What it leaves open is the second half: the set is still the server's, one set for every caller. To serve a caller's own tools with it, a server has to add and remove registrations around each request. On a server shared by concurrent callers that makes one caller's tools visible to another, and a large upstream list is registered and withdrawn again on every request.
So the question I am raising is how dynamic registration should work when the registrations are computed per request, for the caller making it.
One possible shape
A registration whose tools are computed on each request, beside the fixed ones:
const server = yield* McpServer.McpServer
yield* server.addToolSource({
// Runs on every `tools/list`, inside the request's middleware, so it can read the caller.
list: upstream.listTools,
// Runs for a `tools/call` whose name no registered tool has.
call: (name, payload) => upstream.callTool(name, payload),
// Optional: which names this registration answers for, when there are several.
owns: (name) => name.startsWith("upstream_")
})
listreturns the tools, or{ tools, ttlMs?, cacheScope?, _meta? }, which is merged into thetools/listresult and its cache hint on2026-07-28.callreturns aCallToolResult(orInputRequiredon2026-07-28). Its failures map asaddTool's do.- A fixed registration shadows a per-request tool of the same name. A per-request tool is listed only from the registration its calls would go to.
- Nothing is kept between requests: the server holds no copy of what a request listed.
- The server has no input schema for such a tool, so it does not validate arguments; the registration does.
I have this working against Effect's source, with tests: per-request listing, routing with owns, middleware and visibility, errors, two concurrent callers on layerHttpRequestScoped, and per-caller sessions on layerHttp.
I am not attached to the name or to it being a separate method. If per-request registration belongs inside #10442's registry, for example as a registration whose tools are an Effect, I would rather build that. I did not want to open a competing pull request against a design in review.
#10444 lets the server's static cacheHints.tools be "public". If that lands, how a per-request registration's hint combines with the server's static one is the one place the two meet.
Questions
- Is per-request registration part of what dynamic registration in
McpServershould cover, or should a proxy be built another way? - If yes: should it be its own registration (
addToolSource({ list, call, owns? })), or part of #10442's registry? - Should other registrations get the same? I also need it for skills (details in a comment below) and for MCP Events, where #10880 registers event types when the server is built. Resources and prompts I have not needed.
I am happy to open a pull request, rebased onto whichever of main or v4/next-minor you prefer, once the shape is agreed.
- 主要语言
- TypeScript
- 星标
- 16.7k
- 派生
- 808
- 平均合并
- 21 小时 22 分钟
- 30 天内合并 PR
- 486
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Effect-TS/effect 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
`@effect/ui-native` (Effect-TS/ui): `kit/VirtualList` `list` part widens `R` to `any`, poisoning enclosing components可能已有人在做 @effect-bot 今天认领。 未关闭
Effect-TS/effect#11097 · 已指派 1 人 ·
维护者通常 1 天内回复
-
`@effect/ui-native` (Effect-TS/ui): Controlled `input` rejected-edit restore never calls `host.commit()`可能已有人在做 @effect-bot 今天认领。 未关闭
Effect-TS/effect#11096 · 已指派 1 人 ·
维护者通常 1 天内回复
相似的 Issue
-
check:failed streams:edit
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 1 天内回复
-
[Bug]: Critical path skips a child span that ends exactly when the next one starts可能已有人在做 @Piyush4801 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
jaegertracing/jaeger-ui#4865 · 1 条评论 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 90/100
anthropics/claude-code#112972 ·
-
Type: Improvement
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复