Test Runner
STDIOMCP server for running and parsing test results from multiple testing frameworks.
MCP server for running and parsing test results from multiple testing frameworks.
A Model Context Protocol (MCP) server for running and parsing test results from multiple testing frameworks. This server provides a unified interface for executing tests and processing their outputs, supporting:
npm install test-runner-mcp
The following test frameworks need to be installed for their respective test types:
apt-get install bats
or brew install bats
pip install pytest
npm install --save-dev jest
Add the test-runner to your MCP settings (e.g., in claude_desktop_config.json
or cline_mcp_settings.json
):
{ "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-specific environment (required for Flutter tests) "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" } } } }
Note: For Flutter tests, ensure you replace:
/opt/homebrew/Caskroom/flutter/3.27.2/flutter
with your actual Flutter installation path/Users/username/.pub-cache
with your actual pub cache pathYou can find these values by running:
# 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" }
Example for each framework:
// Bats { "command": "bats test/*.bats", "workingDir": "/path/to/project", "framework": "bats", "outputDir": "test_reports" } // Pytest { "command": "pytest test_file.py -v", "workingDir": "/path/to/project", "framework": "pytest", "outputDir": "test_reports" } // Flutter { "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" } // Jest { "command": "jest test/*.test.js", "workingDir": "/path/to/project", "framework": "jest", "outputDir": "test_reports" } // Go { "command": "go test ./...", "workingDir": "/path/to/project", "framework": "go", "outputDir": "test_reports" } // Rust { "command": "cargo test", "workingDir": "/path/to/project", "framework": "rust", "outputDir": "test_reports" } // Generic (for arbitrary commands, CI/CD tools, etc.) { "command": "act -j build", "workingDir": "/path/to/project", "framework": "generic", "outputDir": "test_reports" } // Generic with security overrides { "command": "sudo docker-compose -f docker-compose.test.yml up", "workingDir": "/path/to/project", "framework": "generic", "outputDir": "test_reports", "securityOptions": { "allowSudo": true } }
The test-runner includes built-in security features to prevent execution of potentially harmful commands, particularly for the generic
framework:
Command Validation
sudo
and su
by defaultrm -rf /
Environment Variable Sanitization
Configurable Security
securityOptions
Security options you can configure:
{ "securityOptions": { "allowSudo": false, // Allow sudo commands "allowSu": false, // Allow su commands "allowShellExpansion": true, // Allow shell expansion like $() or backticks "allowPipeToFile": false // Allow pipe to file operations (> or >>) } }
The test runner includes enhanced support for Flutter tests:
Environment Setup
Error Handling
Output Processing
The test runner provides specific support for Rust's cargo test
:
Environment Setup
Output Parsing
For CI/CD pipelines, GitHub Actions via act
, or any other command execution, the generic framework provides:
Automatic Output Analysis
Flexible Integration
act
, Docker, and custom scriptsSecurity Features
The test runner produces structured output while preserving complete test output:
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 }
Results are saved 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 summarynpm install
npm run build
npm test
The test suite includes tests for all supported frameworks and verifies both successful and failed test scenarios.
The project uses GitHub Actions for continuous integration:
This project is licensed under the MIT License - see the LICENSE file for details.