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)
The matrix
Every SDK major, every protocol revision
| Lane | 2025-11-25 | 2026-07-28 |
|---|---|---|
| v1 | the only revision it negotiates | throws - the v1 SDK cannot serve it |
| v2 | legacy mode, no doubles available | default, full support |
| stdio | the only revision it negotiates | throws - stdio is driven by v1 |
| url | legacy mode, no doubles available | pinned, 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.