README.mdโข9.83 kB
# TestRail MCP Server
A comprehensive Model Context Protocol (MCP) server for TestRail integration, providing seamless access to TestRail's test management capabilities through MCP tools with advanced project management, reporting, and AutoSpectra integration.
## ๐ Features
### Core TestRail Integration
- **Complete TestRail API Coverage**: Projects, suites, cases, runs, results, plans, milestones
- **MCP Protocol Integration**: Native MCP server implementation
- **Type-Safe**: Full TypeScript support with comprehensive type definitions
- **Bulk Operations**: Support for bulk test case and result operations
- **Real-time Updates**: WebSocket support for real-time TestRail updates
### Advanced Project Management
- **๐๏ธ Advanced Project Creation**: Template-driven project setup with predefined structures
- **๐ Project Health Analysis**: Comprehensive project structure analysis with recommendations
- **โก Bulk Suite Management**: Efficient bulk operations on test suites with validation
- **๐ฏ Template System**: Pre-built templates for functional, API, performance, security, and mobile testing
### Comprehensive Reporting & Analytics
- **๐ Project Dashboards**: Interactive dashboards with metrics, trends, and failure analysis
- **๐ Test Case Metrics**: Detailed analysis of test case execution patterns and health
- **๐ Coverage Reports**: Comprehensive test coverage analysis by priority, type, and automation
- **๐ Trend Analysis**: Historical trend analysis with pass rate and completion tracking
- **๐ฏ Flakiness Detection**: Automated identification of flaky tests
### AutoSpectra Integration
- **๐ Seamless Sync**: Direct integration with AutoSpectra test automation framework
- **๐ CI/CD Ready**: Built-in support for GitHub Actions, Jenkins, and other CI/CD platforms
- **๐ Auto Case Creation**: Automatic test case creation from AutoSpectra test results
- **๐ Real-time Monitoring**: Live test execution monitoring and result submission
### Enterprise Features
- **๐ Security**: Enterprise-grade security with encrypted credentials and audit logging
- **โก Performance**: Optimized for large datasets with rate limiting and batching
- **๐ก๏ธ Error Handling**: Comprehensive error handling with retry logic and graceful degradation
- **๐ Comprehensive Testing**: Unit, integration, and E2E tests with 95%+ coverage
## ๐ Project Structure
```
testrail-mcp-server/
โโโ src/ # Source code
โ โโโ types/ # TypeScript type definitions
โ โ โโโ testrail.ts # TestRail API types
โ โ โโโ mcp.ts # MCP-specific types
โ โ โโโ index.ts # Type exports
โ โโโ tools/ # MCP tool implementations
โ โโโ utils/ # Utility functions and helpers
โ โโโ index.ts # Main server entry point
โโโ tests/ # Test suites
โ โโโ unit/ # Unit tests
โ โโโ integration/ # Integration tests
โ โโโ e2e/ # End-to-end tests
โโโ docs/ # Documentation
โ โโโ api/ # API documentation
โ โโโ guides/ # User guides and tutorials
โโโ examples/ # Usage examples
โ โโโ basic/ # Basic usage examples
โ โโโ advanced/ # Advanced usage examples
โโโ package.json # Package configuration
โโโ tsconfig.json # TypeScript configuration
โโโ .env.example # Environment configuration template
โโโ .gitignore # Git ignore rules
```
## โก Quick Start
### Prerequisites
- Node.js 16.0 or higher
- TestRail instance with API access
- TestRail API key
### Installation
```bash
# Clone the repository
git clone https://github.com/samuelvinay91/testrail-mcp.git
cd testrail-mcp
# Install dependencies
npm install
# Copy environment configuration
cp .env.example .env
# Edit .env with your TestRail credentials
# TESTRAIL_BASE_URL=https://your-instance.testrail.io
# TESTRAIL_USERNAME=your.email@company.com
# TESTRAIL_API_KEY=your-api-key-here
# Build and start
npm run build
npm start
```
### ๐ค Quick Setup with AI Coding Agents
**Interactive Setup (Recommended)**:
```bash
# Run the interactive setup script
npm run setup-agents
# Follow the prompts to configure your preferred coding agent
# Supports: Claude Desktop, Cursor IDE, Windsurf IDE, Continue (VS Code)
```
**Manual Configuration Examples**:
**Claude Desktop**:
```json
// ~/.claude-desktop/config.json
{
"mcpServers": {
"testrail": {
"command": "node",
"args": ["path/to/testrail-mcp/dist/index.js"],
"env": {
"TESTRAIL_BASE_URL": "https://yourcompany.testrail.io",
"TESTRAIL_USERNAME": "your.email@company.com",
"TESTRAIL_API_KEY": "your-api-key"
}
}
}
}
```
**Cursor IDE**:
```json
// Cursor Settings > MCP Configuration
{
"mcp": {
"servers": [{
"name": "testrail",
"command": "node",
"args": ["./dist/index.js"],
"cwd": "/path/to/testrail-mcp"
}]
}
}
```
**Windsurf IDE**:
```json
// .windsurf/mcp-config.json
{
"servers": {
"testrail": {
"command": "node",
"args": ["path/to/testrail-mcp/dist/index.js"],
"transport": "stdio"
}
}
}
```
๐ **See [complete setup guide](./docs/guides/coding-agents-setup.md) for detailed instructions with Claude, Cursor, Windsurf, Continue, Cody, and more!**
### Development
```bash
# Start development server
npm run dev
# Build the project
npm run build
# Run tests
npm test
# Run with coverage
npm run test:coverage
# Lint and format
npm run lint
npm run format
```
## ๐ง Configuration
Create a `.env` file based on `.env.example`:
```env
# Required: TestRail connection
TESTRAIL_BASE_URL=https://your-instance.testrail.io
TESTRAIL_USERNAME=your.email@company.com
TESTRAIL_API_KEY=your-api-key-here
# Optional: Server configuration
PORT=3000
NODE_ENV=development
LOG_LEVEL=info
# Optional: Default project settings
DEFAULT_PROJECT_ID=1
DEFAULT_SUITE_ID=1
```
## ๐ Available MCP Tools
The TestRail MCP Server provides the following tools:
### Connection & Authentication
- `connect_testrail` - Connect to TestRail instance
- `test_connection` - Test TestRail connection
### Basic Project Management
- `get_projects` - List all projects
- `get_project` - Get specific project
- `create_project` - Create new project
### Advanced Project Management ๐
- `create_advanced_project` - Create project with templates and initial structure
- `analyze_project_structure` - Analyze project health with recommendations
- `bulk_manage_suites` - Perform bulk operations on test suites
- `create_advanced_suite` - Create suite with templates and structure
### Suite & Section Management
- `get_suites` - List suites in project
- `create_suite` - Create new suite
- `get_sections` - List sections in suite
- `create_section` - Create new section
### Test Case Management
- `get_cases` - List test cases
- `get_case` - Get specific test case
- `create_case` - Create new test case
- `update_case` - Update existing test case
- `delete_case` - Delete test case
### Test Run Management
- `get_runs` - List test runs
- `create_run` - Create new test run
- `update_run` - Update test run
- `close_run` - Close test run
### Test Execution
- `get_tests` - List tests in run
- `add_result` - Add test result
- `add_bulk_results` - Add multiple results
- `get_results` - Get test results
### Advanced Reporting & Analytics ๐
- `generate_project_dashboard` - Generate comprehensive project dashboard
- `generate_execution_report` - Generate detailed test execution reports
- `analyze_case_metrics` - Analyze test case metrics and health
- `generate_coverage_report` - Generate comprehensive test coverage reports
- `generate_report` - Generate custom test reports
### AutoSpectra Integration ๐
- `autospectra_sync` - Synchronize AutoSpectra test results with TestRail
### Legacy Tools (Still Available)
- `get_test_stats` - Get test statistics
- `get_execution_trends` - Get execution trends
## ๐ Documentation
- [API Documentation](./docs/api/) - Detailed API reference
- [User Guides](./docs/guides/) - Step-by-step tutorials
- [Coding Agents Setup](./docs/guides/coding-agents-setup.md) - Integration with Claude, Cursor, Windsurf, and other AI tools
- [AutoSpectra Integration](./docs/guides/autospectra-integration.md) - Advanced test automation integration
- [Getting Started](./docs/guides/getting-started.md) - Complete setup guide
- [Examples](./examples/) - Code examples and use cases
## ๐งช Testing
```bash
# Run all tests
npm test
# Run specific test suites
npm run test:unit
npm run test:integration
npm run test:e2e
# Watch mode
npm run test:watch
# Coverage report
npm run test:coverage
```
## ๐ค Contributing
1. Fork the repository
2. Create a feature branch: `git checkout -b feature/amazing-feature`
3. Commit your changes: `git commit -m 'Add amazing feature'`
4. Push to the branch: `git push origin feature/amazing-feature`
5. Open a Pull Request
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## ๐ Support
- [GitHub Issues](https://github.com/your-username/testrail-mcp-server/issues)
- [Documentation](./docs/)
- [Examples](./examples/)
## ๐ Related Projects
- [TestRail API Documentation](https://www.gurock.com/testrail/docs/api)
- [Model Context Protocol](https://github.com/anthropics/mcp)
- [MCP SDK](https://github.com/anthropics/mcp-sdk)