| Install | |
|---|---|
composer require kwaku/laravel-test-mcp |
|
| PHP: | ^8.2 |
| License: | MIT |
| Last Updated: | Jan 5, 2026 |
| Links: | GitHub · Packagist |
Run Pest and PHPUnit tests directly from AI assistants like Claude, Cursor, and ChatGPT.
composer require kwaku/laravel-test-mcp
Add to your MCP client config:
{
"mcpServers": {
"laravel-tests": {
"command": "php",
"args": ["/path/to/your/project/artisan", "mcp:start", "test-runner", "--stdio"]
}
}
}
Same as above, in Cursor's MCP settings.
Run tests with optional filtering by path, name, or group.
Parameters:
path - File or directory path to testfilter - Filter tests by name (regex supported)group - Run only tests in specific group(s)exclude_group - Exclude tests in specific group(s)stop_on_failure - Stop on first failureparallel - Run tests in parallel (Pest only)dry_run - Preview tests without runningforce - Skip confirmation for large suitesExample prompts:
run_tests path: "tests/Unit/UserTest.php"run_tests path: "tests/Feature"run_tests dry_run: trueList all available tests without running them.
Parameters:
path - Directory to scanformat - Output format: tree, flat, or jsonRun tests with code coverage analysis.
Parameters:
path - Path to test or directoryfilter_file - Only show coverage for specific filemin_coverage - Fail if coverage is below this percentageformat - Output format: summary, detailed, or uncovereddry_run - Preview without runningExample prompts:
get_coverageget_coverage filter_file: "app/Models/User.php"get_coverage min_coverage: 80Watch for file changes and auto-run related tests.
Parameters:
path - Directory to watch (default: app)test_path - Test directory (default: tests)duration - How long to watch in seconds (max: 300)Example prompts:
watch_tests duration: 300watch_testsCancel a running operation by its ID.
Parameters:
operation_id - The operation ID (e.g., op_abc123)Example prompts:
cancel_operation operation_id: "op_xxx"Run mutation testing with Infection to find weak tests.
Parameters:
path - Path to testmin_msi - Minimum mutation score indicatorAnalyze a Laravel class and generate comprehensive test stubs with optional factory generation.
Parameters:
class_path (required) - Path to the PHP class file (e.g., "app/Models/User.php")test_type - Type of test: auto, unit, or feature (default: auto)include_comments - Include explanatory comments (default: true)Supported Class Types:
Example prompts:
generate_test class_path: "app/Models/User.php"generate_test class_path: "app/Http/Controllers/UserController.php"generate_test class_path: "app/Services/PaymentService.php" include_comments: falseOutput includes:
Get the latest test run results.
Get code coverage statistics.
Get test configuration details.
Read the contents of a specific test file.
Get historical test results and trends.
Show uncovered code snippets for a file.
Get a structured guide for Test-Driven Development.
Arguments:
feature (required) - The feature to implementtype - Test type: unit, feature, or integrationGet debugging strategies for a failing test.
Arguments:
test_name (required) - Name of the failing testerror_message - The error messageGet recommendations for improving test coverage.
Arguments:
target_coverage - Target percentage (default: 80)focus_area - Area to focus on (e.g., Models, Controllers)# Test framework: 'pest', 'phpunit', or leave empty for auto-detection
TEST_MCP_FRAMEWORK=
# Test execution timeout in seconds (default: 300)
TEST_MCP_TIMEOUT=300
# Coverage driver: 'xdebug', 'pcov', or leave empty for auto-detection
TEST_MCP_COVERAGE_DRIVER=
# Confirmation threshold: warn when running more than N tests (default: 50)
TEST_MCP_CONFIRMATION_THRESHOLD=50
# Rate limiting
TEST_MCP_RATE_LIMIT_ENABLED=true
TEST_MCP_RATE_LIMIT_MAX_ATTEMPTS=60
TEST_MCP_RATE_LIMIT_DECAY_SECONDS=60
Tools that support progress tracking will output:
Example output:
🚀 Operation started (ID: op_abc123xyz)
🔍 Discovering tests...
⏳ Running tests: [5/10] 50.0%
✅ PASSED | 10/10 tests | 2.5s
To cancel a running operation:
cancel_operation with that IDcomposer require pestphp/pest --devpecl install xdebugpecl install pcovTEST_MCP_RATE_LIMIT_MAX_ATTEMPTS in .envforce: true to run anywaydry_run: true to preview firstTEST_MCP_CONFIRMATION_THRESHOLD in .envMIT