mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-21 05:15:21 +02:00
Demonstrate registration of tools conditioned upon client capability support. Also, obviated need for clientConnected callback to pass sessionId because we defer initial fetching of roots happens when you run the get-roots-list tool.
* In how-it-works.md, - added a section on conditional tool registration * In server/index.ts - import registerConditionalTools - in an oninitialized handler for the server, call registerConditionalTools - removed clientConnected from ServerFactoryResponse and all mentions in docs * In tools/index.ts - export a registerConditionalTools function - refactor/move calls to registerGetRootsListTool, registerTriggerElicitationRequestTool, and registerTriggerSamplingRequestTool out of registerTools and into registerConditionalTools * In server/roots.ts - only act if client supports roots - remove setInterval from call to requestRoots. It isn't happening during the initialze handshake anymore, so it doesn't interfere with that process if called immediaately * In get-roots-list.ts, trigger-elicitation-request.ts, and trigger-sampling-request.ts, - only register tool if client supports capability * Throughout the rest of the files, removing all references to `clientConnected`
This commit is contained in:
@@ -48,5 +48,5 @@ The server factory is `src/everything/server/index.ts` and registers all feature
|
||||
- Export a `registerX(server)` function that registers new items with the MCP SDK in the same style as existing ones.
|
||||
- Wire your new module into the central index (e.g., update `tools/index.ts`, `resources/index.ts`, or `prompts/index.ts`).
|
||||
- Ensure schemas (for tools) are accurate JSON Schema and include helpful descriptions and examples.
|
||||
- If the feature is session‑aware, accept/pass `sessionId` where needed. See the `clientConnected(sessionId)` pattern in `server/index.ts` and usages in `logging.ts` and `subscriptions.ts`.
|
||||
`server/index.ts` and usages in `logging.ts` and `subscriptions.ts`.
|
||||
- Keep the docs in `src/everything/docs/` up to date if you add or modify noteworthy features.
|
||||
|
||||
Reference in New Issue
Block a user