SonarQube
STDIOOfficialMCP server integrating SonarQube for code quality analysis and security scanning in development workflows
MCP server integrating SonarQube for code quality analysis and security scanning in development workflows
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. It also supports the analysis of code snippet directly within the agent context.
The simplest method is to rely on our Docker image hosted at mcp/sonarqube. Read below if you want to build it locally.
claude mcp add sonarqube --env SONARQUBE_TOKEN=<token> --env SONARQUBE_ORG=<org> -- docker run -i --name sonarqube-mcp-server --rm -e SONARQUBE_TOKEN -e SONARQUBE_ORG mcp/sonarqube
claude mcp add sonarqube --env SONARQUBE_TOKEN=<token> --env SONARQUBE_URL=<url> -- docker run -i --name sonarqube-mcp-server --rm -e SONARQUBE_TOKEN -e SONARQUBE_URL mcp/sonarqube
In ~/.codex/config.toml, add the following configuration:
[mcp_servers.sonarqube]
command = "docker"
args = ["run", "--name", "sonarqube-mcp-server", "--rm", "-i", "-e", "SONARQUBE_TOKEN", "-e", "SONARQUBE_ORG", "mcp/sonarqube"]
env = { "SONARQUBE_TOKEN" = "<YOUR_USER_TOKEN>", "SONARQUBE_ORG" = "<YOUR_ORG>" }
[mcp_servers.sonarqube]
command = "docker"
args = ["run", "--name", "sonarqube-mcp-server", "--rm", "-i", "-e", "SONARQUBE_TOKEN", "-e", "SONARQUBE_URL", "mcp/sonarqube"]
env = { "SONARQUBE_TOKEN" = "<YOUR_TOKEN>", "SONARQUBE_URL" = "<YOUR_SERVER_URL>" }
You can install our MCP server extension by using the following command:
gemini extensions install https://github.com/SonarSource/sonarqube-mcp-server
You will need to set the required environment variables before starting Gemini:
SONARQUBE_TOKEN="<token>"
SONARQUBE_ORG="<org>" // For SonarQube Cloud, empty otherwise
SONARQUBE_URL="<url>" // For SonarQube Server, empty otherwise
Once installed, the extension will be installed under <home>/.gemini/extensions/sonarqube-mcp-server/gemini-extension.json.
After starting Copilot CLI, run the following command to add the SonarQube MCP server:
/mcp add
You will have to provide different information about the MCP server, you can use tab to navigate between fields.
Server Name: sonarqube
Server Type: Local (Press 1)
Command: docker
Arguments: run, --name, sonarqube-mcp-server, --rm, -i, -e, SONARQUBE_TOKEN, -e, SONARQUBE_ORG, mcp/sonarqube
Environment Variables: SONARQUBE_TOKEN=<YOUR_TOKEN>,SONARQUBE_ORG=<YOUR_ORG>
Tools: *
Server Name: sonarqube
Server Type: Local (Press 1)
Command: docker
Arguments: run, --name, sonarqube-mcp-server, --rm, -i, -e, SONARQUBE_TOKEN, -e, SONARQUBE_ORG, mcp/sonarqube
Environment Variables: SONARQUBE_TOKEN=<YOUR_USER_TOKEN>,SONARQUBE_URL=<YOUR_SERVER_URL>
Tools: *
The configuration file is located at ~/.copilot/mcp-config.json.
GitHub Copilot coding agent can leverage the SonarQube MCP server directly in your CI/CD.
To add the secrets to your Copilot environment, follow the Copilot documentation. Only secrets with names prefixed with COPILOT_MCP_ will be available to your MCP configuration.
In your GitHub repository, navigate under Settings -> Code & automation -> Copilot -> Coding agent, and add the following configuration in the MCP configuration section:
{
  "mcpServers": {
    "sonarqube": {
      "type": "local",
      "command": "docker",
      "args": [
        "run",
        "--name",
        "sonarqube-mcp-server",
        "--rm",
        "-i",
        "-e",
        "SONARQUBE_TOKEN=$SONAR_TOKEN",
        "-e",
        "SONARQUBE_ORG=$SONAR_ORG",
        "mcp/sonarqube"
      ],
      "env": {
        "SONAR_TOKEN": "COPILOT_MCP_SONARQUBE_TOKEN",
        "SONAR_ORG": "COPILOT_MCP_SONARQUBE_ORG"
      },
      "tools": ["*"]
    }
  }
}
{
  "mcpServers": {
    "sonarqube": {
      "type": "local",
      "command": "docker",
      "args": [
        "run",
        "--name",
        "sonarqube-mcp-server",
        "--rm",
        "-i",
        "-e",
        "SONARQUBE_TOKEN=$SONAR_TOKEN",
        "-e",
        "SONARQUBE_URL=$SONAR_URL",
        "mcp/sonarqube"
      ],
      "env": {
        "SONAR_TOKEN": "COPILOT_MCP_SONARQUBE_USER_TOKEN",
        "SONAR_URL": "COPILOT_MCP_SONARQUBE_URL"
      },
      "tools": ["*"]
    }
  }
}
Create a .kiro/settings/mcp.json file in your workspace directory (or edit if it already exists), add the following configuration:
{
  "mcpServers": {
    "sonarqube": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--name",
        "sonarqube-mcp-server",
        "--rm",
        "-e", 
        "SONARQUBE_TOKEN",
        "-e",
        "SONARQUBE_ORG",
        "mcp/sonarqube"
      ],
      "env": {
        "SONARQUBE_TOKEN": "<YOUR_TOKEN>",
        "SONARQUBE_ORG": "<YOUR_ORG>"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}
{
  "mcpServers": {
    "sonarqube": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--name",
        "sonarqube-mcp-server",
        "--rm",
        "-e", 
        "SONARQUBE_TOKEN",
        "-e",
        "SONARQUBE_URL",
        "mcp/sonarqube"
      ],
      "env": {
        "SONARQUBE_TOKEN": "<YOUR_USER_TOKEN>",
        "SONARQUBE_URL": "<YOUR_SERVER_URL>"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}
SonarQube MCP Server is available as a Windsurf plugin. Follow these instructions:
Plugins button at the top right of the Cascade viewsonarqube on the Plugin storeInstallNavigate to the Extensions view in Zed and search for SonarQube MCP Server. When installing the extension, you will be prompted to provide the necessary environment variables:
{
  "sonarqube_token": "YOUR_SONARQUBE_TOKEN",
  "sonarqube_org": "SONARQUBE_ORGANIZATION_KEY",
  "docker_path": "DOCKER_PATH"
}
{
  "sonarqube_token": "YOUR_SONARQUBE_USER_TOKEN",
  "sonarqube_url": "YOUR_SONARQUBE_SERVER_URL",
  "docker_path": "DOCKER_PATH"
}
The docker_path is the path to a docker executable. Examples:
Linux/macOS: /usr/bin/docker or /usr/local/bin/docker
Windows: C:\Program Files\Docker\Docker\resources\bin\docker.exe
You can manually install the SonarQube MCP server by copying the following snippet in the MCP servers configuration file:
{ "sonarqube": { "command": "docker", "args": [ "run", "-i", "--name", "sonarqube-mcp-server", "--rm", "-e", "SONARQUBE_TOKEN", "-e", "SONARQUBE_ORG", "mcp/sonarqube" ], "env": { "SONARQUBE_TOKEN": "<token>", "SONARQUBE_ORG": "<org>" } } }
{ "sonarqube": { "command": "docker", "args": [ "run", "-i", "--name", "sonarqube-mcp-server", "--rm", "-e", "SONARQUBE_TOKEN", "-e", "SONARQUBE_URL", "mcp/sonarqube" ], "env": { "SONARQUBE_TOKEN": "<token>", "SONARQUBE_URL": "<url>" } } }
The SonarQube MCP Server can integrate with SonarQube for IDE to further enhance your development workflow, providing better code analysis and insights directly within your IDE.
When using SonarQube for IDE, the SONARQUBE_IDE_PORT environment variable should be set with the correct port number. SonarQube for VS Code includes a Quick Install button, which automatically sets the correct port configuration.
For example, with SonarQube Cloud:
{ "sonarqube": { "command": "docker", "args": [ "run", "-i", "--name", "sonarqube-mcp-server", "--rm", "-e", "SONARQUBE_TOKEN", "-e", "SONARQUBE_ORG", "-e", "SONARQUBE_IDE_PORT", "mcp/sonarqube" ], "env": { "SONARQUBE_TOKEN": "<token>", "SONARQUBE_ORG": "<org>", "SONARQUBE_IDE_PORT": "<64120-64130>" } } }
When running the MCP server in Docker on Linux, the container cannot access the SonarQube for IDE embedded server running on localhost. To allow the container to connect to the SonarQube for IDE server, add the
--network=hostoption to your Docker run command.
SonarQube MCP Server requires a Java Development Kit (JDK) version 21 or later to build.
Run the following Gradle command to clean the project and build the application:
./gradlew clean build -x test
The JAR file will be created in build/libs/.
You will then need to manually copy and paste the MCP configuration, as follows:
{ "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>" } } }
{ "sonarqube": { "command": "java", "args": [ "-jar", "<path_to_sonarqube_mcp_server_jar>" ], "env": { "STORAGE_PATH": "<path_to_your_mcp_storage>", "SONARQUBE_TOKEN": "<token>", "SONARQUBE_URL": "<url>" } } }
Depending on your environment, you should provide specific environment variables.
You should add the following variable when running the MCP Server:
| Environment variable | Description | 
|---|---|
STORAGE_PATH | Mandatory absolute path to a writable directory where SonarQube MCP Server will store its files (e.g., for creation, updates, and persistence), it is automatically provided when using Docker | 
SONARQUBE_IDE_PORT | Optional port number between 64120 and 64130 used to connect SonarQube MCP Server with SonarQube for IDE. | 
To enable full functionality, the following environment variables must be set before starting the server:
| Environment variable | Description | 
|---|---|
SONARQUBE_TOKEN | Your SonarQube Cloud token | 
SONARQUBE_ORG | Your SonarQube Cloud organization key | 
| Environment variable | Description | 
|---|---|
SONARQUBE_TOKEN | Your SonarQube Server USER token | 
SONARQUBE_URL | Your SonarQube Server URL | 
⚠️ Connection to SonarQube Server requires a token of type USER and will not function properly if project tokens or global tokens are used.
The SonarQube MCP Server supports three transport modes:
Default mode for single-user setups via command-line tools or MCP clients.
Example - Docker with SonarQube Cloud:
{ "mcpServers": { "sonarqube": { "command": "docker", "args": ["run", "--name", "sonarqube-mcp-server", "-i", "--rm", "-e", "SONARQUBE_TOKEN", "-e", "SONARQUBE_ORG", "mcp/sonarqube"], "env": { "SONARQUBE_TOKEN": "<your-token>", "SONARQUBE_ORG": "<your-org>" } } } }
Enables multiple clients to connect to a shared server. Each client provides their own token.
| Environment variable | Description | Default | 
|---|---|---|
SONARQUBE_TRANSPORT | Set to http to enable HTTP transport | Not set (stdio) | 
SONARQUBE_HTTP_PORT | Port number (1024-65535) | 8080 | 
SONARQUBE_HTTP_HOST | Host to bind (127.0.0.1 for localhost, 0.0.0.0 for Docker) | 127.0.0.1 | 
Example - Docker with SonarQube Cloud:
docker run --name sonarqube-mcp-server -p 8080:8080 \ -e SONARQUBE_TRANSPORT=http \ -e SONARQUBE_HTTP_HOST=0.0.0.0 \ -e SONARQUBE_TOKEN="<init-token>" \ -e SONARQUBE_ORG="<your-org>" \ mcp/sonarqube
Client Configuration:
{ "mcpServers": { "sonarqube-http": { "url": "http://127.0.0.1:8080/mcp", "headers": { "SONARQUBE_TOKEN": "<your-token>" } } } }
Note: In HTTP(S) mode, each client sends their own token via the SONARQUBE_TOKEN header. The server's SONARQUBE_TOKEN is only used for initialization.
Same as HTTP but with TLS encryption. Requires SSL certificates.
| Environment variable | Description | Default | 
|---|---|---|
SONARQUBE_TRANSPORT | Set to https to enable HTTPS transport | Not set (stdio) | 
SONARQUBE_HTTP_PORT | Port number (typically 8443 for HTTPS) | 8080 | 
SONARQUBE_HTTP_HOST | Host to bind (127.0.0.1 for localhost, 0.0.0.0 for Docker) | 127.0.0.1 | 
SSL Certificate Configuration (Optional):
| Environment variable | Description | Default | 
|---|---|---|
SONARQUBE_HTTPS_KEYSTORE_PATH | Path to keystore file (.p12 or .jks) | /etc/ssl/mcp/keystore.p12 | 
SONARQUBE_HTTPS_KEYSTORE_PASSWORD | Keystore password | sonarlint | 
SONARQUBE_HTTPS_KEYSTORE_TYPE | Keystore type (PKCS12 or JKS) | PKCS12 | 
Example - Docker with SonarQube Cloud:
docker run --name sonarqube-mcp-server -p 8443:8443 \ -v $(pwd)/keystore.p12:/etc/ssl/mcp/keystore.p12:ro \ -e SONARQUBE_TRANSPORT=https \ -e SONARQUBE_HTTP_HOST=0.0.0.0 \ -e SONARQUBE_HTTP_PORT=8443 \ -e SONARQUBE_TOKEN="<init-token>" \ -e SONARQUBE_ORG="<your-org>" \ mcp/sonarqube
Client Configuration:
{ "mcpServers": { "sonarqube-https": { "url": "https://127.0.0.1:8443/mcp", "headers": { "SONARQUBE_TOKEN": "<your-token>" } } } }
Note: For local development, use HTTP instead of HTTPS to avoid certificate issues. For production deployments with proper SSL certificates from a trusted CA, use HTTPS.
If your SonarQube Server uses a self-signed certificate or a certificate from a private Certificate Authority (CA), you can add custom certificates to the Docker container that will automatically be installed.
Mount a directory containing your certificates when running the container:
docker run -i --name sonarqube-mcp-server --rm \ -v /path/to/your/certificates/:/usr/local/share/ca-certificates/:ro \ -e SONARQUBE_TOKEN="<token>" \ -e SONARQUBE_URL="<url>" \ mcp/sonarqube
The container supports the following certificate formats:
.crt files (PEM or DER encoded).pem files (PEM encoded)When using custom certificates, you can modify your MCP configuration to mount the certificates:
{ "sonarqube": { "command": "docker", "args": [ "run", "-i", "--name", "sonarqube-mcp-server", "--rm", "-v", "/path/to/your/certificates/:/usr/local/share/ca-certificates/:ro", "-e", "SONARQUBE_TOKEN", "-e", "SONARQUBE_URL", "mcp/sonarqube" ], "env": { "SONARQUBE_TOKEN": "<token>", "SONARQUBE_URL": "<url>" } } }
The SonarQube MCP Server supports HTTP proxies through standard Java proxy system properties.
You can configure proxy settings using Java system properties. These can be set as environment variables or passed as JVM arguments.
Common Proxy Properties:
| Property | Description | Example | 
|---|---|---|
http.proxyHost | HTTP proxy hostname | proxy.example.com | 
http.proxyPort | HTTP proxy port | 8080 | 
https.proxyHost | HTTPS proxy hostname | proxy.example.com | 
https.proxyPort | HTTPS proxy port | 8443 | 
http.nonProxyHosts | Hosts that bypass the proxy (pipe-separated) | localhost|127.0.0.1|*.internal.com | 
If your proxy requires authentication, the SonarQube MCP Server uses Java's standard authentication mechanism. You can set up proxy credentials using Java system properties:
| Property | Description | Example | 
|---|---|---|
http.proxyUser | HTTP proxy username | myuser | 
http.proxyPassword | HTTP proxy password | mypassword | 
https.proxyUser | HTTPS proxy username | myuser | 
https.proxyPassword | HTTPS proxy password | mypassword | 
codeSnippet - Code snippet or full file content - Required Stringlanguage - Optional language of the code snippet - StringWhen integration with SonarQube for IDE is enabled:
analyze_file_list - Analyze files in the current working directory using SonarQube for IDE. This tool connects to a running SonarQube for IDE instance to perform code quality analysis on a list of files.
file_absolute_paths - List of absolute file paths to analyze - Required String[]toggle_automatic_analysis - Enable or disable SonarQube for IDE automatic analysis. When enabled, SonarQube for IDE will automatically analyze files as they are modified in the working directory. When disabled, automatic analysis is turned off.
enabled - Enable or disable the automatic analysis - Required BooleanNote: Dependency risks are only available when connecting to SonarQube Server 2025.4 Enterprise or higher with SonarQube Advanced Security enabled.
projectKey - Project key - StringbranchKey - Optional branch key - StringpullRequestKey - Optional pull request key - StringNote: Enterprises are only available when connecting to SonarQube Cloud.
enterpriseKey - Optional enterprise key to filter results - Stringchange_sonar_issue_status - Change the status of a SonarQube issue to "accept", "falsepositive" or to "reopen" an issue.
key - Issue key - Required Stringstatus - New issue's status - Required Enum {"accept", "falsepositive", "reopen"}search_sonar_issues_in_projects - Search for SonarQube issues in my organization's projects.
projects - Optional list of Sonar projects - String[]pullRequestId - Optional Pull Request's identifier - Stringseverities - Optional list of severities to filter by. Possible values: INFO, LOW, MEDIUM, HIGH, BLOCKER - String[]p - Optional page number (default: 1) - Integerps - Optional page size. Must be greater than 0 and less than or equal to 500 (default: 100) - Integerq - Optional pattern to match language keys/names against - Stringcomponent - Optional component key to get measures for - Stringbranch - Optional branch to analyze for measures - StringmetricKeys - Optional metric keys to retrieve (e.g. ncloc, complexity, violations, coverage) - String[]pullRequest - Optional pull request identifier to analyze for measures - Stringp - Optional page number (default: 1) - Integerps - Optional page size. Must be greater than 0 and less than or equal to 500 (default: 100) - Integerlist_portfolios - List enterprise portfolios available in SonarQube with filtering and pagination options.
For SonarQube Server:
q - Optional search query to filter portfolios by name or key - Stringfavorite - If true, only returns favorite portfolios - BooleanpageIndex - Optional 1-based page number (default: 1) - IntegerpageSize - Optional page size, max 500 (default: 100) - IntegerFor SonarQube Cloud:
enterpriseId - Enterprise uuid. Can be omitted only if 'favorite' parameter is supplied with value true - Stringq - Optional search query to filter portfolios by name - Stringfavorite - Required to be true if 'enterpriseId' parameter is omitted. If true, only returns portfolios favorited by the logged-in user. Cannot be true when 'draft' is true - Booleandraft - If true, only returns drafts created by the logged-in user. Cannot be true when 'favorite' is true - BooleanpageIndex - Optional index of the page to fetch (default: 1) - IntegerpageSize - Optional size of the page to fetch (default: 50) - Integerpage - Optional page number - Stringget_project_quality_gate_status - Get the Quality Gate Status for the SonarQube project.
analysisId - Optional analysis ID - Stringbranch - Optional branch key - StringprojectId - Optional project ID - StringprojectKey - Optional project key - StringpullRequest - Optional pull request ID - Stringlist_quality_gates - List all quality gates in my SonarQube.
list_rule_repositories - List rule repositories available in SonarQube.
language - Optional language key - Stringq - Optional search query - Stringshow_rule - Shows detailed information about a SonarQube rule.
key - Rule key - Required Stringget_raw_source - Get source code as raw text from SonarQube. Require 'See Source Code' permission on file.
key - File key - Required Stringbranch - Optional branch key - StringpullRequest - Optional pull request id - Stringget_scm_info - Get SCM information of SonarQube source files. Require See Source Code permission on file's project.
key - File key - Required Stringcommits_by_line - Group lines by SCM commit if value is false, else display commits for each line - Stringfrom - First line to return. Starts at 1 - Numberto - Last line to return (inclusive) - NumberNote: System tools are only available when connecting to SonarQube Server.
get_system_health - Get the health status of SonarQube Server instance. Returns GREEN (fully operational), YELLOW (usable but needs attention), or RED (not operational).
get_system_info - Get detailed information about SonarQube Server system configuration including JVM state, database, search indexes, and settings. Requires 'Administer' permissions.
get_system_logs - Get SonarQube Server system logs in plain-text format. Requires system administration permission.
name - Optional name of the logs to get. Possible values: access, app, ce, deprecation, es, web. Default: app - Stringping_system - Ping the SonarQube Server system to check if it's alive. Returns 'pong' as plain text.
get_system_status - Get state information about SonarQube Server. Returns status (STARTING, UP, DOWN, RESTARTING, DB_MIGRATION_NEEDED, DB_MIGRATION_RUNNING), version, and id.
create_webhook - Create a new webhook for the SonarQube organization or project. Requires 'Administer' permission on the specified project, or global 'Administer' permission.
name - Webhook name - Required Stringurl - Webhook URL - Required StringprojectKey - Optional project key for project-specific webhook - Stringsecret - Optional webhook secret for securing the webhook payload - Stringlist_webhooks - List all webhooks for the SonarQube organization or project. Requires 'Administer' permission on the specified project, or global 'Administer' permission.
projectKey - Optional project key to list project-specific webhooks - StringApplications logs will be written to the STORAGE_PATH/logs/mcp.log file.
This server collects anonymous usage data and sends it to SonarSource to help improve the product. No source code or IP address is collected, and SonarSource does not share the data with anyone else. Collection of telemetry can be disabled with the following system property or environment variable: TELEMETRY_DISABLED=true. Click here to see a sample of the data that are collected.
Copyright 2025 SonarSource.
Licensed under the SONAR Source-Available License v1.0. Using the SonarQube MCP Server in compliance with this documentation is a Non-Competitive Purpose and so is allowed under the SSAL.
Your use of SonarQube via MCP is governed by the SonarQube Cloud Terms of Service or SonarQube Server Terms and Conditions, including use of the Results Data solely for your internal software development purposes.