Set up SonarQube MCP in Claude Code
Code quality analysis, security hotspot detection, and vulnerability tracking from SonarQube Cloud or Server. Official SonarSource implementation.
1
Locate the config file
Claude Code reads MCP server configuration from the following file:
~/.claude.jsonCreate this file if it does not already exist.
2
Add the configuration
You can configure SonarQube MCP using the CLI command or by editing the config file directly.
Option A: CLI command
bash
claude mcp add sonarqube-mcp -e SONARQUBE_TOKEN=YOUR_SONARQUBE_TOKEN -e SONARQUBE_URL=YOUR_SONARQUBE_URL -e SONARQUBE_ORG=YOUR_SONARQUBE_ORG -- docker run --init --pull=always -i --rm mcp/sonarqubeOption B: Config file
json
{
"mcpServers": {
"sonarqube-mcp": {
"command": "docker",
"args": [
"run",
"--init",
"--pull=always",
"-i",
"--rm",
"mcp/sonarqube"
],
"env": {
"SONARQUBE_TOKEN": "YOUR_SONARQUBE_TOKEN",
"SONARQUBE_URL": "YOUR_SONARQUBE_URL",
"SONARQUBE_ORG": "YOUR_SONARQUBE_ORG"
}
}
}
}3
Set up environment variables
SonarQube MCP requires the following environment variables:
SONARQUBE_TOKENRequiredSonarQube authentication token
SONARQUBE_URLOptionalSonarQube Server URL (omit for SonarQube Cloud)
SONARQUBE_ORGOptionalSonarQube Cloud organization key
4
Verify it works
Restart Claude Code. SonarQube MCP should appear in your MCP server list with 13 tools available.
This server adds approximately 6,500 tokens to your context window for tool definitions.