Complete command-line interface documentation for MCP-Jest.
# Global installation (recommended for CLI usage)
npm install -g mcp-jest
# Local installation
npm install mcp-jest
npx mcp-jest --help
mcp-jest [command] [OPTIONS] [SERVER_COMMAND] [SERVER_ARGS...]
Run tests against an MCP server.
mcp-jest node ./server.js --tools search,email
mcp-jest python server.py --tools calculate
mcp-jest ./my-binary --tools fetch
Auto-discover server capabilities and generate test configurations.
# Discover and print to stdout
mcp-jest discover node ./server.js
# Output as JSON file
mcp-jest discover node ./server.js --output tests.json
# Output as TypeScript test file
mcp-jest discover node ./server.js --output tests.ts
# Discover from HTTP server
mcp-jest discover --transport streamable-http --url http://localhost:3000
Validate MCP protocol compliance and get a compliance score.
# Basic validation
mcp-jest validate node ./server.js
# Detailed validation
mcp-jest validate node ./server.js --depth full
# Export compliance report
mcp-jest validate node ./server.js --output compliance.json
Watch for file changes and automatically rerun tests.
# Basic watch mode
mcp-jest watch node ./server.js --tools search
# Watch specific directories
mcp-jest watch node ./server.js --watch-paths src,lib --tools search
# Watch with config file
mcp-jest watch --config mcp-jest.json
Option
Alias
Description
Default
--help
-h
Show help message
-
--version
-v
Show version
-
--config <file>
-c
Load configuration from JSON file
-
--server <cmd>
-s
Server command (stdio only)
-
--timeout <ms>
Test timeout in milliseconds
30000
Option
Description
Example
--transport <type>
Transport type: stdio, sse, streamable-http
--transport streamable-http
--url <url>
Server URL (required for HTTP transports)
--url http://localhost:3000
Option
Alias
Description
Example
--tools <tools>
-t
Comma-separated list of tools to test
--tools search,email
--resources <res>
-r
Comma-separated list of resources to test
--resources "data/*,config.json"
--prompts <prompts>
-p
Comma-separated list of prompts to test
--prompts analyze,summarize
--args <args>
Comma-separated server arguments
--args "port=3000,debug"
Option
Description
Example
--filter <pattern>
-f
Run only tests matching pattern
--skip <pattern>
Skip tests matching pattern
Option
Alias
Description
--update-snapshots
-u
Update snapshots instead of comparing
Option
Description
Example
--reporter <type>
Output format: console, html, json
--reporter html
--report-output <file>
Output file for report
--report-output report.html
Option
Description
Example
--output <file>
Output file (.json or .ts)
--output tests.json
Option
Description
Example
--depth <level>
Validation depth: basic, standard, full
--depth full
--output <file>
Output file for compliance report
--output compliance.json
Option
Description
Example
--watch-paths <paths>
Comma-separated directories to watch
--watch-paths src,lib
# Test specific tools
mcp-jest node ./server.js --tools search,email,calculate
# Test with resources
mcp-jest python server.py --tools search --resources " docs/*,config.json"
# Test with prompts
mcp-jest node server.js --tools search --prompts " review-code,analyze"
# Test with custom timeout
mcp-jest node ./server.js --tools search --timeout 60000
# Use config file
mcp-jest --config mcp-jest.json
# Override config options
mcp-jest --config mcp-jest.json --timeout 60000 --tools search
# 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
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 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
# HTTP with config file
mcp-jest --config http-test.json
# Run tests with snapshot comparison
mcp-jest node ./server.js --tools search
# Update snapshots
mcp-jest node ./server.js --tools search --update-snapshots
mcp-jest node ./server.js --tools search -u
# Generate HTML report
mcp-jest node ./server.js --tools search --reporter html
# Specify output file
mcp-jest node ./server.js --tools search --reporter html --report-output report.html
# Generate JSON report
mcp-jest node ./server.js --tools search --reporter json --report-output results.json
# Discover all capabilities
mcp-jest discover node ./server.js
# Save as JSON config
mcp-jest discover node ./server.js --output mcp-jest.json
# Save as TypeScript
mcp-jest discover node ./server.js --output tests.ts
# Discover HTTP server
mcp-jest discover --transport streamable-http --url http://localhost:3000
# Basic validation
mcp-jest validate node ./server.js
# Full validation with report
mcp-jest validate node ./server.js --depth full --output compliance.json
# Watch and rerun tests
mcp-jest watch node ./server.js --tools search
# Watch specific paths
mcp-jest watch node ./server.js --watch-paths src,lib --tools search
# Watch with config
mcp-jest watch --config mcp-jest.json
Configuration File Format
Create mcp-jest.json:
{
"server" : {
"command" : " node" ,
"args" : [" ./server.js" ],
"env" : {
"NODE_ENV" : " test"
}
},
"tests" : {
"tools" : {
"search" : {
"args" : { "query" : " test" },
"expect" : " content.length > 0"
},
"calculate" : {
"args" : { "a" : 5 , "b" : 3 },
"expect" : " content[0].text === '8'"
}
},
"resources" : {
"config.json" : { "expect" : " exists" },
"docs/*" : { "expect" : " count >= 1" }
},
"prompts" : {
"review-code" : {
"args" : { "code" : " function test() {}" },
"expect" : " messages.length > 0"
}
},
"timeout" : 30000
}
}
{
"server" : {
"transport" : " streamable-http" ,
"url" : " http://localhost:3000/mcp"
},
"tests" : {
"tools" : [" search" , " calculate" ],
"timeout" : 60000
}
}
Code
Description
0
All tests passed
1
One or more tests failed
2
Configuration error
3
Server startup failure
Variable
Description
DEBUG=mcp-jest*
Enable debug logging
MCP_JEST_TIMEOUT
Default timeout (ms)
{
"scripts" : {
"test:mcp" : " mcp-jest node ./server.js --tools search,email" ,
"test:mcp:full" : " mcp-jest --config ./tests/mcp-jest.json" ,
"test:mcp:quick" : " mcp-jest node ./server.js --tools search" ,
"test:mcp:watch" : " mcp-jest watch node ./server.js --tools search" ,
"test:all" : " npm test && npm run test:mcp"
}
}