227 Commits

Author SHA1 Message Date
Ola Hungerford
ad3e660cc1 Merge pull request #3252 from dotsetgreg/fix/session-resource-reregistration
fix(everything): allow re-registration of session resources
2026-03-07 12:32:28 -07:00
Niels Kaspers
cd20aee6b4 Add experimental.tasks mock for new task-based tools
The upstream main added simulate-research-query and async tools that
use server.experimental.tasks.registerToolTask. Update mock servers
to include this API.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 23:21:49 +02:00
Niels Kaspers
0ca9921e20 Trim low-value tests per review feedback
Removed ~29 tests that were adding noise rather than coverage:
- Registration boilerplate tests (16): redundant with registrations.test.ts
- Redundant role/type checks (3): consolidated into behavioral tests
- "Should not throw" tests (6): consolidated into single lifecycle test
- Constant identity tests (2): provided no safety net
- expect(true).toBe(true) test (1): replaced with actual assertion
- Weak capability test (1): removed, handler check already exists

Strengthened remaining tests:
- Resource templates test now verifies specific resource names
- File resources test now asserts registerResource was called

Test count: 124 → 95 (29 removed)
Coverage unchanged at ~71%

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 23:20:05 +02:00
Niels Kaspers
9c0921276c Add tests for server factory, registrations, and resources
Additional test coverage:
- server/index.ts: createServer factory, cleanup function (91% coverage)
- tools/index.ts: registerTools, registerConditionalTools (100% coverage)
- prompts/index.ts: registerPrompts (100% coverage)
- resources/index.ts: registerResources, readInstructions (88% coverage)
- resources/files.ts: registerFileResources (54% coverage)
- resources/subscriptions.ts: handlers, begin/stop updates (47% coverage)

Test count: 124 tests (was 102)
Coverage: 71.35% overall (was 64.73%)
- Tools: 93.12%
- Prompts: 90.53%
- Server: 62.93%
- Resources: 65.44%

Note: Transport files (stdio.ts, sse.ts, streamableHttp.ts) are entry
points that start Express servers. These require integration tests
rather than unit tests.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 23:20:05 +02:00
Niels Kaspers
f48efe3206 Add tests for remaining 6 tools
Complete test coverage for all 16 Everything Server tools:

New tests added:
- toggle-simulated-logging: start/stop logging toggle, session handling
- toggle-subscriber-updates: start/stop updates toggle, session handling
- trigger-sampling-request: capability check, sampling request/response
- trigger-elicitation-request: capability check, accept/decline/cancel actions
- get-roots-list: capability check, registration
- gzip-file-as-resource: compression, resource/resourceLink output types

Test count: 102 tests (was 81)
Coverage: 64.73% overall, 90.93% tools (was 34%, 40%)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 23:20:05 +02:00
Niels Kaspers
93a4f763b6 Add Vitest tests for Everything Server
Adds comprehensive test coverage for the Everything Server including:

Tools (10 tools tested):
- echo: message echoing with validation
- get-sum: number addition with edge cases
- get-env: environment variable retrieval
- get-tiny-image: image content blocks
- get-structured-content: weather data for all cities
- get-annotated-message: priority/audience annotations
- trigger-long-running-operation: progress notifications
- get-resource-links: dynamic resource link generation
- get-resource-reference: text/blob resource validation

Prompts (4 prompts tested):
- simple-prompt: no-argument prompt
- args-prompt: city/state arguments
- completable-prompt: department/name completions
- resource-prompt: embedded resource references

Resources:
- templates.ts: URI generation, text/blob resources
- session.ts: session-scoped resource registration

Test infrastructure:
- vitest.config.ts with v8 coverage
- Mock server helper for capturing registered handlers
- 81 tests, all passing

Closes #2925

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 23:20:05 +02:00
dependabot[bot]
e95bb9c44b Bump the npm_and_yarn group across 1 directory with 2 updates
Bumps the npm_and_yarn group with 1 update in the / directory: [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/typescript-sdk).


