home / mcp / fastmcp sonarqube metrics mcp server

FastMCP SonarQube Metrics MCP Server

Chat with your SonarQube data: explore metrics, compare trends, and track issues—effortlessly.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "archai-labs-fastmcp-sonarqube-metrics": {
      "command": "python",
      "args": [
        "server.py"
      ],
      "env": {
        "TRANSPORT": "stdio",
        "GEMINI_MODEL": "<your_gemini_model> (Optional)",
        "SONARQUBE_URL": "<your_sonarqube_url>",
        "GEMINI_API_KEY": "<your_gemini_api_key>",
        "SONARQUBE_TOKEN": "<your_sonarqube_token>",
        "AZURE_OPENAI_API_KEY": "your_azure_api_key",
        "AZURE_OPENAI_ENDPOINT": "https://your-endpoint"
      }
    }
  }
}

You set up a FastMCP server that exposes SonarQube metrics through a lightweight client/server bridge. It lets you fetch current metrics, historical data, and component-level metrics for SonarQube projects, automate reporting, and integrate SonarQube data into your workflows without writing direct API calls.

How to use

Start the server locally and connect a client to request SonarQube metrics. You can run the server and then use a test client to invoke tools like get_sonarqube_metrics, get_sonarqube_metrics_history, and get_sonarqube_component_tree_metrics. The server reads SonarQube connection details from environment settings, so ensure those are configured before you begin.

How to install

Prerequisites: you need Python 3.7 or newer and a SonarQube instance with API access. You will also install a few Python packages to run the MCP server and its clients.

Step-by-step commands to get you from zero to a running server and test client:

# 1) Install Python packages
pip install fastmcp
pip install httpx
pip install pydantic
pip install python-dotenv

# 2) Run the server (from the project root where server.py exists)
python server.py

# 3) Optional: run a test client to verify basic functionality
python client_test.py

Additional notes

Environment variables configure your SonarQube connection and transport. Create a .env file in the project root with values like these (placeholders shown):

SONARQUBE_URL=<your_sonarqube_url>
SONARQUBE_TOKEN=<your_sonarqube_token>
TRANSPORT=<stdio or sse>
GEMINI_API_KEY=<your-gemini-api_key>
GEMINI_MODEL=<your-gemini-model>  # Optional

Available tools

get_status

Performs a health check on the configured SonarQube instance.

create_sonarqube_project

Creates a new SonarQube project. Requires administrator privileges.

delete_sonarqube_project

Deletes a SonarQube project. Requires administrator privileges. Use with caution.

list_projects

Lists all accessible SonarQube projects, optionally filtered by name or key.

get_sonarqube_metrics

Retrieves specified metrics (bugs, vulnerabilities, code smells, coverage, duplication density) for a given project key.

get_sonarqube_metrics_history

Retrieves historical metrics for a given project using /api/measures/search_history with optional date filters.

get_sonarqube_component_tree_metrics

Retrieves metric values for all components in a project using /api/measures/component_tree with automatic pagination.

get_project_issues

Fetch SonarQube issues for a given project, with optional filters for type, severity, resolution status, and limit.