mcpField
M
MCP Server E2E Testing Example

MCP Server E2E Testing Example

Local
github.com/mkusakaDeveloper Tools0Updated 18w ago

About MCP Server E2E Testing Example

A TypeScript example repository for developers who want to test MCP servers end to end with Vitest. It demonstrates both subprocess-based stdio testing and in-memory testing with the MCP SDK.

Key features

  1. 01Raw stdio JSON-RPC tests
  2. 02In-memory MCP SDK tests
  3. 03Vitest-based test suites
  4. 04Reusable server factory example

Use cases

  1. 01Test a server through its CLI and stdio
  2. 02Test server logic without spawning a process

MCP support

Demonstrates two ways to test a TypeScript MCP server: JSON-RPC over stdio and in-memory RPC using the MCP SDK Client and InMemoryTransport.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

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
# Clone the repo
git clone https://github.com/mkusaka/mcp-server-e2e-testing-example.git
cd mcp-server-e2e-testing-example

# Install dependencies
pnpm install

🧪 Running E2E Tests

1. Raw (spawn + stdio) tests

This suite launches the CLI (src/cli.ts) via npx tsx and sends JSON‑RPC over stdin/stdout.

pnpm vitest run tests/e2e/raw.spec.ts
2. SDK (in‑memory) tests

This suite uses the MCP SDK’s Client + InMemoryTransport to invoke the same server logic without spawning a child process.

pnpm vitest run tests/e2e/sdk.spec.ts

🛠️ Scripts

Add these to package.json if desired:

{
  "scripts": {
    "test:raw": "vitest run tests/e2e/raw.spec.ts",
    "test:sdk": "vitest run tests/e2e/sdk.spec.ts",
    "test": "vitest run"
  }
}
  • pnpm run test:raw – Run only the raw/stdio tests
  • pnpm run test:sdk – Run only the in‑memory SDK tests
  • pnpm run test – Run all tests

📦 Publishing & Usage

This repository is intended as an example/template. Feel free to:

  • Adapt the src/server.ts factory for your own MCP server
  • Expand raw.spec.ts and sdk.spec.ts with additional test cases
  • Integrate into your CI pipeline

📄 License

Released under the MIT License.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.