TestRail MCP Server
Provides tools for managing TestRail projects, suites, test cases, test runs, and test results, enabling AI-assisted test management workflows.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@TestRail MCP Server list all test cases in suite 5"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
TestRail MCP Server
A Model Context Protocol (MCP) server that integrates TestRail with Claude Code, enabling AI-assisted test management workflows.
Features
Project Management: List and retrieve TestRail projects
Suite Management: Access test suites and their configurations
Test Case Operations: Retrieve, update, and manage test cases
Test Run Creation: Create and manage test runs
Results Tracking: Add test results and retrieve execution history
Automation Integration: Link automated tests to TestRail cases
Related MCP server: TestRail MCP Server
Prerequisites
Node.js 18.x or higher
npm or pnpm
TestRail instance with API access enabled
TestRail user account with appropriate permissions
Installation
Option 1: Using Pre-built Container (Recommended)
The easiest way to use the TestRail MCP server is via the pre-built container. See CONTAINER.md for detailed instructions.
Quick start:
# Pull the container
podman pull ghcr.io/yshpyluk/mcp-testrail:latest
# Configure in .mcp.json (see CONTAINER.md for full setup)Option 2: Local Installation
Clone and Install Dependencies
cd mcp-testrail
npm installBuild the Project
npm run buildConfigure Environment Variables
Create a .env file in the project root:
TESTRAIL_BASE_URL=https://your-instance.testrail.io
TESTRAIL_USERNAME=your-email@example.com
TESTRAIL_API_KEY=your-api-key
TESTRAIL_PROJECT_ID=1 # REQUIRED: The TestRail project to work withGetting Your TestRail API Key:
Log in to TestRail
Go to My Settings (top-right corner)
Click on API Keys tab
Click Add Key to generate a new API key
Copy the generated key (you won't be able to see it again)
Configuring Your Project
TESTRAIL_PROJECT_ID is required - this MCP server is designed to work with a single TestRail project. All operations will be performed on the configured project. To find your project ID, check the URL when viewing your project in TestRail (e.g., .../index.php?/projects/overview/1 - the ID is 1).
Configuration for Claude Code
Add the TestRail MCP server to your Claude Code configuration:
Option 1: Global Configuration (~/.config/claude/config.json)
{
"mcpServers": {
"testrail": {
"command": "node",
"args": ["/absolute/path/to/mcp-testrail/dist/index.js"],
"env": {
"TESTRAIL_BASE_URL": "https://your-instance.testrail.io",
"TESTRAIL_USERNAME": "your-email@example.com",
"TESTRAIL_API_KEY": "your-api-key",
"TESTRAIL_PROJECT_ID": "1"
}
}
}
}Option 2: Project-Level Configuration (.mcp.json in project root)
{
"mcpServers": {
"testrail": {
"command": "node",
"args": ["/absolute/path/to/mcp-testrail/dist/index.js"],
"env": {
"TESTRAIL_BASE_URL": "https://your-instance.testrail.io",
"TESTRAIL_USERNAME": "your-email@example.com",
"TESTRAIL_API_KEY": "your-api-key",
"TESTRAIL_PROJECT_ID": "1"
}
}
}
}Security Note: For production use, consider using environment variables instead of hardcoding credentials:
{
"mcpServers": {
"testrail": {
"command": "node",
"args": ["/absolute/path/to/mcp-testrail/dist/index.js"],
"env": {
"TESTRAIL_BASE_URL": "${TESTRAIL_BASE_URL}",
"TESTRAIL_USERNAME": "${TESTRAIL_USERNAME}",
"TESTRAIL_API_KEY": "${TESTRAIL_API_KEY}",
"TESTRAIL_PROJECT_ID": "${TESTRAIL_PROJECT_ID}"
}
}
}
}Available Tools
Project Operations
list_projects
Get all TestRail projects.
Example:
// No parameters neededResponse:
[
{
"id": 1,
"name": "Akrochem ERP",
"is_completed": false,
"suite_mode": 1,
"url": "https://your-instance.testrail.io/index.php?/projects/overview/1"
}
]get_project
Get the configured TestRail project details.
Parameters: None
Suite Operations
list_suites
Get all test suites for the configured project.
Parameters: None
get_suite
Get a specific test suite by ID.
Parameters:
suite_id(number): The ID of the suite
Test Case Operations
list_test_cases
Get test cases for the configured project, optionally filtered by suite.
Parameters:
suite_id(number, optional): Filter by suite ID
Example:
{
"suite_id": 5
}get_test_case
Get a specific test case by ID.
Parameters:
case_id(number): The ID of the test case
update_test_case
Update a test case with new information.
Parameters:
case_id(number): The ID of the test casetitle(string, optional): New titlecustom_automation_id(string, optional): Automation identifierrefs(string, optional): Reference IDs (e.g., "JIRA-123")priority_id(number, optional): Priority (1=Low, 2=Medium, 3=High, 4=Critical)
Example:
{
"case_id": 100,
"custom_automation_id": "tests/specs/ui/purchase-order/new-po-page.spec.ts",
"refs": "AK-1234"
}Test Run Operations
create_test_run
Create a new test run in the configured project.
Parameters:
suite_id(number): The ID of the test suitename(string): Name of the test rundescription(string, optional): Descriptioncase_ids(number[], optional): Specific test cases to include (omit for all cases)
Example:
{
"suite_id": 5,
"name": "Automated Regression - 2025-01-08",
"description": "Nightly automated test run",
"case_ids": [100, 101, 102]
}list_test_runs
Get test runs for the configured project.
Parameters:
suite_id(number, optional): Filter by suite ID
get_test_run
Get a specific test run by ID.
Parameters:
run_id(number): The ID of the test run
close_test_run
Close a test run (mark as completed).
Parameters:
run_id(number): The ID of the test run
Test Results Operations
add_test_results
Add test results for multiple test cases.
Status IDs:
1= Passed2= Blocked3= Untested4= Retest5= Failed
Parameters:
run_id(number): The ID of the test runresults(array): Array of test result objects
Result Object:
case_id(number): Test case IDstatus_id(number): Status (1-5)comment(string, optional): Test result commentversion(string, optional): Version/build testedelapsed(string, optional): Time elapsed (e.g., "1m 30s")defects(string, optional): Comma-separated defect IDs
Example:
{
"run_id": 50,
"results": [
{
"case_id": 100,
"status_id": 1,
"comment": "Test passed successfully",
"version": "v2.5.0",
"elapsed": "45s"
},
{
"case_id": 101,
"status_id": 5,
"comment": "Timeout waiting for element",
"defects": "JIRA-456"
}
]
}get_test_results
Get all test results for a test run.
Parameters:
run_id(number): The ID of the test run
Usage Examples with Claude Code
Example 1: Create Test Run from Playwright Execution
Create a test run in TestRail for the upcoming automated test execution:
- Suite: UI Tests (ID: 5)
- Name: "Automated Regression - [TODAY'S DATE]"
- Include all test cases from the suiteExample 2: Push Test Results from CI/CD
Add test results to TestRail run #50:
- Case 100: Passed (45s)
- Case 101: Failed - "Timeout waiting for selector" (link to JIRA-456)
- Case 102: Passed (1m 20s)Example 3: Sync Automation IDs
Update test cases with automation IDs based on our Playwright test files:
- Case 100 -> tests/specs/ui/purchase-order/new-po-page.spec.ts
- Case 101 -> tests/specs/ui/purchase-order/uom-validation.spec.tsExample 4: Generate Test Coverage Report
List all test cases in suite 5 and compare with our Playwright test files.
Create a coverage report showing which TestRail cases have automated tests.Integration Patterns
Pattern 1: CI/CD Integration
Use the TestRail MCP server in GitHub Actions or other CI/CD pipelines:
# .github/workflows/playwright-testrail.yml
- name: Run Tests and Report to TestRail
run: |
# Run Playwright tests
npx playwright test --reporter=json > test-results.json
# Use Claude Code to parse results and push to TestRail
claude-code "Parse test-results.json and create TestRail run with results"Pattern 2: Manual Test Run Creation
Create a test run for Sprint 23 smoke tests:
- Include only priority 4 (Critical) test cases
- Name: "Sprint 23 - Smoke Tests"Pattern 3: Test Case Management
Update all purchase order test cases to link to Jira epic AK-1000Pattern 4: Results Analysis
Get test results for the last 5 runs and identify flaky tests
(cases that have inconsistent pass/fail status)Development
Build
npm run buildWatch Mode (for development)
npm run watchProject Structure
mcp-testrail/
├── src/
│ ├── index.ts # Main MCP server implementation
│ └── testrail-client.ts # TestRail API client wrapper
├── dist/ # Compiled JavaScript (generated)
├── package.json
├── tsconfig.json
└── README.mdTroubleshooting
"Error: Missing required environment variables"
Ensure TESTRAIL_BASE_URL, TESTRAIL_USERNAME, and TESTRAIL_API_KEY are set in your MCP configuration.
"Error: 401 Unauthorized"
Check that:
Your API key is correct
Your TestRail username is correct
API access is enabled in your TestRail instance (Admin > Site Settings > API)
"Error: Cannot find module"
Run npm run build to compile TypeScript to JavaScript.
"Connection refused"
Verify your TESTRAIL_BASE_URL is correct and accessible from your network.
Security Best Practices
Never commit API keys to version control
Use environment variables for sensitive credentials
Limit API key permissions to only what's needed
Rotate API keys regularly
Use project-level .mcp.json for team-specific configurations
TestRail API Reference
For more details on TestRail API capabilities:
License
MIT
Available Tools
13 toolsadd_test_resultsA
Add test results for multiple test cases in a test run. Status IDs: 1=Passed, 2=Blocked, 3=Untested, 4=Retest, 5=Failed
Inputs: run_id (required), results (required).
close_test_runA
Close a test run (marks it as completed)
Inputs: run_id (required).
create_test_runB
Create a new test run in the configured TestRail project
Inputs: name (required), suite_id (required), case_ids, description.
get_projectB
Get the configured TestRail project details
Inputs: no named parameters.
get_suiteA
Get a specific test suite by ID
Inputs: suite_id (required).
get_test_caseA
Get a specific test case by ID
Inputs: case_id (required).
get_test_resultsA
Get all test results for a test run
Inputs: run_id (required).
get_test_runB
Get a specific test run by ID
Inputs: run_id (required).
list_projectsA
Get all TestRail projects
Inputs: no named parameters.
list_suitesA
Get all test suites for the configured project
Inputs: no named parameters.
list_test_casesA
Get test cases for the configured project. Optionally filter by suite_id.
Inputs: suite_id.
list_test_runsA
Get test runs for the configured project. Optionally filter by suite_id.
Inputs: suite_id.
update_test_caseD
Update a test case with new information
Inputs: case_id (required), refs, title, priority_id, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 13 tools
Each tool targets a distinct resource (project, suite, test case, test run, test result) with a clear action (list, get, create, update, close, add). There is no overlap between list/get variants or between action verbs.
Tool names consistently follow a list_/get_ prefix for read operations and specific action verbs (create, add, update, close) for mutations, all in lowercase snake_case. The pattern is uniform and predictable.
13 tools is well within the ideal range for a domain-specific server, covering all major TestRail entities (projects, suites, test cases, runs, results) without unnecessary redundancy or bloat.
The core workflow of creating runs, adding results, and closing runs is covered, but there are notable gaps: no create/delete for test cases or suites, and no generic get_project by ID. This limits full lifecycle management of test assets.
Maintenance
Related MCP Connectors
Create and manage test cases, test runs and results in Testiny from your AI assistant.
Manage Redbooth tasks, task lists, comments, tags and files from Claude and other AI assistants.
Direct access to Cypress tests results and accessibility reports in your AI workflow.
Test management for AI agents: cases, runs, results, cycles and traceability.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables AI assistants to interact with TestRail test management systems through comprehensive API integration. Supports retrieving and updating test cases, projects, suites, runs, and results, plus adding attachments and managing test data through natural language commands.1840 npmMIT
- AlicenseBqualityDmaintenanceEnables AI assistants to interact directly with TestRail instances for managing test projects, suites, cases, runs, results, plans, milestones, and attachments through the TestRail API with secure authentication.7761 npm1MIT
- AlicenseAqualityCmaintenanceConnect your AI coding assistant to TestRail to manage test cases, runs, results, and more directly from VS Code, Cursor, Claude Desktop, or Claude Code.522 npm1MIT
- AlicenseBqualityDmaintenanceEnables AI assistants to interact with TestRail test management system, supporting full CRUD operations on projects, suites, sections, test cases, runs, results, plans, and milestones.35276 npm1MIT