Swarmia MCP Server

Swarmia MCP Server

Enables querying Swarmia's Export API for engineering metrics including pull request analytics, DORA metrics, investment balance, and effort reporting through an MCP interface.

Category
访问服务器

README

Swarmia MCP Server

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.

Features

This MCP server provides access to the following Swarmia Export API endpoints:

  • Pull Request Metrics - Cycle time, review rate, merge time, PRs in progress, etc.
  • DORA Metrics - Deployment frequency, change lead time, change failure rate, mean time to recovery
  • Investment Balance - Monthly FTE data and investment category breakdowns
  • Software Capitalization Report - Employee contributions to capitalizable work
  • Software Capitalization Employees - FTE effort breakdown by month for each employee
  • Effort Reporting - Authors and their FTE for each issue in a given month

Prerequisites

  • Python 3.8 or higher
  • A Swarmia account with API access
  • A Swarmia API token (obtain from Settings/API tokens in your Swarmia dashboard)

Integration with MCP Clients

To use this MCP server with your favourite MCP client (E.g. Claude, Cursor etc.):

  1. Ensure depedancies are installed
make install
  1. Add the following to your MCP configuration
   {
     "mcpServers": {
       "swarmia": {
         "command": "/path/to/swarmia-mcp/venv/bin/python3",
         "args": ["/path/to/swarmia-mcp/swarmia_mcp_server.py"],
         "env": {
           "SWARMIA_API_TOKEN": "your_api_token_here"
         }
       }
     }
   }
  1. Restart your client application

  2. Ask for some metrics Example queries:

    • "Analyze our team's pull request cycle time trends"
    • "Get the software capitalization report for Q1 2024"
    • "Show me effort reporting for last month"

Installation for Development

  1. Clone or download this repository
  2. Install the required dependencies and setup the project:
make install
  1. Set up your Swarmia API token as an environment variable:
export SWARMIA_API_TOKEN="your_api_token_here"

Quick Setup

For a complete setup including dependency installation and environment checks:

make setup

Usage

Running the MCP Server

To run the server:

make run

Or directly:

python3 swarmia_mcp_server.py

The server will start and listen for MCP client connections via stdio.

Available Tools

The server provides the following tools:

1. get_pull_request_metrics

Get pull request metrics for the organization.

Parameters:

  • timeframe (optional): Predefined timeframe (last_7_days, last_14_days, last_30_days, etc.)
  • start_date (optional): Start date in YYYY-MM-DD format (alternative to timeframe)
  • end_date (optional): End date in YYYY-MM-DD format (alternative to timeframe)
  • timezone (optional): Timezone for data aggregation (default: UTC)

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.

2. get_dora_metrics

Get DORA metrics for the organization.

Parameters:

  • timeframe (optional): Predefined timeframe
  • start_date (optional): Start date in YYYY-MM-DD format
  • end_date (optional): End date in YYYY-MM-DD format
  • timezone (optional): Timezone for data aggregation
  • app (optional): Deployment application name(s), comma-separated
  • environment (optional): Deployment environment(s), comma-separated

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.

3. get_investment_balance

Get investment balance statistics using the Effort model.

Parameters:

  • start_date (required): First day of the month in YYYY-MM-DD format
  • end_date (required): Last day of the month in YYYY-MM-DD format
  • timezone (optional): Timezone for data aggregation

Returns: CSV data with investment categories, FTE months, relative percentages, and activity counts.

4. get_software_capitalization_report

Get software capitalization report with employee contributions.

Parameters:

  • start_date (required): First day of the start month in YYYY-MM-DD format
  • end_date (required): Last day of the end month in YYYY-MM-DD format
  • timezone (optional): Timezone for data aggregation

Returns: CSV data with employee details, capitalizable work, developer months, and additional context.

5. get_software_capitalization_employees

Get list of employees with FTE effort breakdown by month.

Parameters:

  • year (required): Year for the report (e.g., 2024)
  • timezone (optional): Timezone for data aggregation

Returns: CSV data with employee details and monthly FTE breakdowns.

6. get_effort_reporting

Get effort reporting for authors and their FTE for each issue.

Parameters:

  • month (required): Month in YYYY-MM-DD format (first day of the month)
  • timezone (optional): Timezone for data aggregation
  • custom_field (optional): Jira field ID to include as Custom field column
  • group_by (optional): How FTE rows should be grouped (highestLevelIssue, lowestLevelIssue, customField)

Returns: CSV data with author details, FTE contributions, and issue information.

Configuration

Environment Variables

  • SWARMIA_API_TOKEN: Your Swarmia API token (required)

Timeframes

The following predefined timeframes are available:

  • last_7_days
  • last_14_days
  • last_30_days
  • last_60_days
  • last_90_days
  • last_180_days
  • last_365_days

Timezones

You can specify any timezone using tz database identifiers (e.g., America/New_York, Europe/London, Asia/Tokyo). The default is UTC.

API Reference

This MCP server is based on the Swarmia Export API documentation.

Base URL

https://app.swarmia.com/api/v0

Authentication

The server uses token-based authentication. Your API token is passed as a query parameter to all requests.

Error Handling

The server includes comprehensive error handling for:

  • Missing or invalid API tokens
  • HTTP request failures
  • Invalid parameters
  • API rate limiting
  • Network connectivity issues

Logging

The server logs all activities at the INFO level. You can adjust the logging level by modifying the logging.basicConfig() call in the server code.

Development

Available Make Targets

The project includes a comprehensive Makefile with the following targets:

  • make help - Show available targets and help information
  • make install - Install dependencies and setup the project
  • make setup - Complete setup (install + environment checks)
  • make test - Test the API connection and server functionality
  • make run - Run the MCP server
  • make check-env - Check if required environment variables are set
  • make clean - Clean up temporary files
  • make format - Format code with black (if available)
  • make lint - Lint code with flake8 (if available)
  • make type-check - Type check with mypy (if available)
  • make quality - Run all quality checks
  • make info - Show project information

Testing

To test the server:

make test

Example Usage

Here's an example of how you might use this server with an MCP client:

# Example: Get pull request metrics for the last 30 days
result = await client.call_tool(
    "get_pull_request_metrics",
    {
        "timeframe": "last_30_days",
        "timezone": "America/New_York"
    }
)

# Example: Get DORA metrics for a specific date range
result = await client.call_tool(
    "get_dora_metrics",
    {
        "start_date": "2024-01-01",
        "end_date": "2024-01-31",
        "app": "my-app",
        "environment": "production"
    }
)

# Example: Get investment balance for January 2024
result = await client.call_tool(
    "get_investment_balance",
    {
        "start_date": "2024-01-01",
        "end_date": "2024-01-31"
    }
)

Troubleshooting

Common Issues

  1. "SWARMIA_API_TOKEN environment variable is required"

    • Make sure you've set the SWARMIA_API_TOKEN environment variable
    • Verify your token is valid and has the necessary permissions
  2. "API request failed with status 401"

    • Your API token may be invalid or expired
    • Check your token in the Swarmia dashboard
  3. "API request failed with status 403"

    • Your token may not have permission to access the requested data
    • Contact your Swarmia administrator
  4. "Request failed: Connection timeout"

    • Check your internet connection
    • Verify that app.swarmia.com is accessible from your network

Getting Help

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选