sonarqube-mcp-server
SonarQube MCP Server: Connect AI to SonarQube for intelligent code quality analysis.

sonarqube-mcp-server Solution Overview
The SonarQube MCP Server is a valuable tool within the MCP ecosystem, acting as a bridge between AI models and SonarQube's code quality analysis platform. This server empowers AI assistants to access and interpret crucial code quality metrics, identify issues, and track project health trends directly from SonarQube. By providing AI models with this contextual understanding of code quality, developers can leverage AI to automate code reviews, prioritize bug fixes, and proactively improve code quality.
Key features include listing SonarQube projects and retrieving detailed issue information with extensive filtering options. The server supports both SonarQube and SonarCloud, ensuring broad compatibility. Implemented with TypeScript and leveraging Zod for parameter validation, the SonarQube MCP Server offers a robust and reliable solution for integrating code quality insights into AI-powered development workflows. It can be easily integrated using Docker, NPX, or local Node execution.
sonarqube-mcp-server Key Capabilities
Code Quality Metrics Retrieval
The sonarqube-mcp-server
allows AI models to retrieve code quality metrics from SonarQube. This functionality enables AI assistants to understand the overall health and maintainability of a codebase. The server acts as a bridge, translating MCP requests into SonarQube API calls and returning the results in a structured format that AI models can easily process. This includes metrics like code coverage, technical debt, and code complexity. By providing access to these metrics, the server empowers AI models to provide more informed and context-aware assistance to developers.
For example, an AI assistant could use this feature to automatically assess the impact of a proposed code change on the overall code quality, identifying potential regressions or areas of concern before the change is even committed. The server uses the SonarQube API to fetch the metrics, requiring a valid SONARQUBE_TOKEN
for authentication.
Issue Access and Filtering
This feature provides AI models with the ability to access and filter issues reported by SonarQube. This allows AI assistants to understand the specific problems within a codebase, such as bugs, vulnerabilities, and code smells. The server supports extensive filtering options, including severity, status, resolution, type, rules, and tags, enabling AI models to focus on the most relevant issues. This granular control allows AI assistants to provide targeted guidance to developers, helping them prioritize and address the most critical problems.
For instance, an AI assistant could use this feature to identify all critical vulnerabilities in a specific project and provide developers with remediation advice based on the issue type and context. The issues
tool requires a project_key
parameter and supports various optional parameters for filtering, such as severity
, statuses
, and types
.
Project Listing with Pagination
The sonarqube-mcp-server
provides a tool to list all SonarQube projects with pagination support. This is crucial for AI models that need to process large numbers of projects without overwhelming the system. The pagination feature allows the AI to retrieve projects in manageable chunks, improving performance and scalability. This functionality is particularly useful in organizations with many projects, where an AI assistant might need to analyze code quality across the entire portfolio.
For example, an AI assistant could use this feature to generate a report summarizing the code quality of all projects in an organization, broken down by team or business unit. The projects
tool supports optional parameters for page
and page_size
, allowing the AI to control the number of projects returned per request.
Comprehensive Parameter Validation
The server employs Zod schemas for comprehensive parameter validation. This ensures that all incoming requests adhere to the expected data types and formats, preventing errors and improving the reliability of the system. By validating parameters, the server protects the SonarQube API from malformed requests and ensures that AI models are providing valid input. This is particularly important in a client-server architecture where the client (AI model) may not always be perfectly reliable.
This validation helps to maintain data integrity and prevents unexpected behavior, contributing to a more stable and predictable integration between AI models and SonarQube. For example, if an AI model attempts to request issues with an invalid severity level, the server will reject the request and return an error message, preventing the request from reaching the SonarQube API.
SonarQube and SonarCloud Support
The sonarqube-mcp-server
supports both SonarQube and SonarCloud, providing flexibility for users who are using either on-premise or cloud-based code quality analysis. This dual support allows AI models to interact with code quality data regardless of the underlying infrastructure. The server automatically adapts to the specific API endpoints and authentication mechanisms required by each platform.
This feature simplifies the integration process for organizations that may be using a mix of SonarQube and SonarCloud instances. For example, an AI assistant could be configured to analyze code quality data from both a self-hosted SonarQube server and a SonarCloud project, providing a unified view of code quality across the entire organization. The server uses the SONARQUBE_URL
environment variable to determine which platform to connect to.