mcp-jest

by josharsh

365 downloads
Not rated
GitHub

About

Automated testing for Model Context Protocol servers. Ship MCP Servers with confidence.

Details

Author
josharsh
Downloads
365
Categories
Other

- Dead simple API – one function call tests your entire server.
- Declarative testing – describe what to test, not how.
- Comprehensive coverage – connection, capability discovery, functional, and validation.
- CI/CD ready – works with GitHub Actions, Jenkins, and more.
- Fast execution – complete suites in under 500ms.
- Zero dependencies beyond the official MCP SDK.
- Flexible usage – library, CLI, config files, TypeScript support.

Install via npm install mcp-jest (or globally with npm install -g mcp-jest), then either call the mcpTest function from your code or use the mcp-jest CLI command with a server command and list of tools to test. For example: mcp-jest node ./server.js --tools search,email.

mcp-jest

npm version
npm downloads
License: MIT
Node.js CI
TypeScript

The first (and perhaps only) testing framework for Model Context Protocol (MCP) servers - like Jest, but for MCP

> 🚀 Finally! Test your MCP servers with confidence. No more manual verification, no more broken deployments.

The Problem

You built an MCP server that connects AI assistants to your database, file system, or API. But how do you know it actually works?

npm install mcp-jest

Why mcp-jest?

The Problem 😤

Building MCP servers? You've probably experienced this:

- ❌ Manual Testing Hell: Manually connecting clients to test every change
- ❌ Silent Failures: Servers break and you don't know until Claude Code crashes
- ❌ No CI/CD: Can't automate MCP server testing in pipelines
- ❌ Debugging Nightmare: When things break, you have no idea what went wrong
- ❌ Fear of Deployment: Every update is a gamble

The Solution ✨

mcp-jest is the missing piece of the MCP ecosystem:

- ✅ Automated Testing: Write tests once, run them everywhere
- ✅ Instant Feedback: Know immediately when something breaks
- ✅ CI/CD Ready: Integrate seamlessly into any build pipeline
- ✅ Crystal Clear Results: Detailed reports show exactly what works and what doesn't
- ✅ Deploy with Confidence: Comprehensive testing before production

⚡ Quick Start (30 seconds)

1. Install

npm install mcp-jest          # As dependency
npm install -g mcp-jest       # Or globally for CLI

2. Test Your Server

import { mcpTest } from 'mcp-jest';

const results = await mcpTest(
{ command: 'node', args: ['./server.js'] },
{ tools: ['search', 'email'] }
);

console.log(${results.passed}/${results.total} tests passed);

3. Or Use CLI

mcp-jest node ./server.js --tools search,email

That's it! Your MCP server is now tested. 🎉

🔥 Features That Matter

🧪 Dead Simple API

One function call tests your entire server. No complex setup, no boilerplate.

📝 Declarative Testing

Describe what to test, not how. Focus on your server logic, not test infrastructure.

🔍 Comprehensive Coverage

- Connection Testing: Server starts and responds - Capability Discovery: Tools/resources/prompts exist - Functional Testing: Everything actually works - Validation: Results match expectations

🚀 Built for Production

- CI/CD Integration: Works with GitHub Actions, Jenkins, etc. - Fast Execution: Complete test suites in under 500ms - Detailed Reporting: Know exactly what failed and why - Zero Dependencies: Uses official MCP SDK only

🛠️ Flexible Usage

- Library: Integrate into existing test suites - CLI: Perfect for scripts and pipelines - Config Files: Complex test scenarios - TypeScript: Full type safety included

---

🎯 Real-World Examples

Testing a Search Server

const results = await mcpTest(
  { command: 'python', args: ['search-server.py'] },
  {
    tools: {
      search: {
        args: { query: 'artificial intelligence' },
        expect: result => result.results.length > 0
      },
      autocomplete: {
        args: { partial: 'artif' },
        expect: 'suggestions.length >= 3'
      }
    }
  }
);

CI/CD Integration

```yaml
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.