Vitest-native testing for MCP servers

Matchers, snapshots, interaction doubles, and real external servers, on both MCP SDK majors.

server.test.ts

SDK v12025-11-25
  • connects and lists tools12ms
  • echo round-trips4ms
  • answers an elicitation7ms
  • collects progress notifications9ms
1 file 4 passed (4)
SDK v22026-07-28
  • connects and lists tools12ms
  • echo round-trips4ms
  • answers an elicitation7ms
  • collects progress notifications9ms
1 file 4 passed (4)

The matrix

Every SDK major, every protocol revision

Lane2025-11-252026-07-28
v1the only revision it negotiatesthrows - the v1 SDK cannot serve it
v2legacy mode, no doubles availabledefault, full support
stdiothe only revision it negotiatesthrows - stdio is driven by v1
urllegacy mode, no doubles availablepinned, otherwise auto-negotiated

Coverage

What mcp-vitest covers

Both SDK majors
v1 and v2 servers, detected automatically. No adapter to write.
Lifecycle coverage
Run the same tests against the 2025 and 2026-07-28 protocol revisions.
Interaction doubles
Answer a server's sampling, elicitation, and roots requests from your test.
Typed matchers
Seven of them, with TypeScript augmentation and did-you-mean suggestions.
External servers
Spawn one over stdio or point at a running URL. Everything else works unchanged.
Regression safety
Snapshot manifests normalized so key order and absent optionals never churn them.

Same suite. Both SDK majors. Both protocol eras.