SonarQube MCP Server
by SonarSource
Connects AI agents to SonarQube Server or Cloud for code quality and security analysis, so they check their own changes before handing them over. Pointed at the Tractus-X organization eclipse-tractusx on SonarQube Cloud, they check against the same rules and Quality Gates as the Tractus-X CI as they go, so agents can validate the quality of their code.
- 17tools listed
- 15read-only
- 2write
- Transport
- stdio (default) or Streamable HTTP(S)
- Runs as
- Docker image sonarsource/sonarqube-mcp or a JAR
- Connects to
- SonarQube Cloud or SonarQube Server
- Authentication
- A SonarQube user token
- Tractus-X organization
- eclipse-tractusx on SonarQube Cloud
- License
- SONAR Source-Available License v1.0
Tools
The tools an AI agent can call through this server.
Analysis3
analyze_Readcode_ snippet Analyze a file with the SonarQube analyzers and report quality and security issues.
analyze_Readfile_ list Analyze a list of files through a running SonarQube for IDE.
Used by tractusx-testlabtoggle_Readautomatic_ analysis Turn the automatic analysis of SonarQube for IDE on or off.
Used by tractusx-testlab
Issues and Security Hotspots5
search_Readsonar_ issues_ in_ projects Search the issues in the organization's projects.
Used by tractusx-testlabchange_Writesonar_ issue_ status Accept an issue, mark it as a false positive or reopen it.
search_Readsecurity_ hotspots Search the Security Hotspots of a project.
show_Readsecurity_ hotspot Show a Security Hotspot with its rule, code context and comments.
change_Writesecurity_ hotspot_ status Review a Security Hotspot by changing its status.
Projects and Quality Gates5
search_Readmy_ sonarqube_ projects Find projects and their exact project keys.
Used by tractusx-testlablist_Readbranches List the analyzed branches of a project.
list_Readpull_ requests List the pull requests of a project.
get_Readproject_ quality_ gate_ status Get the Quality Gate status of a project.
list_Readquality_ gates List all Quality Gates.
Coverage, measures and rules4
search_Readfiles_ by_ coverage Find the files with the lowest test coverage.
get_Readfile_ coverage_ details Show the uncovered lines and branches of one file.
get_Readcomponent_ measures Get the measures of a project, directory or file.
show_Readrule Show the details of a SonarQube rule.
A selection of the tools that matter for code changes. The server has more groups (system, webhooks, portfolios, architecture and more), and toolsets or a read-only mode can limit what an agent sees.
How it works
How the Testlab agents use it
At the start of a task they turn automatic analysis off, at the end they analyze the files they changed and turn it back on. They look up project keys instead of guessing them.
Limit the tools
Toolsets and a read-only mode narrow the tools an agent sees, so it only gets what the task needs.
Connect it
Get your SonarQube Cloud token
All Tractus-X repositories are analyzed in the SonarQube Cloud organization eclipse-tractusx, so the organization is already filled in below. You only need your own token.
- Sign in to SonarQube Cloud (sonarcloud.io) with your GitHub account.
- Open your avatar in the top right, then My Account and the Security tab.
- Enter a name for the token, for example "mcp-server", pick an expiry date and select Generate Token.
- Copy the token right away, it is only shown once. Keep it out of Git: put it in an environment variable (SONAR_TOKEN) or your password manager.
The token acts as you. Reading the public Tractus-X projects works with any account; changing the status of an issue or Security Hotspot needs the matching permission on that project.
Claude Code (SonarQube Cloud)
export SONAR_TOKEN=<your-token>
claude mcp add sonarqube \
--env SONARQUBE_TOKEN=$SONAR_TOKEN \
--env SONARQUBE_ORG=eclipse-tractusx \
-- docker run --init --pull=always -i --rm -e SONARQUBE_TOKEN -e SONARQUBE_ORG sonarsource/sonarqube-mcp
MCP client configuration (SonarQube Cloud)
{
"mcpServers": {
"sonarqube": {
"command": "docker",
"args": ["run", "--init", "--pull=always", "-i", "--rm", "-e", "SONARQUBE_TOKEN", "-e", "SONARQUBE_ORG", "sonarsource/sonarqube-mcp"],
"env": {
"SONARQUBE_TOKEN": "<your-token>",
"SONARQUBE_ORG": "eclipse-tractusx"
}
}
}
}
Let agents check their own code
With the organization set to eclipse-tractusx, the agent checks against the same organization, rules and Quality Gates as the Tractus-X CI. Before it hands over a change, it looks up the project key, analyzes the files it changed, fixes what SonarQube finds and reports the Quality Gate status. Add a prompt like this to your task or to the agent instructions of your repository:
Before you finish, check your changes with the SonarQube MCP server:
1. Find the project key of this repository in the eclipse-tractusx organization.
2. Analyze every file you changed and fix the issues SonarQube reports.
3. Show the Quality Gate status of the project and any issues left in the files you touched.