home / mcp / fastmcp sonarqube metrics mcp server
Chat with your SonarQube data: explore metrics, compare trends, and track issues—effortlessly.
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.
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.
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.pyEnvironment 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> # OptionalPerforms a health check on the configured SonarQube instance.
Creates a new SonarQube project. Requires administrator privileges.
Deletes a SonarQube project. Requires administrator privileges. Use with caution.
Lists all accessible SonarQube projects, optionally filtered by name or key.
Retrieves specified metrics (bugs, vulnerabilities, code smells, coverage, duplication density) for a given project key.
Retrieves historical metrics for a given project using /api/measures/search_history with optional date filters.
Retrieves metric values for all components in a project using /api/measures/component_tree with automatic pagination.
Fetch SonarQube issues for a given project, with optional filters for type, severity, resolution status, and limit.