Updates `@modelcontextprotocol/sdk` from 1.25.2 to 1.26.0
- [Release notes](https://github.com/modelcontextprotocol/typescript-sdk/releases)
- [Commits](https://github.com/modelcontextprotocol/typescript-sdk/compare/v1.25.2...v1.26.0)

Updates `hono` from 4.11.3 to 4.11.7
- [Release notes](https://github.com/honojs/hono/releases)
- [Commits](https://github.com/honojs/hono/compare/v4.11.3...v4.11.7)

---
updated-dependencies:
- dependency-name: "@modelcontextprotocol/sdk"
  dependency-version: 1.26.0
  dependency-type: direct:production
  dependency-group: npm_and_yarn
- dependency-name: hono
  dependency-version: 4.11.7
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-04 20:38:38 +00:00
Ola Hungerford
760829a778 Merge pull request #3206 from modelcontextprotocol/chore/apache-2.0-license
chore: update licensing to Apache 2.0 for new contributions
2026-02-04 06:00:33 -07:00
Greg King
3e1be88c3b fix(everything): allow re-registration of session resources
When a tool like `gzip-file-as-resource` is called multiple times with the
same output name (especially the default `README.md.gz`), the server would
throw "Resource already registered" because the SDK doesn't allow
registering duplicate URIs.

This fix:
- Tracks registered resources by URI in a module-level Map
- Before registering a new resource, checks if the URI already exists
- If it does, removes the old resource using the SDK's `remove()` method
- Then registers the new resource with fresh content

This allows tools to be called repeatedly with the same parameters without
errors, which is important for LLM agents that may retry tool calls.

Found using Bellwether (https://bellwether.sh), an MCP server validation tool.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 09:10:58 -05:00
cliffhall
ae1e7a5500 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.
2026-01-23 13:35:32 -05:00
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
1542b65154 fix(everything): move task to params.task and remove pollInterval from requests
- Use params.task instead of params._meta.task for task metadata
- Remove pollInterval from task requests (only available on result)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 18:39:29 -07:00
Ola Hungerford
a160653441 Apply suggestions from code review
Co-authored-by: Cliff Hall <cliff@futurescale.com>
2026-01-21 17:55:10 -07: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
olaservo
1cda86effb docs(everything): update features.md for direct elicitation flow
Update documentation to reflect that simulate-research-query now sends
elicitation requests directly from the background task instead of using
the tasks/result side-channel approach.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 17:44:55 -07:00
olaservo
c53a0f3799 fix(everything): send elicitation directly from background task
Instead of waiting for the client to call tasks/result to trigger
elicitation, the server now sends elicitation/create directly from
the background process using sendRequest. This simplifies the flow:

- Server sends elicitation proactively when clarification is needed
- Client receives and handles it via existing elicitation handler
- Task resumes and completes after receiving the response
- Client's polling sees completed status

This approach avoids requiring the client to detect input_required
status and call tasks/result as a side-channel.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 17:42:26 -07:00
Ola Hungerford
6556e339cb Merge branch 'main' into add-tasks-support 2026-01-17 14:05:35 -07:00
Adam Jones
6b36e3c223 chore: update licensing to Apache 2.0 for new contributions 2026-01-12 22:50:22 +00:00
cliffhall
677f40a38f In roots.ts, clientCapabilites.roots and response.roots are optional.
Fixes #2818
2026-01-10 17:40:58 -05:00
cliffhall
7300631a5c In roots.ts, clientCapabilites.roots and response.roots are optional.
Fixes #2818
2026-01-10 17:32:20 -05:00
olaservo
9d863fb7e6 feat: add async sampling and elicitation tools
Add tools that demonstrate bidirectional MCP tasks where the server
sends requests to the client for async execution:

- trigger-sampling-request-async: Send sampling request with task
  params, client creates task and executes LLM call in background,
  server polls for completion and retrieves result

- trigger-elicitation-request-async: Same pattern for user input,
  useful when user may take time to fill out forms

Both tools:
- Check client capabilities (tasks.requests.sampling/elicitation)
- Accept both CreateTaskResult and direct result responses
- Poll tasks/get for status updates
- Fetch final result via tasks/result

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 09:14:30 -07:00
olaservo
0208e93f85 feat(everything): add SEP-1686 Tasks support
- Add tasks capability with list, cancel, and requests.tools.call
- Add InMemoryTaskStore and InMemoryTaskMessageQueue from SDK experimental
- Add simulate-research-query tool demonstrating task lifecycle
- Task demonstrates working -> input_required -> completed status flow
- Uses elicitation for ambiguous queries when client supports it

Closes #3037

🦉 Generated with [Claude Code](https://claude.ai/code)
2026-01-09 06:48:53 -07:00
dependabot[bot]
737ce98e4a Bump @modelcontextprotocol/sdk
Bumps the npm_and_yarn group with 1 update in the / directory: [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/typescript-sdk).


Updates `@modelcontextprotocol/sdk` from 1.24.0 to 1.25.2
- [Release notes](https://github.com/modelcontextprotocol/typescript-sdk/releases)
- [Commits](https://github.com/modelcontextprotocol/typescript-sdk/compare/1.24.0...v1.25.2)

---
updated-dependencies:
- dependency-name: "@modelcontextprotocol/sdk"
  dependency-version: 1.25.2
  dependency-type: direct:production
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-07 16:49:05 +00:00
cliffhall
44faf3a200 Remove console log statements 2025-12-19 10:18:55 -05:00
Cliff Hall
53cc385d4e Update src/everything/AGENTS.md
Co-authored-by: adam jones <domdomegg+git@gmail.com>
2025-12-18 15:03:44 -05:00
cliffhall
17aaa455bb Sync roots at startup. This was deferred to list_roots tool is used, but I'm putting it back.
* In server/roots.ts
  - Updated function doc
2025-12-17 17:49:35 -05: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
c6daef707a Get roots unconditionally when syncRoots is called
* In server/roots.ts
  - in syncRoots, if roots are supported fetch them

* In get-roots-list.ts,
  - Don't import and inspect current roots map, just call syncRoots to get the list.
2025-12-15 19:37:56 -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
ebac6314cf Updated server instructions.md. See https://github.com/modelcontextprotocol/servers/pull/3121#discussion_r2616651611 2025-12-15 17:04:59 -05:00
cliffhall
8758a11b37 Updated server instructions.md. See https://github.com/modelcontextprotocol/servers/pull/3121#discussion_r2616651611 2025-12-15 17:04:35 -05:00
cliffhall
734d5c3ebb Updated server instructions.md. See https://github.com/modelcontextprotocol/servers/pull/3121#discussion_r2616651611 2025-12-15 17:01:33 -05:00
cliffhall
70feb6f2b0 Remove includeContext: "thisServer" from CreateMessageRequest in trigger-sampling-request.ts 2025-12-15 14:40:11 -05:00
cliffhall
e0f1c42159 Add listChanged capability for tools, prompts, and resources in servers/index.ts 2025-12-15 14:39:20 -05:00
cliffhall
cdbcdc551a Cache roots in get-roots-list.ts if list was not already present and had to be requested. 2025-12-13 16:25:28 -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
eed70bbbda Updated doc in trigger-sampling-request.ts 2025-12-13 15:48:41 -05:00
cliffhall
0ba86f8d4f Updated doc in echo.ts 2025-12-13 15:48:13 -05:00
cliffhall
29a20bfd0a Updated doc in get-annotated-message.ts 2025-12-13 15:46:57 -05:00
cliffhall
82cda366d6 Updated doc in get-env.ts 2025-12-13 15:45:24 -05:00
cliffhall
6ad8af7130 Updated doc in get-resource-reference.ts 2025-12-13 15:44:17 -05:00
cliffhall
8126179a0a Run pretter:fix 2025-12-13 15:43:00 -05:00
cliffhall
e1c1dcfac8 Use roots cache in get-roots-list tool
* In get-roots-list.ts, query the server's cache of the latest roots from the client and only request the list from the client if it doesn't exist.
* In roots.ts, export the roots map
2025-12-13 15:42:24 -05:00
cliffhall
6854902775 Use roots cache in get-roots-list tool
* In get-roots-list.ts, query the server's cache of the latest roots from the client and only request the list from the client if it doesn't exist.
* In roots.ts, export the roots map
2025-12-13 15:41:44 -05:00
cliffhall
77deef08ce Update doc in tools/gzip-file-as-resource.ts 2025-12-13 15:24:10 -05:00
cliffhall
cd5b728fb6 Update doc in tools/toggle-subscriber-updates.ts 2025-12-13 15:21:38 -05:00
cliffhall
ba098427d6 Update doc in tools/toggle-subscriber-updates.ts 2025-12-13 15:19:26 -05:00
cliffhall
45ea1e21f9 Update doc in tools/toggle-subscriber-updates.ts 2025-12-13 15:18:15 -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