$git clone https://github.com/SonarSource/sonarqube-mcp-serverThe SonarQube MCP Server is a Model Context Protocol (MCP) server that enables seamless integration with SonarQube Server or Cloud for code quality and security. It also supports the analysis of code snippet directly within the agent context.
| 1 | # SonarQube MCP Server |
| 2 | |
| 3 | [](https://github.com/SonarSource/sonarqube-mcp-server/actions/workflows/build.yml) |
| 4 | [](https://sonarcloud.io/summary/new_code?id=SonarSource_sonarqube-mcp-server) |
| 5 | |
| 6 | The SonarQube MCP Server is a Model Context Protocol (MCP) server that enables seamless integration with SonarQube Server or Cloud for code quality and security. |
| 7 | It also supports the analysis of code snippet directly within the agent context. |
| 8 | |
| 9 | ## Quick setup |
| 10 | |
| 11 | <details> |
| 12 | <summary>Security best practices</summary> |
| 13 | |
| 14 | > 🔒 **Important**: Your SonarQube token is a sensitive credential. Follow these security practices: |
| 15 | |
| 16 | **When using CLI commands:** |
| 17 | - **Avoid hardcoding tokens** in command-line arguments – they get saved in shell history |
| 18 | - **Use environment variables** – set tokens in environment variables before running commands |
| 19 | |
| 20 | **When using configuration files:** |
| 21 | - **Never commit tokens** to version control |
| 22 | - **Use environment variable substitution** in config files when possible |
| 23 | |
| 24 | </details> |
| 25 | |
| 26 | ### 🚀 Generate your configuration |
| 27 | |
| 28 | The fastest way to get started is the **[SonarQube MCP Server Configuration Generator](https://mcp.sonarqube.com/config-generator.html)** – an interactive tool that produces a ready-to-use configuration for your preferred AI agent client. |
| 29 | |
| 30 | ### Manual setup |
| 31 | |
| 32 | If you prefer to configure things yourself, the simplest method is to use our container image at [sonarsource/sonarqube-mcp](https://hub.docker.com/r/sonarsource/sonarqube-mcp/tags). Use `sonarsource/sonarqube-mcp` for automatic updates (with `--pull=always`), or pin to a version tag (e.g., `sonarsource/sonarqube-mcp:1.19.0.2785`) for reproducible deployments. Read below if you want to build it locally. |
| 33 | |
| 34 | > **Note:** While the examples below use `docker`, any OCI-compatible container runtime works (e.g., Podman, nerdctl). Simply replace `docker` with your preferred tool. |
| 35 | |
| 36 | <details> |
| 37 | <summary>Antigravity</summary> |
| 38 | |
| 39 | SonarQube MCP Server is available in the Antigravity MCP Store. Follow these instructions: |
| 40 | |
| 41 | 1. Open the **Agent Side Panel** |
| 42 | 2. Click the three dots (**...**) at the top right and select **MCP Servers** |
| 43 | 3. Search for `SonarQube` and select **Install** |
| 44 | 4. Provide the required SonarQube User token. You can also provide your organization key for SonarQube Cloud or the SonarQube URL if connecting to SonarQube Server. |
| 45 | |
| 46 | For **SonarQube Cloud US**, set the URL to `https://sonarqube.us`. |
| 47 | |
| 48 | Alternatively, you can manually configure the server via `mcp_config.json`: |
| 49 | |
| 50 | * To connect with SonarQube Cloud: |
| 51 | |
| 52 | In the Agent Side Panel, click the three dots (**...**) -> **MCP Store** -> **Manage MCP Servers** -> **View raw config**, and add the following: |
| 53 | |
| 54 | ```json |
| 55 | { |
| 56 | "mcpServers": { |
| 57 | "sonarqube": { |
| 58 | "command": "docker", |
| 59 | "args": ["run", "--init", "--pull=always", "-i", "--rm", "-e", "SONARQUBE_TOKEN", "-e", "SONARQUBE_ORG", "sonarsource/sonarqube-mcp"], |
| 60 | "env": { |
| 61 | "SONARQUBE_TOKEN": "<YOUR_TOKEN>", |
| 62 | "SONARQUBE_ORG": "<YOUR_ORG>" |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | ``` |
| 68 | |
| 69 | For **SonarQube Cloud US**, manually add `"SONARQUBE_URL": "https://sonarqube.us"` to the `env` section and `"-e", "SONARQUBE_URL"` to the `args` array. |
| 70 | |
| 71 | * To connect with SonarQube Server: |
| 72 | |
| 73 | ```json |
| 74 | { |
| 75 | "mcpServers": { |
| 76 | "sonarqube": { |
| 77 | "command": "docker", |
| 78 | "args": ["run", "--init", "--pull=always", "-i", "--rm", "-e", "SONARQUBE_TOKEN", "-e", "SONARQUBE_URL", "sonarsource/sonarqube-mcp"], |
| 79 | "env": { |
| 80 | "SONARQUBE_TOKEN": "<YOUR_USER_TOKEN>", |
| 81 | "SONARQUBE_URL": "<YOUR_SERVER_URL>" |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | ``` |
| 87 | |
| 88 | </details> |
| 89 | |
| 90 | <details> |
| 91 | <summary>Claude Code</summary> |
| 92 | |
| 93 | * To connect with SonarQube Cloud: |
| 94 | |
| 95 | ```bash |
| 96 | claude mcp add sonarqube \ |
| 97 | --env SONARQUBE_TOKEN=$SONAR_TOKEN \ |
| 98 | --env SONARQUBE_ORG= |