MCP Server E2E Testing Example
About
# MCP Server E2E Testing Example A minimal example repository demonstrating two patterns for end‑to‑end (E2E) testing a TypeScript MCP (Model Context Protocol) server using [Vitest](https://vitest.dev/): - **Raw approach**: Spawning the CLI with `tsx` and communicating over `stdio` (JSON‑RPC). - **SDK approach**…
Details
- License
- MIT
Explore
- Two E2E testing approaches: raw and SDK
- Uses Vitest as the test runner
- Raw approach spawns CLI with tsx and uses stdio
- SDK approach uses Client and InMemoryTransport
- Includes an example server with resources, prompts, and tools
- Ready‑to‑run test suites and a reproducible layout
- Node.js ≥ 16
- pnpm installed globally
- Git
pnpm install
``
---
This repository is intended as an example/template. Feel free to:
- Adapt the src/server.ts factory for your own MCP server raw.spec.ts
- Expand and sdk.spec.ts` with additional test cases
- Integrate into your CI pipeline
---
A minimal example repository demonstrating two patterns for end‑to‑end (E2E) testing a TypeScript MCP (Model Context Protocol) server using Vitest:
- Raw approach: Spawning the CLI with tsx and communicating over stdio (JSON‑RPC).
- SDK approach: Using the official MCP SDK’s Client and InMemoryTransport for in‑memory RPC.
Repository: https://github.com/mkusaka/mcp-server-e2e-testing-example
---
📁 Repository Layout
.
├── LICENSE
├── README.md
├── package.json
├── pnpm-lock.yaml
├── src
│ ├── cli.ts # CLI entrypoint (tsx + stdio transport)
│ └── server.ts # createServer() factory (resources, prompts, tools)
├── tests
│ └── e2e
│ ├── raw.spec.ts # spawn‑based E2E tests
│ └── sdk.spec.ts # SDK/InMemoryTransport‑based E2E tests
└── tsconfig.json
---
🚀 Getting Started
Prerequisites
- Node.js ≥ 16
- pnpm installed globally
- Git
Installation
```bash
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



