SonarQube MCP Server — Claude Code MCP server: what it does
Wires SonarQube Server or Cloud into your AI assistant so the agent can read code quality and security findings and analyze a snippet in context.
claude mcp add --env SONARQUBE_TOKEN=<SONARQUBE_TOKEN> --env SONARQUBE_ORG=<SONARQUBE_ORG> --env SONARQUBE_URL=<SONARQUBE_URL> --transport stdio sonarqube-mcp-server -- docker run -i --rm -e SONARQUBE_TOKEN -e SONARQUBE_ORG -e SONARQUBE_URL docker.io/sonarsource/sonarqube-mcpWhat SonarQube MCP Server does
The server runs in a container and talks to the assistant over stdio. The image is sonarsource/sonarqube-mcp: it queries your SonarQube Server or Cloud instance and hands the agent quality and security data. Snippet analysis works inside the agent context too, without loading the whole project.
You need a SonarQube user token, plus an organization key for Cloud. Treat the token as a credential: passing it as a command-line argument leaves it in shell history, and committing it to version control is worse. Use environment variables instead. For SonarQube Cloud US the URL is https://sonarqube.us.
Startup goes through docker run, so Docker or another OCI-compatible runtime has to be on the machine. The plain sonarsource/sonarqube-mcp tag pulls the latest build each time, while a pinned tag such as sonarsource/sonarqube-mcp:1.19.0.2785 gives you a reproducible one.
What it helps with
- read project quality metrics from SonarQube without opening the web UI
- walk through vulnerabilities and code smells inside the agent chat
- check a code snippet for issues without building the whole project
- pull Quality Gate status into the assistant's context
- connect a SonarQube Cloud instance to a local workflow
Example prompts for the agent
- Show me the open vulnerabilities in the SonarQube project
- Run this snippet through SonarQube
- What is the Quality Gate status for the main project?
How to install SonarQube MCP Server
Platform CLI
claude mcp add --env SONARQUBE_TOKEN=<SONARQUBE_TOKEN> --env SONARQUBE_ORG=<SONARQUBE_ORG> --env SONARQUBE_URL=<SONARQUBE_URL> --transport stdio sonarqube-mcp-server -- docker run -i --rm -e SONARQUBE_TOKEN -e SONARQUBE_ORG -e SONARQUBE_URL docker.io/sonarsource/sonarqube-mcpReplace <…> with your own values
Platform CLI
codex mcp add sonarqube-mcp-server --env SONARQUBE_TOKEN=<SONARQUBE_TOKEN> --env SONARQUBE_ORG=<SONARQUBE_ORG> --env SONARQUBE_URL=<SONARQUBE_URL> -- docker run -i --rm -e SONARQUBE_TOKEN -e SONARQUBE_ORG -e SONARQUBE_URL docker.io/sonarsource/sonarqube-mcpReplace <…> with your own values
Config file
{
"mcpServers": {
"sonarqube-mcp-server": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"SONARQUBE_TOKEN",
"-e",
"SONARQUBE_ORG",
"-e",
"SONARQUBE_URL",
"docker.io/sonarsource/sonarqube-mcp"
],
"env": {
"SONARQUBE_TOKEN": "<SONARQUBE_TOKEN>",
"SONARQUBE_ORG": "<SONARQUBE_ORG>",
"SONARQUBE_URL": "<SONARQUBE_URL>"
}
}
}
}Replace <…> with your own values
Config file
{
"servers": {
"sonarqube-mcp-server": {
"type": "stdio",
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"SONARQUBE_TOKEN",
"-e",
"SONARQUBE_ORG",
"-e",
"SONARQUBE_URL",
"docker.io/sonarsource/sonarqube-mcp"
],
"env": {
"SONARQUBE_TOKEN": "<SONARQUBE_TOKEN>",
"SONARQUBE_ORG": "<SONARQUBE_ORG>",
"SONARQUBE_URL": "<SONARQUBE_URL>"
}
}
}
}Replace <…> with your own values
Platform CLI
gemini mcp add -e SONARQUBE_TOKEN=<SONARQUBE_TOKEN> -e SONARQUBE_ORG=<SONARQUBE_ORG> -e SONARQUBE_URL=<SONARQUBE_URL> sonarqube-mcp-server docker run -i --rm -e SONARQUBE_TOKEN -e SONARQUBE_ORG -e SONARQUBE_URL docker.io/sonarsource/sonarqube-mcpReplace <…> with your own values
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about SonarQube MCP Server
How do I install SonarQube MCP Server in Claude Code?
Run `claude mcp add --env SONARQUBE_TOKEN=<SONARQUBE_TOKEN> --env SONARQUBE_ORG=<SONARQUBE_ORG> --env SONARQUBE_URL=<SONARQUBE_URL> --transport stdio sonarqube-mcp-server -- docker run -i --rm -e SONARQUBE_TOKEN -e SONARQUBE_ORG -e SONARQUBE_URL docker.io/sonarsource/sonarqube-mcp`. Fill in your token, organization key and server URL.
What does SonarQube MCP Server do?
It connects an AI assistant to SonarQube Server or Cloud so the agent gets code quality and security data. It can also analyze a single code snippet in the agent context.
What do I need before running it?
A SonarQube user token, and an organization key for Cloud. It runs in a container, so Docker or another OCI-compatible runtime is required.