Test Runner MCP server

Unifies test execution and result processing across multiple frameworks for streamlined cross-language testing and analysis.
Back to servers
Setup instructions
Provider
privsim
Release date
Jan 18, 2025
Language
TypeScript
Stats
15 stars

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.

Installation

Install the package using npm:

npm install test-runner-mcp

Prerequisites

Each testing framework requires its own installation:

Configuration

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

Using the Test Runner

Basic Usage

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"
}

Framework Examples

Bats Tests

{
  "command": "bats test/*.bats",
  "workingDir": "/path/to/project",
  "framework": "bats",
  "outputDir": "test_reports"
}

Pytest Tests

{
  "command": "pytest test_file.py -v",
  "workingDir": "/path/to/project",
  "framework": "pytest",
  "outputDir": "test_reports"
}

Flutter Tests

{
  "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 Tests

{
  "command": "jest test/*.test.js",
  "workingDir": "/path/to/project",
  "framework": "jest",
  "outputDir": "test_reports"
}

Go Tests

{
  "command": "go test ./...",
  "workingDir": "/path/to/project",
  "framework": "go",
  "outputDir": "test_reports"
}

Rust Tests

{
  "command": "cargo test",
  "workingDir": "/path/to/project",
  "framework": "rust",
  "outputDir": "test_reports"
}

Generic Tests

For arbitrary commands or CI/CD tools:

{
  "command": "act -j build",
  "workingDir": "/path/to/project",
  "framework": "generic",
  "outputDir": "test_reports"
}

Security Features

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
  }
}

Output Format

The test runner produces structured output in the specified output directory:

  • test_output.log: Raw test output
  • test_errors.log: Error messages if any
  • test_results.json: Structured test results
  • summary.txt: Human-readable summary

The 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
}

How to install this MCP server

For Claude Code

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.

For Cursor

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.

Adding an MCP server to Cursor globally

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"
            }
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.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

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later