Frequently Asked Questions

Everything you need to know about MCP Jest, the testing framework for Model Context Protocol servers.

TL;DR - What is MCP Jest?

MCP Jest is an automated testing framework for Model Context Protocol (MCP) servers. Install with npm install -g mcp-jest, then run mcp-jest node ./server.js --tools your-tools to test your MCP server instantly. Zero configuration required.

General

What is MCP Jest?

MCP Jest is the first automated testing framework specifically designed for Model Context Protocol (MCP) servers. It allows developers to write and run tests for their MCP servers, similar to how Jest works for JavaScript applications. MCP Jest enables automated testing, CI/CD integration, snapshot testing, and supports multiple transport protocols including stdio, HTTP streaming, and SSE.

What is Model Context Protocol (MCP)?

Model Context Protocol (MCP) is an open standard introduced by Anthropic that enables AI assistants like Claude and ChatGPT to connect with external tools, data sources, and services. MCP servers expose tools, prompts, and resources that AI systems can use to perform tasks like searching databases, calling APIs, or executing code.

Who created MCP Jest?

MCP Jest was created by Harsh Joshi. It is open source under the MIT license and free to use in both commercial and open source projects.

Is MCP Jest free to use?

Yes, MCP Jest is completely free and open source under the MIT license. You can use it in commercial projects, open source projects, and personal projects without any cost or licensing fees.

What Node.js version does MCP Jest require?

MCP Jest requires Node.js version 18 or higher. This is because it uses modern JavaScript features and the MCP SDK that require Node.js 18+.

Installation & Setup

How do I install MCP Jest?

You can install MCP Jest globally using npm: `npm install -g mcp-jest`. For local installation in your project, use `npm install mcp-jest` or `npm install --save-dev mcp-jest`. Global installation is recommended for CLI usage, while local installation is better for programmatic usage in test files.

How do I test my first MCP server with MCP Jest?

After installing MCP Jest globally, run `mcp-jest node ./your-server.js --tools tool1,tool2` where `./your-server.js` is the path to your MCP server and `tool1,tool2` are the names of tools you want to test. MCP Jest will automatically connect to your server, discover tools, run tests, and report results.

Does MCP Jest require any configuration?

No, MCP Jest works out of the box with zero configuration. Simply point it at your MCP server and specify which tools to test. However, you can optionally create a configuration file (mcp-jest.config.json) for more advanced setups with custom timeouts, reporters, or test patterns.

Testing Features

Can MCP Jest test HTTP-based MCP servers?

Yes, MCP Jest supports multiple transport protocols. Use `--transport streamable-http --url http://localhost:3000` to test HTTP streaming servers, or `--transport sse` for Server-Sent Events. By default, MCP Jest uses stdio transport for local servers.

What is snapshot testing in MCP Jest?

Snapshot testing in MCP Jest captures the output of your MCP tools and saves them to files. On subsequent test runs, MCP Jest compares the current output with the saved snapshots to detect unexpected changes. This is useful for regression testing. Use `--update-snapshots` to update snapshots when intentional changes are made.

How do I run only specific tests?

Use the `--filter` option to run only tests matching a pattern: `mcp-jest node ./server.js --filter search`. You can also use `--skip` to exclude tests: `mcp-jest node ./server.js --skip experimental`. Both options support glob patterns.

Can MCP Jest test prompts and resources, not just tools?

Yes, MCP Jest can test all MCP primitives including tools, prompts, and resources. Specify which to test using the appropriate flags. By default, it auto-discovers and tests all available tools.

CI/CD Integration

Does MCP Jest work with GitHub Actions?

Yes, MCP Jest works seamlessly with GitHub Actions. Simply install it in your workflow and run your tests. Example: `npm install -g mcp-jest && mcp-jest node ./server.js --tools search`. MCP Jest returns proper exit codes (0 for pass, 1 for fail) for CI/CD integration.

Can I use MCP Jest in GitLab CI or Jenkins?

Yes, MCP Jest works with any CI/CD system that can run npm commands, including GitLab CI, Jenkins, CircleCI, Travis CI, Azure Pipelines, and more. The installation and usage commands are the same across all platforms.

How do I add MCP Jest to my npm scripts?

Add a test script to your package.json: `"scripts": { "test:mcp": "mcp-jest node ./server.js --tools search,calculate" }`. Then run it with `npm run test:mcp`. This makes it easy to run tests locally and in CI/CD pipelines.

Programmatic Usage

Can I use MCP Jest with Jest or Vitest?

Yes, MCP Jest provides a programmatic API that integrates with any JavaScript test framework including Jest, Vitest, and Mocha. Import MCPTester from mcp-jest and use it in your test files to connect to MCP servers, call tools, and make assertions.

Does MCP Jest support TypeScript?

Yes, MCP Jest is written in TypeScript and provides full type definitions. You can use it in TypeScript projects with full type safety and IntelliSense support in your IDE.

What does the programmatic API look like?

The MCPTester class provides methods like connect(), disconnect(), listTools(), callTool(name, args), listPrompts(), getPrompt(name), listResources(), and readResource(uri). Create a tester instance with your server config, connect, run tests, and disconnect.

Troubleshooting

My tests are timing out. What should I do?

Increase the timeout using `--timeout <ms>`. The default timeout is 30000ms (30 seconds). For slow servers or operations, try `--timeout 60000` for 60 seconds. Also ensure your MCP server is starting properly and responding to requests.

MCP Jest cannot find my tools. Why?

Ensure your MCP server properly implements the tools/list method and returns the tools you expect. Verify the tool names match exactly what you are specifying in --tools. Use `--verbose` to see detailed output about tool discovery.

How do I debug failing tests?

Use the `--verbose` flag to see detailed output including server logs, request/response data, and error messages. You can also use MCP Inspector for interactive debugging during development, then switch to MCP Jest for automated testing.

Comparison

What is the difference between MCP Jest and MCP Inspector?

MCP Inspector is an interactive debugging tool for manual testing and exploration of MCP servers. MCP Jest is an automated testing framework designed for CI/CD and regression testing. Use MCP Inspector during development to explore your server, and MCP Jest to automate testing in your pipeline.

Why use MCP Jest instead of manual testing?

Manual testing is time-consuming, error-prone, and cannot be integrated into CI/CD pipelines. MCP Jest provides automated, repeatable tests that run in seconds, catch regressions automatically, and block broken deployments. It saves hours of manual testing effort.

Can I use both MCP Jest and MCP Inspector?

Yes, they complement each other. Use MCP Inspector during development for interactive debugging and exploration. Use MCP Jest for automated testing in your CI/CD pipeline and for regression testing.

Ready to get started?

Install MCP Jest and test your first MCP server in under a minute.

Still have questions?

Open an issue on GitHub and we will help you out.