The SonarQube MCP Server provides seamless integration with SonarQube Server or Cloud through the Model Context Protocol (MCP). It enables direct code snippet analysis within the agent context, allowing you to access SonarQube's powerful code quality features from your development environment.
The simplest installation method is to use the official Docker image:
docker run -i --rm -e SONARQUBE_TOKEN="<your-token>" -e SONARQUBE_ORG="<your-org>" mcp/sonarqube
For SonarQube Server connection:
docker run -i --rm -e SONARQUBE_TOKEN="<your-token>" -e SONARQUBE_URL="<your-server-url>" mcp/sonarqube
You can manually install the SonarQube MCP server by adding configuration to your MCP servers configuration file:
For SonarQube Cloud:
{
"sonarqube": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"SONARQUBE_TOKEN",
"-e",
"SONARQUBE_ORG",
"mcp/sonarqube"
],
"env": {
"SONARQUBE_TOKEN": "<token>",
"SONARQUBE_ORG": "<org>"
}
}
}
For SonarQube Server:
{
"sonarqube": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"SONARQUBE_TOKEN",
"-e",
"SONARQUBE_URL",
"mcp/sonarqube"
],
"env": {
"SONARQUBE_TOKEN": "<token>",
"SONARQUBE_URL": "<url>"
}
}
}
If you prefer to build from source:
./gradlew clean build -x test
{
"sonarqube": {
"command": "java",
"args": [
"-jar",
"<path_to_sonarqube_mcp_server_jar>"
],
"env": {
"STORAGE_PATH": "<path_to_your_mcp_storage>",
"SONARQUBE_TOKEN": "<token>",
"SONARQUBE_ORG": "<org>"
}
}
}
Variable | Description |
---|---|
STORAGE_PATH | An absolute path to a writable directory where SonarQube MCP Server will store its files |
Variable | Description |
---|---|
SONARQUBE_TOKEN | Your SonarQube Cloud token |
SONARQUBE_ORG | Your SonarQube Cloud organization key |
Variable | Description |
---|---|
SONARQUBE_TOKEN | Your SonarQube Server USER token |
SONARQUBE_URL | Your SonarQube Server URL |
change_sonar_issue_status: Change the status of a SonarQube issue
search_sonar_issues_in_projects: Search for SonarQube issues in your organization's projects
get_project_quality_gate_status: Get the Quality Gate Status for a project
list_quality_gates: List all quality gates in the organization
list_rule_repositories: List rule repositories available in SonarQube
show_rule: Shows detailed information about a SonarQube rule
Application logs are written to the STORAGE_PATH/logs/mcp.log
file. Check these logs if you encounter any issues with the server.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "sonarqube" '{"command":"docker","args":["run","-i","--rm","-e","SONARQUBE_TOKEN","-e","SONARQUBE_ORG","mcp/sonarqube"],"env":{"SONARQUBE_TOKEN":"<token>","SONARQUBE_ORG":"<org>"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"sonarqube": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"SONARQUBE_TOKEN",
"-e",
"SONARQUBE_ORG",
"mcp/sonarqube"
],
"env": {
"SONARQUBE_TOKEN": "<token>",
"SONARQUBE_ORG": "<org>"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"sonarqube": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"SONARQUBE_TOKEN",
"-e",
"SONARQUBE_ORG",
"mcp/sonarqube"
],
"env": {
"SONARQUBE_TOKEN": "<token>",
"SONARQUBE_ORG": "<org>"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect