Commit Graph

11 Commits

Author SHA1 Message Date
cliffhall
9ade57133f Fix #3234 -
"Everything Server crashes when multiple clients reconnect"

* In index.ts
  - added a variable to hold the initialize timeout
  - store the timeout in the oninitialized handler
  - clear the timeout in the cleanup callback

* In roots.ts
  - In the catch block of syncRoots, log the error to the console via .error rather than attempting to send to the client because the most probable case here is that we don't have a connection.

* In simulate-research-query.ts
  - remove redundant local variable in getTask
* Everywhere else, prettier.
2026-01-23 13:26:02 -05:00
olaservo
5156cff9dc fix(everything): implement graceful HTTP elicitation degradation
Implement graceful degradation for elicitation on HTTP transport:
- STDIO: Full elicitation works via sendRequest
- HTTP: Catches elicitation failure, uses default interpretation
- Task completes successfully on both transports

simulate-research-query now uses try-catch around sendRequest and
includes explanatory message when elicitation is skipped on HTTP.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 19:19:32 -07:00
cliffhall
f8933ec3e6 Sync roots at startup. This was deferred to list_roots tool is used, but I'm putting it back.
The syncRoots call should be idempotent, requesting roots if they haven't been yet for the session, but always retuning the cached roots otherwise. That could be deferred but setting the handler for roots_list changed note should not.

* In server/roots.ts
  - only set the notification handler and call for initial roots list if the roots aren't already cached for this client.

* In server/index.ts
  - in the oninitialized handler
    - get the sessionId from the transport
    - set a 350ms timeout to call syncRoots with the server and sessionId
      - this delay cause it to run after the `notifications/initialized` handler finishes, otherwise, the request gets lost.

* All other changes attributable to prettier
2025-12-17 17:46:24 -05:00
cliffhall
1b8f376b90 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`
2025-12-15 17:51:30 -05:00
cliffhall
20527e4175 Updated doc in all tools 2025-12-13 15:55:07 -05:00
cliffhall
7b8592538f Updated doc in all tools 2025-12-13 15:52:32 -05:00
cliffhall
b8074f9b9c Update doc in tools/trigger-elicitation-request.ts and trigger-long-running-operation.ts 2025-12-13 15:16:37 -05:00
cliffhall
8291c0b290 Update doc in tools/trigger-elicitation-request.ts 2025-12-13 15:12:51 -05:00
cliffhall
3f5e5cfb81 Update doc in tools/trigger-elicitation-request.ts 2025-12-13 15:09:26 -05:00
cliffhall
18ef6aa69b [WIP] Refactor everything server to be more modular and use recommended APIs.
Adding Trigger Elicitation Request and Get Roots List tools

* Updated architecture.md

* Added roots.ts
  - tracks roots by sessionId
  - setRootsListChangedHandler
    - listens for roots changed notification from the client
      - updates the roots map by sessionId
      - sends log notification or error to the client

* In server/index.ts
  - import setRootsListChangedHandler
  - in clientConnected callback
    - call setRootsListChangedHandler passing server and sessionId

* In sse.ts, stdio.ts, and streamableHttp.ts
  - receive clientConnected from server factory
  - call clientConnected when server is connected to transport
* Added get-roots-list.ts
  - registerGetRootsListTool
    - Registers the 'get-roots-list' tool with the given MCP server.

* Added trigger-elicitation-request.ts
  - registerTriggerElicitationRequestTool
    - registered tool sends an elicitation request that exercises all supported field types

* In tools/index.ts
  - imports registerTriggerElicitationRequestTool and registerGetRootsListTool
  - in registerTools
    - call registerTriggerElicitationRequestTool and registerGetRootsListTool, passing server
2025-12-11 20:25:37 -05:00
cliffhall
ea6fe271cd [WIP] Refactor everything server to be more modular and use recommended APIs.
Adding Trigger Elicitation Request tool

* Updated architecture.md

* Added trigger-elicitation-request.ts
  - registerTriggerElicitationRequestTool
    - registered tool sends an elicitation request that exercises all supported field types

* In tools/index.ts
  - imports registerTriggerElicitationRequestTool
  - in registerTools
    - call registerTriggerElicitationRequestTool passing server
2025-12-11 18:10:37 -05:00