Test Runner MCP is a Model Context Protocol server that provides a unified interface for executing tests and processing outputs from multiple testing frameworks including Bats, Pytest, Flutter, Jest, Go, Rust, and generic command execution. It standardizes test execution and results parsing across different testing ecosystems.
Install the package using npm:
npm install test-runner-mcp
Each testing framework requires its own installation:
apt-get install bats
or brew install bats
pip install pytest
npm install --save-dev jest
Add the test-runner to your MCP settings in your configuration file:
{
"mcpServers": {
"test-runner": {
"command": "node",
"args": ["/path/to/test-runner-mcp/build/index.js"],
"env": {
"NODE_PATH": "/path/to/test-runner-mcp/node_modules",
"FLUTTER_ROOT": "/opt/homebrew/Caskroom/flutter/3.27.2/flutter",
"PUB_CACHE": "/Users/username/.pub-cache",
"PATH": "/opt/homebrew/Caskroom/flutter/3.27.2/flutter/bin:/usr/local/bin:/usr/bin:/bin"
}
}
}
}
For Flutter tests, update the environment variables with your specific installation paths:
# Get Flutter root
flutter --version
# Get pub cache path
echo $PUB_CACHE # or default to $HOME/.pub-cache
# Get Flutter binary path
which flutter
Use the run_tests
tool with the following parameters:
{
"command": "test command to execute",
"workingDir": "working directory for test execution",
"framework": "bats|pytest|flutter|jest|go|rust|generic",
"outputDir": "directory for test results",
"timeout": "test execution timeout in milliseconds (default: 300000)",
"env": "optional environment variables",
"securityOptions": "optional security options for command execution"
}
{
"command": "bats test/*.bats",
"workingDir": "/path/to/project",
"framework": "bats",
"outputDir": "test_reports"
}
{
"command": "pytest test_file.py -v",
"workingDir": "/path/to/project",
"framework": "pytest",
"outputDir": "test_reports"
}
{
"command": "flutter test test/widget_test.dart",
"workingDir": "/path/to/project",
"framework": "flutter",
"outputDir": "test_reports",
"FLUTTER_ROOT": "/opt/homebrew/Caskroom/flutter/3.27.2/flutter",
"PUB_CACHE": "/Users/username/.pub-cache",
"PATH": "/opt/homebrew/Caskroom/flutter/3.27.2/flutter/bin:/usr/local/bin:/usr/bin:/bin"
}
{
"command": "jest test/*.test.js",
"workingDir": "/path/to/project",
"framework": "jest",
"outputDir": "test_reports"
}
{
"command": "go test ./...",
"workingDir": "/path/to/project",
"framework": "go",
"outputDir": "test_reports"
}
{
"command": "cargo test",
"workingDir": "/path/to/project",
"framework": "rust",
"outputDir": "test_reports"
}
For arbitrary commands or CI/CD tools:
{
"command": "act -j build",
"workingDir": "/path/to/project",
"framework": "generic",
"outputDir": "test_reports"
}
The test runner includes security features to prevent execution of harmful commands:
{
"command": "sudo docker-compose -f docker-compose.test.yml up",
"workingDir": "/path/to/project",
"framework": "generic",
"outputDir": "test_reports",
"securityOptions": {
"allowSudo": true,
"allowSu": false,
"allowShellExpansion": true,
"allowPipeToFile": false
}
}
The test runner produces structured output in the specified output directory:
test_output.log
: Raw test outputtest_errors.log
: Error messages if anytest_results.json
: Structured test resultssummary.txt
: Human-readable summaryThe structured output follows this format:
interface TestResult {
name: string;
passed: boolean;
output: string[];
rawOutput?: string; // Complete unprocessed output
}
interface TestSummary {
total: number;
passed: number;
failed: number;
duration?: number;
}
interface ParsedResults {
framework: string;
tests: TestResult[];
summary: TestSummary;
rawOutput: string; // Complete command output
}
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "test-runner" '{"command":"node","args":["/path/to/test-runner-mcp/build/index.js"],"env":{"NODE_PATH":"/path/to/test-runner-mcp/node_modules","FLUTTER_ROOT":"/opt/homebrew/Caskroom/flutter/3.27.2/flutter","PUB_CACHE":"/Users/username/.pub-cache","PATH":"/opt/homebrew/Caskroom/flutter/3.27.2/flutter/bin:/usr/local/bin:/usr/bin:/bin"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"test-runner": {
"command": "node",
"args": [
"/path/to/test-runner-mcp/build/index.js"
],
"env": {
"NODE_PATH": "/path/to/test-runner-mcp/node_modules",
"FLUTTER_ROOT": "/opt/homebrew/Caskroom/flutter/3.27.2/flutter",
"PUB_CACHE": "/Users/username/.pub-cache",
"PATH": "/opt/homebrew/Caskroom/flutter/3.27.2/flutter/bin:/usr/local/bin:/usr/bin:/bin"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"test-runner": {
"command": "node",
"args": [
"/path/to/test-runner-mcp/build/index.js"
],
"env": {
"NODE_PATH": "/path/to/test-runner-mcp/node_modules",
"FLUTTER_ROOT": "/opt/homebrew/Caskroom/flutter/3.27.2/flutter",
"PUB_CACHE": "/Users/username/.pub-cache",
"PATH": "/opt/homebrew/Caskroom/flutter/3.27.2/flutter/bin:/usr/local/bin:/usr/bin:/bin"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect