swarmia-mcp is a local server based on the Model Context Protocol (MCP) that provides read-only access to the Swarmia Export API. It allows users to retrieve a variety of metrics and reports from Swarmia, including pull request metrics, DORA metrics, investment balance reports, software capitalization reports, and work hour reports.
Purpose
The server is designed to enable MCP clients (such as Claude, Cursor, etc.) to query engineering performance data in Swarmia through natural language for quick reporting and analysis.
Main Capabilities
The server provides the following tools, corresponding to Swarmia Export API endpoints:
-
Pull Request Metrics: Retrieve the organization's pull request metrics, including cycle time, review rate, merge time, in-progress PRs, etc. Parameters include an optional time range (such as last_7_days, last_14_days, last_30_days, etc.), start date (YYYY-MM-DD), end date (YYYY-MM-DD), and time zone (default UTC). Returns CSV data, including columns such as start date, end date, team, cycle time, review rate, time to first review, number of merged PRs per week, merge time, in-progress PRs, contributors, etc.
-
DORA Metrics: Retrieve the organization's DORA metrics, including deployment frequency, lead time for changes, change failure rate, and mean time to recovery. Parameters include an optional time range, start date, end date, time zone, as well as optional deployment application names (comma-separated) and deployment environments (comma-separated). Returns CSV data, including deployment frequency, lead time for changes, average deployment time, change failure rate, mean time to recovery, deployment count, etc.
-
Investment Balance: Retrieve investment balance statistics using the Effort model. Requires a start date (YYYY-MM-DD, the first day of the month) and an end date (YYYY-MM-DD, the last day of the month). Returns CSV data, including investment category, FTE months, relative percentage, and activity count.
-
Software Capitalization Report: Retrieve a software capitalization report that includes employee contributions. Requires a start date (YYYY-MM-DD, the first day of the starting month) and an end date (YYYY-MM-DD, the last day of the ending month). Returns CSV data, including employee details, capitalizable work, developer months, and additional context.
-
Software Capitalization Employees: Get the employee list and their monthly FTE breakdown. Requires a year (e.g., 2024). Returns CSV data containing employee details and monthly FTE breakdown.
-
Effort Reporting: Get the author of each issue and their FTE. Requires a month (YYYY-MM-DD, the first day of the month), optional custom fields (Jira field IDs, included as Custom field columns), and grouping method (highestLevelIssue, lowestLevelIssue, customField). Returns CSV data containing author details, FTE contributions, and issue information.
Usage
Environment Requirements
- Python 3.8 or higher
- A Swarmia account with API access
- A Swarmia API token (obtained from Settings/API tokens in the Swarmia dashboard)
Integration with MCP Clients
- Ensure dependencies are installed
- Add the following configuration to the MCP configuration
- Restart the client application
- Query metrics, for example: "Analyze our team's pull request cycle time trends", "Get the software capitalization report for Q1 2024", "Show me effort reporting for last month"
Development Installation
- Clone or download this repository
- Install the required dependencies and set up the project
- Set the Swarmia API token as an environment variable
- Full setup includes dependency installation and environment checks
Running the MCP Server
After running the server, it will start and listen for MCP client connections via stdio.
Environment Variables
- SWARMIA_API_TOKEN: Your Swarmia API token (required)
Available Make Targets
The project includes a Makefile that provides the following targets:
- make help: Display available targets and help information
- make install: Install dependencies and set up the project
- make setup: Full setup (installation + environment checks)
- make test:Test the API connection and server functionality
- make run: Run the MCP server
- make check-env: Check whether the required environment variables are set
- make clean: Clean up temporary files
- make format: Format code with black (if available)
- make lint: Check code with flake8 (if available)
- make type-check: Perform type checking with mypy (if available)
- make quality: Run all quality checks
- make info: Display project information
Use Cases
Suitable for scenarios that require quickly obtaining engineering effectiveness metrics and reports from Swarmia, such as analyzing team pull request cycle time trends, getting software capitalization reports, and viewing effort reports. Through the MCP client, users can query data in natural language without directly calling the API.
Limitations
- The server is read-only and cannot modify data in Swarmia.
- A valid Swarmia API token is required, and the token must have permission to access the required data.
- It depends on a network connection and must be able to access app.swarmia.com.
- The server uses token-based authentication, and the API token is passed as a query parameter to all requests.
- The server includes error handling covering missing or invalid API tokens, HTTP request failures, invalid parameters, API rate limits, and network connection issues.
- The server logs all activity at the INFO level, and the log level can be adjusted by modifying the logging.basicConfig() call in the server code.
- Predefined time ranges are available, and time zones can use tz database identifiers (such as America/New_York, Europe/London, Asia/Tokyo), with UTC as the default.
- This MCP server is based on the Swarmia Export API documentation.