
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Testing framework for Model Context Protocol (MCP) servers - like Jest but for MCP
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.
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
Building MCP servers? You've probably experienced this:
mcp-jest is the missing piece of the MCP ecosystem:
π Documentation: https://mcp-jest.ddiy.diy/
npm install mcp-jest # As dependency
npm install -g mcp-jest # Or globally for CLI
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`);
mcp-jest node ./server.js --tools search,email
That's it! Your MCP server is now tested. π
One function call tests your entire server. No complex setup, no boilerplate.
Describe what to test, not how. Focus on your server logic, not test infrastructure.
--filter
--skip
*
for flexible pattern matchingconst 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'
}
}
}
);
# .github/workflows/test.yml
- name: Test MCP Server
run: |
npm install -g mcp-jest
mcp-jest node ./dist/server.js --tools "search,analyze"
{
"scripts": {
"test": "jest && npm run test:mcp",
"test:mcp": "mcp-jest node ./server.js --tools search,email",
"dev": "concurrently 'npm run dev:server' 'npm run test:mcp:watch'"
}
}
// Capture and compare MCP outputs over time
const results = await mcpTest(
{ command: 'node', args: ['./weather-server.js'] },
{
tools: {
getWeather: {
args: { city: 'London' },
snapshot: {
exclude: ['temperature', 'timestamp'], // Exclude changing data
properties: ['format', 'units', 'structure'] // Track structure
}
}
}
}
);
// Update snapshots when changes are intentional
// mcp-jest node ./server.js --update-snapshots
# Run only search-related tests
mcp-jest node ./server.js --tools "search,email,weather" --filter search
# Skip email tests during development
mcp-jest node ./server.js --tools "search,email,weather" --skip email
# Use wildcards for flexible filtering
mcp-jest node ./server.js --tools "getUser,getUserProfile,updateUser" --filter "user*"
# Combine with other options
mcp-jest node ./server.js --filter search --timeout 5000 --update-snapshots
# Test stdio server (default)
mcp-jest node ./server.js --tools search,email
# Test HTTP streaming server
mcp-jest --transport streamable-http --url http://localhost:3000 --tools search
# Test SSE server
mcp-jest --transport sse --url http://api.example.com/sse --tools search,email
# Use config file for HTTP transport
cat > mcp-jest.json << EOF
{
"server": {
"transport": "streamable-http",
"url": "http://localhost:3000/mcp"
},
"tests": {
"tools": ["search", "calculate"],
"timeout": 60000
}
}
EOF
mcp-jest --config mcp-jest.json
mcp-jest [OPTIONS] [SERVER_COMMAND]
Option | Description | Example |
---|---|---|
-h, --help | Show help message | mcp-jest --help |
-v, --version | Show version | mcp-jest --version |
-c, --config <file> | Load configuration from JSON file | mcp-jest --config test.json |
-s, --server <cmd> | Server command to test (stdio only) | mcp-jest --server "node server.js" |
--transport <type> | Transport type: stdio, sse, streamable-http | mcp-jest --transport streamable-http |
--url <url> | Server URL (required for HTTP transports) | mcp-jest --url http://localhost:3000 |
--args <args> | Comma-separated server arguments | mcp-jest node server.js --args "port=3000,debug" |
-t, --tools <tools> | Comma-separated list of tools to test | mcp-jest --tools search,calculate |
-r, --resources <res> | Comma-separated list of resources to test | mcp-jest --resources "data/*,config.json" |
-p, --prompts <prompts> | Comma-separated list of prompts to test | mcp-jest --prompts analyze,summarize |
--timeout <ms> | Test timeout in milliseconds | mcp-jest --timeout 60000 |
-u, --update-snapshots | Update snapshots instead of comparing | mcp-jest -u |
-f, --filter <pattern> | Run only tests matching pattern | mcp-jest --filter "search*" |
--skip <pattern> | Skip tests matching pattern | mcp-jest --skip "*test*" |
βββββββββββββββββββββββ βββββββββββββββββββββββ
β β β β
β MCP Server Dev β ??? β How do I know my β
β Implements Tool β ββββββ> β server works? β
β β β β
βββββββββββββββββββββββ βββββββββββββββββββββββ
Before MCP-JEST: Manual testing, no automation, no confidence
βββββββββββββββββββββββ βββββββββββββββββββββββ βββββββββββββββββββββββ
β β β β β β
β MCP Server Dev β ββββββ> β MCP-JEST β ββββββ> β β Automated Tests β
β Implements Tool β β Test Framework β β β CI/CD Ready β
β β β β β β Snapshot Testing β
βββββββββββββββββββββββ βββββββββββββββββββββββ βββββββββββββββββββββββ
With MCP-JEST: Automated, repeatable, confident testing
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MCP-JEST Architecture β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β CLI β β Library β β Types β β
β β (cli.ts) β β (index.ts) β β (types.ts) β β
β ββββββββ¬βββββββ ββββββββ¬βββββββ ββββββββ¬βββββββ β
β β β β β
β ββββββββββββββββββββββ΄βββββββββββββββββββββ β
β β β
β βΌ β
β βββββββββββββββββββ β
β β MCPTestRunner β β
β β (runner.ts) β β
β ββββββββββ¬ββββββββββ β
β β β
β βββββββββββββββββββββΌββββββββββββββββββββ β
β β β β β
β βΌ βΌ βΌ β
β ββββββββββββββββ βββββββββββββββββ ββββββββββββββββ β
β β MCPTestClientβ βSnapshotManagerβ β Expectation β β
β β (client.ts) β β (snapshot.ts) β β Evaluator β β
β ββββββββ¬ββββββββ βββββββββ¬ββββββββ ββββββββ¬ββββββββ β
β β β β β
β βΌ βΌ βΌ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β MCP Protocol Communication β β
β β (via @modelcontextprotocol/sdk) β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
βββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β Your MCP Server β
β (Being Tested) β
βββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Generic Testing vs MCP-JEST β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Generic Test Framework: β
β βββββββββββ β
β β Test βββ[HTTP/Function Call]ββ> Response β
β βββββββββββ β
β β
β MCP-JEST: β
β βββββββββββ β
β β Test β β
β ββββββ¬βββββ β
β β β
β βββ[1. Process Management] β
β βββ[2. StdioTransport Setup] β
β βββ[3. MCP Protocol Handshake] β
β βββ[4. Capability Discovery] β
β βββ[5. Tool/Resource/Prompt Execution] β
β βββ[6. Structured Validation] β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββ
β MCP-JEST Test Coverage β
ββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Connection Layer: β
β β’ Server startup β
β β’ Protocol handshake β
β β’ Timeout handling β
β β
β Discovery Layer: β
β β’ Available tools β
β β’ Available resources β
β β’ Available prompts β
β β’ Capability matching β
β β
β Functional Layer: β
β β’ Tool execution with arguments β
β β’ Resource reading β
β β’ Prompt generation β
β β’ Error handling β
β β
β Validation Layer: β
β β’ Response structure β
β β’ Content validation β
β β’ Snapshot comparison β
β β’ Custom expectations β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β Developer Experience Flow β
ββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β 1. Write Test Config (JSON) β
β Simple, declarative, no code needed β
β β
β 2. Run Tests β
β $ mcp-jest test-config.json β
β β
β 3. See Results β
β β Connection test passed (50ms) β
β β Tool: calculate - passed (23ms) β
β β Resource: data - failed (15ms) β
β Expected: "value" β
β Received: "other" β
β β
β 4. Update Snapshots (if needed) β
β $ mcp-jest test-config.json -u β
β β
β 5. Integrate with CI/CD β
β Exit codes, JSON output, timing info β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Snapshot Comparison Algorithm β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β€
β β
β 1. Normalize Data: β
β β’ Sort object keys alphabetically β
β β’ Remove volatile fields (timestamps, IDs) β
β β’ Apply inclusion/exclusion rules β
β β
β 2. Generate Hash: β
β β’ Create deterministic string representation β
β β’ Use SHA-256 for consistency β
β β
β 3. Compare: β
β βββββββββββββββ βββββββββββββββ β
β β Current β β Stored β β
β β Output β <=> β Snapshot β β
β βββββββββββββββ βββββββββββββββ β
β β β β
β ββββββββββ¬ββββββββββββ β
β β β
β ββββββ΄βββββ β
β β Equal? β β
β ββββββ¬βββββ β
β β β
β βββββββββββ΄ββββββββββ β
β β β β
β [Yes] [No] β
β β β β
β β Pass Check Update Mode β
β β β
β ββββββββββ΄βββββββββ β
β β β β
β [Update Mode] [Normal Mode] β
β β β β
β Update & Pass Show Diff & Fail β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Testing Approach Comparison β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β€
β β
β Manual Testing: β
β βββββββββββββββ β
β β’ Start server manually β
β β’ Use Claude Desktop or terminal β
β β’ Manually invoke each tool β
β β’ Visually verify outputs β
β β’ No automation, no CI/CD β
β β
β Custom Scripts: β
β βββββββββββββββ β
β β’ Write custom Node.js/Python scripts β
β β’ Implement MCP client from scratch β
β β’ Handle all edge cases yourself β
β β’ Maintain test infrastructure β
β β’ Reinvent the wheel for each project β
β β
β Generic Test Frameworks (Jest/Mocha): β
β βββββββββββββββββββββββββββββββββββββ β
β β’ Not designed for process communication β
β β’ No MCP protocol understanding β
β β’ Complex setup for stdio handling β
β β’ No built-in capability discovery β
β β’ Manual snapshot implementation β
β β
β MCP-JEST: β
β βββββββββ β
β β Purpose-built for MCP β
β β Zero-config process management β
β β Protocol-aware testing β
β β Built-in expectations & snapshots β
β β CI/CD ready out of the box β
β β Minimal dependencies β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Feature Comparison β
βββββββββββββββββββ¬βββββββββββ¬ββββββββββ¬βββββββββββ¬ββββββββββ β€
β Feature β MCP-JEST β Manual β Custom β Generic β
β β β Testing β Scripts β Frameworksβ
βββββββββββββββββββΌβββββββββββΌββββββββββΌβββββββββββΌβββββββββββββ€
β Process Mgmt β β β β β ~ β β β
β MCP Protocol β β β β β ~ β β β
β Auto Discovery β β β β β ~ β β β
β Snapshots β β β β β ~ β ~ β
β CI/CD Ready β β β β β ~ β β β
β Type Safety β β β β β ~ β ~ β
β Zero Config β β β β β β β β β
β Timing Info β β β β β ~ β β β
β Expectations β β β β β ~ β β β
β JSON Reports β β β β β ~ β ~ β
βββββββββββββββββββ΄βββββββββββ΄ββββββββββ΄βββββββββββ΄βββββββββββ
Legend: β Full Support, ~ Partial/Manual Implementation, β Not Supported
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Value for Server Developers β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β€
β β
β Confidence: β
β β’ Know your server works before shipping β
β β’ Catch regressions immediately β
β β’ Test edge cases systematically β
β β
β Productivity: β
β β’ Fast feedback loop β
β β’ No manual testing repetition β
β β’ Focus on features, not testing infrastructure β
β β
β Quality: β
β β’ Consistent behavior across updates β
β β’ Document expected behavior via tests β
β β’ Ensure protocol compliance β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Ecosystem Benefits β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Standardization: β
β β’ Common testing patterns β
β β’ Shared quality bar β
β β’ Consistent user experience β
β β
β Trust: β
β β’ Users can trust tested servers β
β β’ "MCP-JEST tested" badge β
β β’ Reduced bugs in production β
β β
β Growth: β
β β’ Lower barrier to entry β
β β’ Faster development cycles β
β β’ More reliable servers β more adoption β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
We love contributions! Here's how to get started:
# Clone the repository
cd mcp-jest
npm install
npm run dev # Start development mode
npm test # Run tests
npm run build # Build for production
Server won't start?
# Use absolute paths
mcp-jest /usr/bin/node ./server.js
# Check server logs
DEBUG=mcp-jest* mcp-jest node ./server.js
Connection timeout?
# Increase timeout
mcp-jest node ./server.js --timeout 60000
Tool execution fails?
// Add detailed logging
expect: (result) => {
console.log('Result:', JSON.stringify(result, null, 2));
return result.success === true;
}
MIT License - Use freely in commercial and open source projects.
Built with β€οΈ for the MCP ecosystem
Get Started β’ Documentation β’ Examples β’ Contributing
Make your MCP servers bulletproof. Start testing today! π
Comprehensive documentation is available to help you get the most out of mcp-jest:
We welcome contributions from the community! Your input helps make mcp-jest better for everyone.
Thank you to all our contributors who have helped shape this project. Every contribution, no matter how small, is valued and appreciated.
We encourage contributions of all kinds:
Security is a top priority for mcp-jest. We take the security of our code and our users seriously.
If you discover a security vulnerability, please follow our responsible disclosure process outlined in the security policy.
mcp-jest is released under the MIT License. This means you can use it freely in both commercial and open-source projects.
See the LICENSE file for the full license text.
Need help? We're here to support you:
Before opening an issue, please check if your question has already been answered in the documentation or existing issues.
[1.0.13] - 2025-01-15
--transport
and --url
for HTTP configurationtransport
field (defaults to stdio
for backward compatibility)FAQs
Testing framework for Model Context Protocol (MCP) servers - like Jest but for MCP
The npm package mcp-jest receives a total of 129 weekly downloads. As such, mcp-jest popularity was classified as not popular.
We found that mcp-jest demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.