Integrate with SonarQube for IDE

Integrate the SonarQube MCP Server with SonarQube for IDE to get code analysis and insights directly in your IDE.

Integrate the SonarQube MCP Server with SonarQube for IDE to get code analysis and insights directly in your IDE.

Note: Although the examples below use docker, any OCI-compatible container runtime works (for example, Podman, nerdctl, etc). Simply replace docker with commands specific to your preferred tool.

When using SonarQube for IDE, set the SONARQUBE_IDE_PORT environment variable to the correct port number. See the list of base variables for more information.

SonarQube for VS Code includes a Quick Install button when running an agent-enabled IDE, which automatically sets the correct port configuration.

The following examples show configurations for SonarQube Cloud and SonarQube Server. Specify SONARQUBE_IDE_PORT in each.

Warning: User tokens are required when setting up connected mode or an MCP server between SonarQube Server and SonarQube for IDE. Your binding won't function properly if you use project tokens, global tokens, or scoped organization tokens during setup.

SonarQube Cloud

{
  "sonarqube": {
    "command": "docker",
    "args": [
      "run",
      "-i",
      "--rm",
      "--init",
      "--pull=always",
      "-e",
      "SONARQUBE_TOKEN",
      "-e",
      "SONARQUBE_ORG",
      "-e",
      "SONARQUBE_IDE_PORT",
      "mcp/sonarqube"
    ],
    "env": {
      "SONARQUBE_TOKEN": "<YourSonarQubeUserToken>",
      "SONARQUBE_ORG": "<YourSonarQubeOrganization>",
      "SONARQUBE_IDE_PORT": "<Your-IDE-Port>"
    }
  }
}

Note: SONARQUBE_URL should be defined as https://sonarqube.us each time you use a SonarQube Cloud configuration (SONARQUBE_TOKEN + SONARQUBE_ORG) and want to connect to a US-region instance. See the Connecting to SonarQube Cloud in the US region section for details.

SonarQube Server

Use this code sample when using Docker to configure your MCP server for integrating with SonarQube Server or SonarQube Community Build.

Note: On Linux, containers can't access the SonarQube for IDE embedded server on localhost. Add the --network=host option to your container run command to fix this.

MCP Server setup in your IDE

For detailed quickstart instructions to set up the SonarQube MCP Server with the most popular AI agents, see the IDE/CLI quickstart guides.

Last updated

Was this helpful?