TestRail MCP Server
A Model Context Protocol server that provides integration with TestRail, allowing AI assistants to interact with TestRail projects, test cases, test runs, and results.
README
TestRail MCP Server
A Model Context Protocol (MCP) server that provides integration with TestRail, allowing AI assistants to interact with TestRail projects, test cases, test runs, and results.
Features
Tools
- get_projects: Retrieve all TestRail projects
- get_project: Get details of a specific project
- get_test_cases: Retrieve test cases with optional filtering
- create_test_case: Create new test cases
- get_test_runs: Retrieve test runs for a project
- create_test_run: Create new test runs
- add_test_result: Add test results to test runs
- get_users: Retrieve TestRail users
- test_connection: Test the connection to TestRail
- parse_testrail_url: 🆕 Parse TestRail URLs and auto-call appropriate tools
Resources
- testrail://projects: Access to all TestRail projects
- testrail://users: Access to all TestRail users
Prompts
- test_case_template: Generate comprehensive test case templates
- test_run_summary: Generate detailed test run summary reports
Installation
- Clone this repository:
git clone <repository-url>
cd mcp-testrail
- Install dependencies:
npm install
- Build the project:
npm run build
Configuration
Create a .env file in the root directory with your TestRail configuration:
TESTRAIL_URL=https://your-company.testrail.io
TESTRAIL_USERNAME=your-email@company.com
TESTRAIL_API_KEY=your-api-key
DEFAULT_PROJECT_ID=1
Getting TestRail API Credentials
- Log in to your TestRail instance
- Go to your user profile (click on your name in the top-right corner)
- Navigate to the "API Keys" tab
- Generate a new API key
- Use your email address as the username and the generated key as the API key
Usage
With Claude Desktop
Add the server to your Claude Desktop configuration file (claude_desktop_config.json):
{
"mcpServers": {
"testrail": {
"command": "node",
"args": ["/path/to/mcp-testrail/dist/index.js"],
"env": {
"TESTRAIL_URL": "https://your-company.testrail.io",
"TESTRAIL_USERNAME": "your-email@company.com",
"TESTRAIL_API_KEY": "your-api-key"
}
}
}
}
Direct Usage
You can also run the server directly:
npm start
Or in development mode:
npm run dev
Development
Project Structure
src/
├── index.ts # Main MCP server implementation
├── testrail-client.ts # TestRail API client
└── types.ts # TypeScript type definitions
Available Scripts
npm run build: Build the TypeScript projectnpm run watch: Build and watch for changesnpm start: Start the compiled servernpm run dev: Start the server in development mode with ts-nodenpm run lint: Lint the source code
Building
npm run build
Testing
Test the connection to TestRail:
npm run dev
# Then use the test_connection tool
API Coverage
This MCP server covers the following TestRail API endpoints:
Projects
GET /get_projects- Get all projectsGET /get_project/{id}- Get project details
Test Cases
GET /get_cases/{project_id}- Get test casesGET /get_case/{id}- Get test case detailsPOST /add_case/{section_id}- Create test casePOST /update_case/{id}- Update test case
Test Runs
GET /get_runs/{project_id}- Get test runsGET /get_run/{id}- Get test run detailsPOST /add_run/{project_id}- Create test runPOST /close_run/{id}- Close test run
Test Results
GET /get_results/{test_id}- Get test resultsPOST /add_result/{test_id}- Add test resultPOST /add_result_for_case/{run_id}/{case_id}- Add result for specific case
Users
GET /get_users- Get all usersGET /get_user/{id}- Get user details
Suites & Sections
GET /get_suites/{project_id}- Get test suitesGET /get_sections/{project_id}- Get sectionsGET /get_milestones/{project_id}- Get milestones
Examples
URL Parsing (New Feature!)
Simply paste any TestRail URL and get the data automatically:
// Parse a test case URL
{
"url": "https://moneyforward.tmxtestrail.com/index.php?/cases/view/2322865"
}
// Automatically detects it's a test case and retrieves case ID 2322865
// Parse a test run URL
{
"url": "https://company.testrail.io/runs/view/456"
}
// Automatically detects it's a test run and retrieves run details
// Parse test cases list with filters
{
"url": "https://company.testrail.io/cases/123?suite_id=5§ion_id=10"
}
// Automatically retrieves filtered test cases
Creating a Test Case
// Using the create_test_case tool
{
"sectionId": 123,
"title": "Test user login functionality",
"type_id": 1,
"priority_id": 2,
"custom_steps_separated": [
{
"content": "Navigate to login page",
"expected": "Login page is displayed"
},
{
"content": "Enter valid credentials",
"expected": "User is logged in successfully"
}
]
}
Adding Test Results
// Using the add_test_result tool
{
"runId": 456,
"caseId": 789,
"status_id": 1, // Passed
"comment": "Test executed successfully",
"elapsed": "5m",
"version": "v1.2.3"
}
Error Handling
The server includes comprehensive error handling and will return detailed error messages for:
- Invalid TestRail credentials
- Network connectivity issues
- Invalid parameters
- TestRail API errors
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
MIT License - see LICENSE file for details.
Support
For issues and questions:
- Check the TestRail API documentation
- Verify your credentials and network connectivity
- Check the server logs for detailed error messages
- Open an issue in this repository
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。