MCP Server E2E Testing Example

by mkusaka

148 downloads
Not rated
GitHub

Description

# 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…

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

Author
mkusaka
Downloads
148
Categories
Other

- 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

Clone the repository, install dependencies with pnpm install, then run the desired test suite: pnpm vitest run tests/e2e/raw.spec.ts (spawn‑based raw tests) or pnpm vitest run tests/e2e/sdk.spec.ts (in‑memory SDK tests). Convenience scripts (pnpm run test:raw, pnpm run test:sdk, pnpm run test) can be added to package.json.

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:

- 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

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.