A Model Context Protocol (MCP) server that integrates with SonarQube to provide AI assistants with access to code quality metrics, issues, and analysis results.
The SonarQube MCP Server enables AI assistants to interact with SonarQube's code quality analysis capabilities through the Model Context Protocol. This integration allows AI assistants to:
- Retrieve code metrics and analysis results
- Access and filter issues
- Check quality status
- Analyze project quality over time
- List all SonarQube projects with pagination support
- Get available metrics with descriptions and domains
- Get detailed issue information from SonarQube projects with extensive filtering options
- Access component measures with current values and historical trends
- Monitor SonarQube system health and status
- Support for both SonarQube and SonarCloud
- Comprehensive parameter validation using Zod schemas
- Full TypeScript support
-
Edit
claude_desktop_config.json
:- Open Claude Desktop
- Go to
Settings
->Developer
->Edit Config
- Add the one of the configurations below to the
mcpServers
section
-
Restart Claude Desktop to apply the changes
{
"mcpServers": {
"sonarqube": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"SONARQUBE_URL",
"-e",
"SONARQUBE_TOKEN",
"-e",
"SONARQUBE_ORGANIZATION",
"sapientpants/sonarqube-mcp-server"
],
"env": {
"SONARQUBE_URL": "https://sonarqube.example.com",
"SONARQUBE_TOKEN": "your-sonarqube-token",
"SONARQUBE_ORGANIZATION": "your-organization-key (optional)"
}
}
}
}
{
"mcpServers": {
"sonarqube": {
"command": "npx",
"args": [
"-y",
"sonarqube-mcp-server@latest"
],
"env": {
"SONARQUBE_URL": "https://sonarqube.example.com",
"SONARQUBE_TOKEN": "your-sonarqube-token",
"SONARQUBE_ORGANIZATION": "your-organization-key (optional)"
}
}
}
}
The SonarQube MCP Server provides the following tools:
-
projects
: List all SonarQube projects- Parameters:
page
(optional) - Page number for results paginationpage_size
(optional) - Number of items per page
- Parameters:
-
metrics
: Get available metrics from SonarQube- Parameters:
page
(optional) - Page number for results paginationpage_size
(optional) - Number of items per page
- Parameters:
-
issues
: Get issues from a SonarQube project- Parameters:
project_key
(required) - The unique identifier for the SonarQube projectbranch
(optional) - Filter issues for a specific branchpull_request
(optional) - Filter issues for a specific pull requesthotspots
(optional) - Filter for security hotspotsseverity
(optional) - Filter issues by severity (INFO, MINOR, MAJOR, CRITICAL, BLOCKER)page
(optional) - Page number for results paginationpage_size
(optional) - Number of items per pagestatuses
(optional) - Filter issues by status (array of: OPEN, CONFIRMED, REOPENED, RESOLVED, CLOSED, TO_REVIEW, IN_REVIEW, REVIEWED)resolutions
(optional) - Filter issues by resolution (array of: FALSE-POSITIVE, WONTFIX, FIXED, REMOVED)resolved
(optional) - Whether to return only resolved issues (true) or unresolved issues (false)types
(optional) - Filter issues by type (array of: CODE_SMELL, BUG, VULNERABILITY, SECURITY_HOTSPOT)rules
(optional) - Array of rule keys to filter issuestags
(optional) - Array of tags to filter issuescreated_after
(optional) - Return issues created after the given date (format: YYYY-MM-DD)created_before
(optional) - Return issues created before the given date (format: YYYY-MM-DD)created_at
(optional) - Return issues created on the given datecreated_in_last
(optional) - Return issues created during a time span before the current time (e.g., "1d" for issues created in the last day)assignees
(optional) - Array of assignee login names to filter issuesauthors
(optional) - Array of author login names to filter issuescwe
(optional) - Array of CWE identifiers to filter vulnerability issueslanguages
(optional) - Array of languages to filter issuesowasp_top10
(optional) - Array of OWASP Top 10 categories to filter issuessans_top25
(optional) - Array of SANS Top 25 categories to filter issuessonarsource_security
(optional) - Array of SonarSource security categories to filter issueson_component_only
(optional) - Return only issues at the specified component level (true) or issues from the component's subtree (false)facets
(optional) - Array of facets to return along with the issuessince_leak_period
(optional) - Return only issues created since the leak periodin_new_code_period
(optional) - Return only issues created in the new code period
- Parameters:
-
measures_component
: Get measures for a specific component- Parameters:
component
(required) - Component keymetric_keys
(required) - Comma-separated list or array of metric keysadditional_fields
(optional) - Additional fields to return in the responsebranch
(optional) - Branch namepull_request
(optional) - Pull request keyperiod
(optional) - Period index
- Parameters:
-
measures_components
: Get measures for multiple components- Parameters:
component_keys
(required) - Comma-separated list or array of component keysmetric_keys
(required) - Comma-separated list or array of metric keysadditional_fields
(optional) - Additional fields to return in the responsebranch
(optional) - Branch namepull_request
(optional) - Pull request keyperiod
(optional) - Period indexpage
(optional) - Page number for results paginationpage_size
(optional) - Number of items per page
- Parameters:
-
measures_history
: Get measures history for a component- Parameters:
component
(required) - Component keymetrics
(required) - Comma-separated list or array of metric keysfrom
(optional) - Start date (format: YYYY-MM-DD)to
(optional) - End date (format: YYYY-MM-DD)branch
(optional) - Branch namepull_request
(optional) - Pull request keypage
(optional) - Page number for results paginationpage_size
(optional) - Number of items per page
- Parameters:
-
system_health
: Get the health status of the SonarQube instance- No parameters required
-
system_status
: Get the status of the SonarQube instance- No parameters required
-
system_ping
: Ping the SonarQube instance to check if it is up- No parameters required
SONARQUBE_URL
- URL of your SonarQube instance (default: https://next.sonarqube.com/sonarqube)SONARQUBE_TOKEN
- Authentication token for SonarQube API accessSONARQUBE_ORGANIZATION
- (Optional) Organization key for SonarQube Cloud
- Clone the repository:
git clone https://github.com/sapientpants/sonarqube-mcp-server.git
cd sonarqube-mcp-server
- Install dependencies:
pnpm install
- Build the project:
pnpm run build
- Configure Claude Desktop
{
"mcpServers": {
"sonarqube": {
"command": "node",
"args": [
"/path/to/sonarqube-mcp-server/dist/index.js"
],
"env": {
"SONARQUBE_TOKEN": "your-sonarqube-token"
}
}
}
}
- Node.js 20 or higher
- pnpm 10.7.0 or higher
- Docker (for container builds)
pnpm run build
- Build the TypeScript codepnpm run start
- Start the serverpnpm run dev
- Start the server in development modepnpm run test
- Run testspnpm run lint
- Run ESLintpnpm run format
- Format code with Prettier
MIT