A Model Context Protocol (MCP) server that provides access to Swarmia's Export API. This server allows you to fetch various metrics and reports from Swarmia including pull request metrics, DORA metrics, investment balance reports, software capitalization reports, and effort reporting. This MCP server provides access to the following Swarmia Export API endpoints: - Pull Request Metrics - Cycle time
Add this skill
npx mdskills install mattjegan/swarmia-mcpComprehensive MCP server for Swarmia metrics with clear tool docs and setup
1# Swarmia MCP Server23A Model Context Protocol (MCP) server that provides access to Swarmia's Export API. This server allows you to fetch various metrics and reports from Swarmia including pull request metrics, DORA metrics, investment balance reports, software capitalization reports, and effort reporting.45## Features67This MCP server provides access to the following Swarmia Export API endpoints:89- **Pull Request Metrics** - Cycle time, review rate, merge time, PRs in progress, etc.10- **DORA Metrics** - Deployment frequency, change lead time, change failure rate, mean time to recovery11- **Investment Balance** - Monthly FTE data and investment category breakdowns12- **Software Capitalization Report** - Employee contributions to capitalizable work13- **Software Capitalization Employees** - FTE effort breakdown by month for each employee14- **Effort Reporting** - Authors and their FTE for each issue in a given month1516## Prerequisites1718- Python 3.8 or higher19- A Swarmia account with API access20- A Swarmia API token (obtain from Settings/API tokens in your Swarmia dashboard)2122## Integration with MCP Clients2324To use this MCP server with your favourite MCP client (E.g. Claude, Cursor etc.):25261. **Ensure depedancies are installed**27```bash28make install29```30312. **Add the following to your MCP configuration**32```json33 {34 "mcpServers": {35 "swarmia": {36 "command": "/path/to/swarmia-mcp/venv/bin/python3",37 "args": ["/path/to/swarmia-mcp/swarmia_mcp_server.py"],38 "env": {39 "SWARMIA_API_TOKEN": "your_api_token_here"40 }41 }42 }43 }44```45463. **Restart your client application**47484. **Ask for some metrics**49 Example queries:50 - "Analyze our team's pull request cycle time trends"51 - "Get the software capitalization report for Q1 2024"52 - "Show me effort reporting for last month"5354## Installation for Development55561. Clone or download this repository572. Install the required dependencies and setup the project:5859```bash60make install61```62633. Set up your Swarmia API token as an environment variable:6465```bash66export SWARMIA_API_TOKEN="your_api_token_here"67```6869### Quick Setup7071For a complete setup including dependency installation and environment checks:7273```bash74make setup75```7677## Usage7879### Running the MCP Server8081To run the server:8283```bash84make run85```8687Or directly:8889```bash90python3 swarmia_mcp_server.py91```9293The server will start and listen for MCP client connections via stdio.9495### Available Tools9697The server provides the following tools:9899#### 1. `get_pull_request_metrics`100Get pull request metrics for the organization.101102**Parameters:**103- `timeframe` (optional): Predefined timeframe (`last_7_days`, `last_14_days`, `last_30_days`, etc.)104- `start_date` (optional): Start date in YYYY-MM-DD format (alternative to timeframe)105- `end_date` (optional): End date in YYYY-MM-DD format (alternative to timeframe)106- `timezone` (optional): Timezone for data aggregation (default: UTC)107108**Returns:** CSV data with columns including Start Date, End Date, Team, Cycle Time, Review Rate, Time to first review, PRs merged/week, Merge Time, PRs in progress, Contributors.109110#### 2. `get_dora_metrics`111Get DORA metrics for the organization.112113**Parameters:**114- `timeframe` (optional): Predefined timeframe115- `start_date` (optional): Start date in YYYY-MM-DD format116- `end_date` (optional): End date in YYYY-MM-DD format117- `timezone` (optional): Timezone for data aggregation118- `app` (optional): Deployment application name(s), comma-separated119- `environment` (optional): Deployment environment(s), comma-separated120121**Returns:** CSV data with DORA metrics including Deployment Frequency, Change Lead Time, Average Time to Deploy, Change Failure Rate, Mean Time to Recovery, Deployment Count.122123#### 3. `get_investment_balance`124Get investment balance statistics using the Effort model.125126**Parameters:**127- `start_date` (required): First day of the month in YYYY-MM-DD format128- `end_date` (required): Last day of the month in YYYY-MM-DD format129- `timezone` (optional): Timezone for data aggregation130131**Returns:** CSV data with investment categories, FTE months, relative percentages, and activity counts.132133#### 4. `get_software_capitalization_report`134Get software capitalization report with employee contributions.135136**Parameters:**137- `start_date` (required): First day of the start month in YYYY-MM-DD format138- `end_date` (required): Last day of the end month in YYYY-MM-DD format139- `timezone` (optional): Timezone for data aggregation140141**Returns:** CSV data with employee details, capitalizable work, developer months, and additional context.142143#### 5. `get_software_capitalization_employees`144Get list of employees with FTE effort breakdown by month.145146**Parameters:**147- `year` (required): Year for the report (e.g., 2024)148- `timezone` (optional): Timezone for data aggregation149150**Returns:** CSV data with employee details and monthly FTE breakdowns.151152#### 6. `get_effort_reporting`153Get effort reporting for authors and their FTE for each issue.154155**Parameters:**156- `month` (required): Month in YYYY-MM-DD format (first day of the month)157- `timezone` (optional): Timezone for data aggregation158- `custom_field` (optional): Jira field ID to include as Custom field column159- `group_by` (optional): How FTE rows should be grouped (`highestLevelIssue`, `lowestLevelIssue`, `customField`)160161**Returns:** CSV data with author details, FTE contributions, and issue information.162163## Configuration164165### Environment Variables166167- `SWARMIA_API_TOKEN`: Your Swarmia API token (required)168169### Timeframes170171The following predefined timeframes are available:172- `last_7_days`173- `last_14_days`174- `last_30_days`175- `last_60_days`176- `last_90_days`177- `last_180_days`178- `last_365_days`179180### Timezones181182You can specify any timezone using tz database identifiers (e.g., `America/New_York`, `Europe/London`, `Asia/Tokyo`). The default is UTC.183184## API Reference185186This MCP server is based on the [Swarmia Export API documentation](https://help.swarmia.com/getting-started/integrations/data-export/export-api).187188### Base URL189```190https://app.swarmia.com/api/v0191```192193### Authentication194The server uses token-based authentication. Your API token is passed as a query parameter to all requests.195196## Error Handling197198The server includes comprehensive error handling for:199- Missing or invalid API tokens200- HTTP request failures201- Invalid parameters202- API rate limiting203- Network connectivity issues204205## Logging206207The server logs all activities at the INFO level. You can adjust the logging level by modifying the `logging.basicConfig()` call in the server code.208209## Development210211### Available Make Targets212213The project includes a comprehensive Makefile with the following targets:214215- `make help` - Show available targets and help information216- `make install` - Install dependencies and setup the project217- `make setup` - Complete setup (install + environment checks)218- `make test` - Test the API connection and server functionality219- `make run` - Run the MCP server220- `make check-env` - Check if required environment variables are set221- `make clean` - Clean up temporary files222- `make format` - Format code with black (if available)223- `make lint` - Lint code with flake8 (if available)224- `make type-check` - Type check with mypy (if available)225- `make quality` - Run all quality checks226- `make info` - Show project information227228### Testing229230To test the server:231232```bash233make test234```235236## Example Usage237238Here's an example of how you might use this server with an MCP client:239240```python241# Example: Get pull request metrics for the last 30 days242result = await client.call_tool(243 "get_pull_request_metrics",244 {245 "timeframe": "last_30_days",246 "timezone": "America/New_York"247 }248)249250# Example: Get DORA metrics for a specific date range251result = await client.call_tool(252 "get_dora_metrics",253 {254 "start_date": "2024-01-01",255 "end_date": "2024-01-31",256 "app": "my-app",257 "environment": "production"258 }259)260261# Example: Get investment balance for January 2024262result = await client.call_tool(263 "get_investment_balance",264 {265 "start_date": "2024-01-01",266 "end_date": "2024-01-31"267 }268)269```270271## Troubleshooting272273### Common Issues2742751. **"SWARMIA_API_TOKEN environment variable is required"**276 - Make sure you've set the `SWARMIA_API_TOKEN` environment variable277 - Verify your token is valid and has the necessary permissions2782792. **"API request failed with status 401"**280 - Your API token may be invalid or expired281 - Check your token in the Swarmia dashboard2822833. **"API request failed with status 403"**284 - Your token may not have permission to access the requested data285 - Contact your Swarmia administrator2862874. **"Request failed: Connection timeout"**288 - Check your internet connection289 - Verify that `app.swarmia.com` is accessible from your network290291### Getting Help292293- Check the [Swarmia Export API documentation](https://help.swarmia.com/getting-started/integrations/data-export/export-api)294- Review the Swarmia API token settings in your dashboard295- Contact Swarmia support for API-related issues296
Full transparency — inspect the skill content before installing.