Vitest-native testing for MCP servers

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

test/completions.test.ts

SDK v12025-11-25
  • completes a prompt argument by prefix15ms
  • a non-matching prefix completes to nothing2ms
  • completes a resource-template variable1ms
3 passed (3)
SDK v22026-07-28
  • completes a prompt argument by prefix55ms
  • a non-matching prefix completes to nothing4ms
  • completes a resource-template variable3ms
3 passed (3)
latest v0.4.2 on npm

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.