McpServer: dynamic registration per request (tools known only when a request arrives, and different for each caller)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- backend-api-design
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 16.7k
- Fork
- 808
- Merge medio
- 21h 22m
- PR unite (30g)
- 486
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Effect-TS/effect
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
`@effect/ui-native` (Effect-TS/ui): `kit/VirtualList` `list` part widens `R` to `any`, poisoning enclosing componentsForse già presa @effect-bot l’ha presa oggi. Aperta
Effect-TS/effect#11097 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
`@effect/ui-native` (Effect-TS/ui): Controlled `input` rejected-edit restore never calls `host.commit()`Forse già presa @effect-bot l’ha presa oggi. Aperta
Effect-TS/effect#11096 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Effect-TS/effect
Issue simili
-
check:failed streams:edit
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
iptv-org/iptv#60585 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Critical path skips a child span that ends exactly when the next one startsForse già presa @Piyush4801 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
jaegertracing/jaeger-ui#4865 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
anthropics/claude-code#112972 ·
-
Type: Improvement
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno