testrail-mcp-server

testrail-mcp-server

Enables TestRail test management through MCP tools, allowing users to manage projects, test cases, runs, and results via natural language.

Category
访问服务器

README

TestRail MCP Server

A Model Context Protocol (MCP) server for TestRail integration, providing comprehensive access to TestRail's test management functionality through MCP tools.

Features

This MCP server provides tools for:

  • Projects: List and retrieve TestRail projects
  • Test Cases: Create, read, update, and delete test cases
  • Test Runs: Manage test runs (create, update, close, delete)
  • Test Results: Add and retrieve test results (single and bulk operations)
  • Sections: Organize test cases with sections

Prerequisites

  • Node.js 18 or higher
  • A TestRail instance with API access
  • TestRail API key (generate from your TestRail account settings)

Installation

  1. Clone or download this repository
  2. Install dependencies:
npm install
  1. Build the project:
npm run build
  1. Create a .env file in the project root with your TestRail credentials:
cp .env.example .env

Edit .env with your credentials:

TESTRAIL_URL=https://your-instance.testrail.io
TESTRAIL_USERNAME=your-email@example.com
TESTRAIL_API_KEY=your-api-key

Configuration for Claude Code

To use this MCP server with Claude Code, add it to your MCP settings file:

macOS/Linux: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "testrail": {
      "command": "node",
      "args": ["/absolute/path/to/testrail-mcp-server/dist/index.js"],
      "env": {
        "TESTRAIL_URL": "https://your-instance.testrail.io",
        "TESTRAIL_USERNAME": "your-email@example.com",
        "TESTRAIL_API_KEY": "your-api-key"
      }
    }
  }
}

Or if you prefer to use the .env file:

{
  "mcpServers": {
    "testrail": {
      "command": "node",
      "args": ["/absolute/path/to/testrail-mcp-server/dist/index.js"]
    }
  }
}

Available Tools

Projects

  • testrail_get_projects - Get all projects
  • testrail_get_project - Get a specific project by ID

Test Cases

  • testrail_get_cases - Get test cases from a project (optionally filtered by suite)
  • testrail_get_case - Get a specific test case by ID
  • testrail_add_case - Create a new test case in a section
  • testrail_update_case - Update an existing test case
  • testrail_delete_case - Delete a test case

Test Runs

  • testrail_get_runs - Get all test runs in a project
  • testrail_get_run - Get a specific test run by ID
  • testrail_add_run - Create a new test run
  • testrail_update_run - Update an existing test run
  • testrail_close_run - Close a test run
  • testrail_delete_run - Delete a test run

Test Results

  • testrail_get_results - Get test results for a specific test
  • testrail_get_results_for_case - Get test results for a test case in a run
  • testrail_get_results_for_run - Get all test results for a test run
  • testrail_add_result - Add a test result for a specific test
  • testrail_add_result_for_case - Add a test result for a case in a test run
  • testrail_add_results - Add multiple test results (bulk operation)
  • testrail_add_results_for_cases - Add multiple test results for cases (bulk operation)

Sections

  • testrail_get_sections - Get sections from a project (optionally filtered by suite)
  • testrail_get_section - Get a specific section by ID
  • testrail_add_section - Create a new section
  • testrail_update_section - Update an existing section
  • testrail_delete_section - Delete a section

Usage Examples

Once configured, you can use these tools through Claude Code. Here are some example prompts:

Getting Projects

List all TestRail projects

Creating a Test Case

Create a new test case in section 123 with title "Test user login" and priority High

Adding Test Results

Add a passed test result for test case 456 in run 789 with comment "All checks passed"

Creating a Test Run

Create a new test run called "Sprint 24 Testing" for project 1

TestRail Status IDs

When adding test results, use these status IDs:

  • 1 - Passed
  • 2 - Blocked
  • 3 - Untested (retest)
  • 4 - Retest
  • 5 - Failed

TestRail Priority IDs

When creating or updating test cases, use these priority IDs:

  • 1 - Low
  • 2 - Medium
  • 3 - High
  • 4 - Critical

Development

Project Structure

testrail-mcp-server/
├── src/
│   ├── index.ts              # Main MCP server implementation
│   └── testrail-client.ts    # TestRail API client
├── dist/                     # Compiled JavaScript output
├── package.json
├── tsconfig.json
├── .env.example
└── README.md

Building

npm run build

Watching for Changes

npm run watch

Running Locally

npm start

Troubleshooting

Connection Issues

  1. Verify your TestRail credentials are correct
  2. Check that your TestRail instance URL is accessible
  3. Ensure your API key has the necessary permissions
  4. Check the Claude Code logs for detailed error messages

API Errors

  • 401 Unauthorized: Invalid credentials or API key
  • 403 Forbidden: Insufficient permissions for the requested operation
  • 404 Not Found: Resource (project, case, run, etc.) not found
  • 429 Too Many Requests: Rate limit exceeded, wait and retry

API Reference

For more details on TestRail's API, see the official TestRail API documentation.

License

MIT

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

Security

Never commit your .env file or expose your TestRail API credentials. Always use environment variables or secure credential storage.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选