Skip to content

Conversation

@nielskaspers
Copy link

@nielskaspers nielskaspers commented Jan 20, 2026

Summary

Adds comprehensive Vitest test coverage for the Everything Server, addressing #2925.

  • 124 tests across tools, prompts, resources, and server
  • 71% overall coverage (was 0%)
  • All 16 tools, all 4 prompts tested

Coverage by Component

Component Coverage Tests
Tools 93% 61
Prompts 91% 18
Resources 65% 31
Server 63% 8
Registrations 100% 6

Tools (16/16 tested)

All tools at 100% except:

  • get-roots-list (35%) - capability-gated branches
  • gzip-file-as-resource (84%) - network error branches

Not Unit Tested

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

Test Files

__tests__/tools.test.ts        - 61 tests (all 16 tools)
__tests__/prompts.test.ts      - 18 tests (all 4 prompts)
__tests__/resources.test.ts    - 31 tests (templates, session, files, subscriptions)
__tests__/server.test.ts       - 8 tests (createServer factory)
__tests__/registrations.test.ts - 6 tests (index wiring files)
vitest.config.ts               - test configuration

Test Plan

  • All 124 tests pass locally
  • Coverage report generated with v8
  • Mock server pattern matches existing test patterns in filesystem/memory servers

nielskaspers and others added 3 commits January 20, 2026 23:58
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 modelcontextprotocol#2925

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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>
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant