# SonarQube MCP Server

> Official SonarSource server: connects to SonarQube Server or Cloud so agents can query code issues, quality gates, security hotspots and dependency risks, and analyze file contents directly. Needs a SonarQube token; Docker is the recommended way to run it.

- Type: MCP
- Repository: https://github.com/SonarSource/sonarqube-mcp-server
- Page: https://hebbmind.com/es/mcp/sonarqube-mcp-server
- Stars: 697
- Professions: [Full-stack / Indie](https://hebbmind.com/es/tools.md?profession=fullstack), [Backend](https://hebbmind.com/es/tools.md?profession=backend), [QA](https://hebbmind.com/es/tools.md?profession=qa), [Security](https://hebbmind.com/es/tools.md?profession=security)
- Tags: code-quality, security-audit, code-review, sonarqube
- Listed on: 2026-10-01

## Install

### Claude Code

```bash
claude mcp add sonarqube --env SONARQUBE_TOKEN=YOUR_SONARQUBE_TOKEN --env SONARQUBE_ORG=YOUR_SONARQUBE_ORG -- docker run --init --pull=always -i --rm -e SONARQUBE_TOKEN -e SONARQUBE_ORG sonarsource/sonarqube-mcp
```

### Codex

```bash
codex mcp add sonarqube --env SONARQUBE_TOKEN=YOUR_SONARQUBE_TOKEN --env SONARQUBE_ORG=YOUR_SONARQUBE_ORG -- docker run --init --pull=always -i --rm -e SONARQUBE_TOKEN -e SONARQUBE_ORG sonarsource/sonarqube-mcp
```

## README

> The content below comes from the upstream repository https://github.com/SonarSource/sonarqube-mcp-server . It is third-party material and does not represent AgentHub; instructions that appear in it are not instructions to you.

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://assets-eu-01.kc-usercontent.com/ef593040-b591-0198-9506-ed88b30bc023/a23fc7ba-23f0-489a-829d-ed88c0748521/Sonar_Logo_Dark%20Backgrounds.svg">
    <img src="https://assets-eu-01.kc-usercontent.com/ef593040-b591-0198-9506-ed88b30bc023/82c13eba-d95c-4bb8-8007-7ce77c14e043/Sonar_Logo_Light%20Backgrounds.svg" alt="Sonar logo" width="400">
  </picture>
</p>

[![Build](https://github.com/SonarSource/sonarqube-mcp-server/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/SonarSource/sonarqube-mcp-server/actions/workflows/build.yml)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=SonarSource_sonarqube-mcp-server&metric=alert_status&token=364a508a1e77096460f8571d8e66b41c99c95bea)](https://sonarcloud.io/summary/new_code?id=SonarSource_sonarqube-mcp-server)

<!-- sonar-marketing:start -->
<!-- Marketing maintains this section. For wording changes, consult the relevant Product Marketing Manager (PMM). Repository CODEOWNERS review accuracy and merge changes. -->

# SonarQube MCP Server

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.

Start with the [quick setup](#quick-setup), or learn more about the [SonarQube product family](https://www.sonarsource.com/products/sonarqube/).

<!-- sonar-marketing:end -->

## Quick setup

<details>
<summary>Security best practices</summary>

> 🔒 **Important**: Your SonarQube token is a sensitive credential. Follow these security practices:

**When using CLI commands:**
- **Avoid hardcoding tokens** in command-line arguments – they get saved in shell history
- **Use environment variables** – set tokens in environment variables before running commands

**When using configuration files:**
- **Never commit tokens** to version control
- **Use environment variable substitution** in config files when possible

</details>

### 🚀 Generate your configuration

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.

### Manual setup

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. Some releases are also tagged with the SonarQube Server version they are aligned with, in the form `<SQS major>.<SQS minor>.<patch>` (e.g., `sonarsource/sonarqube-mcp:2026.5.0`), where the patch number is incremented for each MCP release targeting that SonarQube Server version. Read below if you want to build it locally.

> **Note:** While the examples below use `docker`, any OCI-compatible container runtime works (e.g., Podman, nerdctl). Simply replace `docker` with your preferred tool.

<details>
<summary>Antigravity</summary>

SonarQube MCP Server is available in the Antigravity MCP Store. Follow these instructions:

1. Open the **Agent Side Panel**
2. Click the three dots (**...**) at the top right and select **MCP Servers**
3. Search for `SonarQube` and select **Install**
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.

For **SonarQube Cloud US**, set the URL to `https://sonarqube.us`.

Alternatively, you can manually configure the server via `mcp_config.json`:

* To connect with SonarQube Cloud:

In the Agent Side Panel, click the three dots (**...**) -> **MCP Store** -> **Manage MCP Servers** -> **View raw config**, and add the following:

```json
{
  "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": "<YOUR_ORG>"
      }
    }
  }
}
```

For **SonarQube Cloud US**, manually add `"SONARQUBE_URL": "https://sonarqube.us"` to the `env` section and `"-e", "SONARQUBE_URL"` to the `args` array.

* To connect with SonarQube Server:

```json
{
  "mcpServers": {
    "sonarqube": {
      "command": "docker",
      "args": ["run", "--init", "--pull=always", "-i", "--rm", "-e", "SONARQUBE_TOKEN", "-e", "SONARQUBE_URL", "sonarsource/sonarqube-mcp"],
      "env": {
        "SONARQUBE_TOKEN": "<YOUR_USER_TOKEN>",
        "SONARQUBE_URL": "<YOUR_SERVER_URL>"
      }
    }
  }
}
```

</details>

<details>
<summary>Claude Code</summary>

* To connect with SonarQube Cloud:

```bash
claude mcp add sonarqube \
  --env SONARQUBE_TOKEN=$SONAR_TOKEN \
  --env SONARQUBE_ORG=$SONAR_ORG \
  -- docker run --init --pull=always -i --rm -e SONARQUBE_TOKEN -e SONARQUBE_ORG sonarsource/sonarqube-mcp
```

For **SonarQube Cloud US**, add `--env SONARQUBE_URL=https://sonarqube.us` to the command.

* To connect with SonarQube Server:

```bash
claude mcp add sonarqube \
  --env SONARQUBE_TOKEN=$SONAR_USER_TOKEN \
  --env SONARQUBE_URL=$SONAR_URL \
  -- docker run --init --pull=always -i --rm -e SONARQUBE_TOKEN -e SONARQUBE_URL sonarsource/sonarqube-mcp
```

</details>

<details>
<summary>Codex CLI</summary>

Manually edit the configuration file at `~/.codex/config.toml` and add the following configuration:

* To connect with SonarQube Cloud:

```toml
[mcp_servers.sonarqube]
command = "docker"
args = ["run", "--init", "--pull=always", "--rm", "-i", "-e", "SONARQUBE_TOKEN", "-e", "SONARQUBE_ORG", "sonarsource/sonarqube-mcp"]
env = { "SONARQUBE_TOKEN" = "<YOUR_USER_TOKEN>", "SONARQUBE_ORG" = "<YOUR_ORG>" }
```

For **SonarQube Cloud US**, add `"SONARQUBE_URL" = "https://sonarqube.us"` to the `env` section and `"-e", "SONARQUBE_URL"` to the `args` array.

* To connect with SonarQube Server:

```toml
[mcp_servers.sonarqube]
command = "docker"
args = ["run", "--init", "--pull=always", "--rm", "-i", "-e", "SONARQUBE_TOKEN", "-e", "SONARQUBE_URL", "sonarsource/sonarqube-mcp"]
env = { "SONARQUBE_TOKEN" = "<YOUR_TOKEN>", "SONARQUBE_URL" = "<YOUR_SERVER_URL>" }
```

</details>

<details>
<summary>Cursor</summary>

* To connect with SonarQube Cloud:

[![Install for SonarQube Cloud](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=sonarqube&config=eyJlbnYiOnsiU09OQVJRVUJFX1RPS0VOIjoiWU9VUl9UT0tFTiIsIlNPTkFSUVVCRV9PUkciOiJZT1VSX1NPTkFSUVVCRV9PUkcifSwiY29tbWFuZCI6ImRvY2tlciBydW4gLS1pbml0IC0tcHVsbD1hbHdheXMgLWkgLS1ybSAtZSBTT05BUlFVQkVfVE9LRU4gLWUgU09OQVJRVUJFX09SRyBzb25hcnNvdXJjZS9zb25hcnF1YmUtbWNwIn0%3D)

For **SonarQube Cloud US**, manually add `"SONARQUBE_URL": "https://sonarqube.us"` to the `env` section in your MCP configuration after installation.

* To connect with SonarQube Server:

[![Install for SonarQube Server](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=sonarqube&config=eyJlbnYiOnsiU09OQVJRVUJFX1RPS0VOIjoiWU9VUl9VU0VSX1RPS0VOIiwiU09OQVJRVUJFX1VSTCI6IllPVVJfU09OQVJRVUJFX1VSTCJ9LCJjb21tYW5kIjoiZG9ja2VyIHJ1biAtLWluaXQgLS1wdWxsPWFsd2F5cyAtaSAtLXJtIC1lIFNPTkFSUVVCRV9UT0tFTiAtZSBTT05BUlFVQkVfVVJMIHNvbmFyc291cmNlL3NvbmFycXViZS1tY3AifQ%3D%3D)

</details>

<details>
<summary>Gemini CLI</summary>

> **Note:** The Gemini CLI extension has moved to the [sonarqube-agent-plugins](https://github.com/SonarSource/sonarqube-agent-plugins) repository. Please install it from there going forward.

You can install our MCP server extension by using the following command:

```bash
gemini extensions install https://github.com/SonarSource/sonarqube-agent-plugins
```

You will need to set the required environment variables before starting Gemini:

**Environment Variables Required:**

* **For SonarQube Cloud:**
  - `SONARQUBE_TOKEN` - Your SonarQube Cloud token
  - `SONARQUBE_ORG` - Your organization key
  - `SONARQUBE_URL` - (Optional) Set to `https://sonarqube.us` for SonarQube Cloud US

* **For SonarQube Server:**
  - `SONARQUBE_TOKEN` - Your SonarQube Server USER token
  - `SONARQUBE_URL` - Your SonarQube Server URL

Once installed, the extension will be installed under `<home>/.gemini/extensions/sonarqube/gemini-extension.json`.

</details>

<details>
<summary>GitHub Copilot CLI</summary>

After starting Copilot CLI, run the following command to add the SonarQube MCP server:

```bash
/mcp add
```

You will have to provide different information about the MCP server, you can use tab to navigate between fields.

* To connect with SonarQube Cloud:

```
Server Name: sonarqube
Server Type: Local (Press 1)
Command: docker
Arguments: run, --init, --pull=always, --rm, -i, -e, SONARQUBE_TOKEN, -e, SONARQUBE_ORG, sonarsource/sonarqube-mcp
Environment Variables: SONARQUBE_TOKEN=<YOUR_TOKEN>,SONARQUBE_ORG=<YOUR_ORG>
Tools: *
```

For **SonarQube Cloud US**, add `-e, SONARQUBE_URL` to Arguments and `SONARQUBE_URL=https://sonarqube.us` to Environment Variables.

* To connect with SonarQube Server:

```
Server Name: sonarqube
Server Type: Local (Press 1)
Command: docker
Arguments: run, --init, --pull=always, --rm, -i, -e, SONARQUBE_TOKEN, -e, SONARQUBE_URL, sonarsource/sonarqube-mcp
Environment Variables: SONARQUBE_TOKEN=<YOUR_USER_TOKEN>,SONARQUBE_URL=<YOUR_SERVER_URL>
Tools: *
```

The configuration file is located at `~/.copilot/mcp-config.json`.

</details>

<details>
<summary>GitHub Copilot coding agent</summary>

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](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/extend-coding-agent-with-mcp#setting-up-a-copilot-environment-for-copilot-coding-agent). Only secrets with names prefixed with **COPILOT_MCP_** will be available to your MCP configuration.

In your GitHub repository, navigate under **Settings -> Copilot -> Coding agent**, and add the following configuration in the MCP configuration section:

* To connect with SonarQube Cloud:

```
{
  "mcpServers": {
    "sonarqube": {
      "type": "local",
      "command": "docker",
      "args": [
        "run",
        "--init",
        "--pull=always",
        "--rm",
        "-i",
        "-e",
        "SONARQUBE_TOKEN",
        "-e",
        "SONARQUBE_ORG",
        "sonarsource/sonarqube-mcp"
      ],
      "env": {
        "SONARQUBE_TOKEN": "COPILOT_MCP_SONARQUBE_TOKEN",
        "SONARQUBE_ORG": "COPILOT_MCP_SONARQUBE_ORG"
      },
      "tools": ["*"]
    }
  }
}
```

For **SonarQube Cloud US**, add `"-e", "SONARQUBE_URL"` to the `args` array and `"SONARQUBE_URL": "COPILOT_MCP_SONARQUBE_URL"` to the `env` section, then set the secret `COPILOT_MCP_SONARQUBE_URL=https://sonarqube.us`.

* To connect with SonarQube Server:

```
{
  "mcpServers": {
    "sonarqube": {
      "type": "local",
      "command": "docker",
      "args": [
        "run",
        "--init",
        "--pull=always",
        "--rm",
        "-i",
        "-e",
        "SONARQUBE_TOKEN",
        "-e",
        "SONARQUBE_URL",
        "sonarsource/sonarqube-mcp"
      ],
      "env": {
        "SONARQUBE_TOKEN": "COPILOT_MCP_SONARQUBE_USER_TOKEN",
        "SONARQUBE_URL": "COPILOT_MCP_SONARQUBE_URL"
      },
      "tools": ["*"]
    }
  }
}
```

</details>

<details>
<summary>Kiro</summary>

Create a `.kiro/settings/mcp.json` file in your workspace directory (or edit if it already exists), add the following configuration:

* To connect with 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": "<YOUR_ORG>"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}
```

For **SonarQube Cloud US**, add `"-e", "SONARQUBE_URL"` to the `args` array and `"SONARQUBE_URL": "https://sonarqube.us"` to the `env` section.

* To connect with SonarQube Server:

```
{
  "mcpServers": {
    "sonarqube": {
      "command": "docker",
      "args": [
        "run",
        "--init",
        "--pull=always",
        "-i",
        "--rm",
        "-e", 
        "SONARQUBE_TOKEN",
        "-e",
        "SONARQUBE_URL",
        "sonarsource/sonarqube-mcp"
      ],
      "env": {
        "SONARQUBE_TOKEN": "<YOUR_USER_TOKEN>",
        "SONARQUBE_URL": "<YOUR_SERVER_URL>"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}
```

</details>
    
<details>
<summary>VS Code</summary>

You can use the following buttons to simplify the installation process within VS Code.

[![Install for SonarQube Cloud](https://img.shields.io/badge/VS_Code-Install_for_SonarQube_Cloud-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=sonarqube&inputs=%5B%7B%22id%22%3A%22SONARQUBE_TOKEN%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22SonarQube%20Cloud%20Token%22%2C%22password%22%3Atrue%7D%2C%7B%22id%22%3A%22SONARQUBE_ORG%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22SonarQube%20Cloud%20Organization%20Key%22%2C%22password%22%3Afalse%7D%5D&config=%7B%22command%22%3A%22docker%22%2C%22args%22%3A%5B%22run%22%2C%22--init%22%2C%22--pull%3Dalways%22%2C%22-i%22%2C%22--rm%22%2C%22-e%22%2C%22SONARQUBE_TOKEN%22%2C%22-e%22%2C%22SONARQUBE_ORG%22%2C%22mcp%2Fsonarqube%22%5D%2C%22env%22%3A%7B%22SONARQUBE_TOKEN%22%3A%22%24%7Binput%3ASONARQUBE_TOKEN%7D%22%2C%22SONARQUBE_ORG%22%3A%22%24%7Binput%3ASONARQUBE_ORG%7D%22%7D%7D)

For **SonarQube Cloud US**, manually add `"SONARQUBE_URL": "https://sonarqube.us"` to the `env` section in your MCP configuration after installation.

[![Install for SonarQube Server](https://img.shields.io/badge/VS_Code-Install_for_SonarQube_Server-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=sonarqube&inputs=%5B%7B%22id%22%3A%22SONARQUBE_TOKEN%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22SonarQube%20Server%20User%20Token%22%2C%22password%22%3Atrue%7D%2C%7B%22id%22%3A%22SONARQUBE_URL%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22SonarQube%20Server%20URL%22%2C%22password%22%3Afalse%7D%5D&config=%7B%22command%22%3A%22docker%22%2C%22args%22%3A%5B%22run%22%2C%22--init%22%2C%22--pull%3Dalways%22%2C%22-i%22%2C%22--rm%22%2C%22-e%22%2C%22SONARQUBE_TOKEN%22%2C%22-e%22%2C%22SONARQUBE_URL%22%2C%22mcp%2Fsonarqube%22%5D%2C%22env%22%3A%7B%22SONARQUBE_TOKEN%22%3A%22%24%7Binput%3ASONARQUBE_TOKEN%7D%22%2C%22SONARQUBE_URL%22%3A%22%24%7Binput%3ASONARQUBE_URL%7D%22%7D%7D)

</details>
<details>
<summary>Windsurf</summary>

SonarQube MCP Server is available as a Windsurf plugin. Follow these instructions:

1. Open Windsurf **Settings** > **Cascade** > **MCP Servers** and select **Open MCP Marketplace** 
2. Search for `sonarqube` on the Cascade MCP Marketplace
3. Choose the **SonarQube MCP Server** and select **Install**
4. Add the required SonarQube User token. Optionally add a default organization key for SonarQube Cloud, or add the SonarQube URL for SonarQube Server or Community Build.

For **SonarQube Cloud US**, set the URL to `https://sonarqube.us`.

</details>

<details>
<summary>Zed</summary>

Navigate 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:

* When using SonarQube Cloud:

```
{
  "sonarqube_token": "YOUR_SONARQUBE_TOKEN",
  "sonarqube_org": "SONARQUBE_ORGANIZATION_KEY",
  "docker_path": "DOCKER_PATH"
}
```

For **SonarQube Cloud US**, add `"sonarqube_url": "https://sonarqube.us"` to the configuration.

* When using SonarQube Server:

```
{
  "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`

</details>

> 💡 **Tip:** We recommend pulling the latest image regularly or before reporting issues to ensure you have the most up-to-date features and fixes.

## Manual installation

You can manually install the SonarQube MCP server by copying the following snippet in the MCP servers configuration file:

* To connect with SonarQube Cloud:

```JSON
{
  "sonarqube": {
    "command": "docker",
    "args": [
      "run",
      "--init",
      "--pull=always",
      "-i",
      "--rm",
      "-e",
      "SONARQUBE_TOKEN",
      "-e",
      "SONARQUBE_ORG",
      "sonarsource/sonarqube-mcp"
    ],
    "env": {
      "SONARQUBE_TOKEN": "<token>",
      "SONARQUBE_ORG": "<org>"
    }
  }
}
```

* To connect with SonarQube Server:

```JSON
{
  "sonarqube": {
    "command": "docker",
    "args": [
      "run",
      "--init",
      "--pull=always",
      "-i",
      "--rm",
      "-e",
      "SONARQUBE_TOKEN",
      "-e",
      "SONARQUBE_URL",
      "sonarsource/sonarqube-mcp"
    ],
    "env": {
      "SONARQUBE_TOKEN": "<token>",
      "SONARQUBE_URL": "<url>"
    }
  }
}
```

## Integration with SonarQube for IDE

The SonarQube MCP Server can integrate with [SonarQube for IDE](https://www.sonarsource.com/products/sonarlint/) to further enhance your development workflow, providing better code analysis and insights directly within your IDE.

<details>
<summary>Configuration</summary>

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:

```JSON
{
  "sonarqube": {
    "command": "docker",
    "args": [
      "run",
      "--init",
      "--pull=always",
      "-i",
      "--rm",
      "-e",
      "SONARQUBE_TOKEN",
      "-e",
      "SONARQUBE_ORG",
      "-e",
      "SONARQUBE_IDE_PORT",
      "sonarsource/sonarqube-mcp"
    ],
    "env": {
      "SONARQUBE_TOKEN": "<token>",
      "SONARQUBE_ORG": "<org>",
      "SONARQUBE_IDE_PORT": "<64120-64130>"
    }
  }
}
```

> When running the MCP server in a container 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=host` option to your container run command.

</details>

## Configuration

Depending on your environment, you should provide specific environment variables.

### Base

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 the container image                 |
| `SONARQUBE_PROJECT_KEY`          | Optional default project key. When set, all tools that require a project key will use this value automatically — the `projectKey` parameter is removed from their schema entirely. Useful when working on a single project. |
| `SONARQUBE_IDE_PORT`             | Optional port number between 64120 and 64130 used to connect SonarQube MCP Server with SonarQube for IDE.                                                                                                                   |
| `SONARQUBE_FORCE_LOCAL_ANALYSIS` | Set to `true` to use `analyze_code_snippet` instead of Vortex analysis on Cloud stdio, including for entitled organizations. Requires the `analysis` toolset. Default: `false`. Has no effect on SonarQube Server or Cloud HTTP. |
| `SONARQUBE_DEBUG_ENABLED`        | When set to `true`, enables debug logging. Debug logs are written to both the log file and STDERR. Useful for troubleshooting connectivity or configuration issues. Default: `false`.                                       |
| `SONARQUBE_LOG_TO_FILE_DISABLED` | When set to `true`, disables writing logs to disk entirely. No log files will be created under `STORAGE_PATH/logs/`. Useful in containerized or ephemeral environments where file logging is undesirable. Default: `false`. |

### Workspace Mount (Reducing Context Bloat)

By default, analysis tool `analyze_code_snippet` requires the agent to pass the full file content as a `fileContent` argument. For large files or when analyzing many files in a session, this significantly increases context window usage and cost.

**Solution:** mount your project directory into the container at `/app/mcp-workspace`. When this mount is detected, the server reads files directly from disk using the project-relative `filePath` argument — file content never passes through the agent context.

```json
{
  "args": [
    "run", "-i", "--rm", "--init", "--pull=always",
    "-e", "SONARQUBE_TOKEN",
    "-e", "SONARQUBE_ORG",
    "-v", "/path/to/your/project:/app/mcp-workspace",
    "sonarsource/sonarqube-mcp"
  ]
}
```

With a mount, analysis tools read files directly using `filePath`; `fileContent` is not needed.

Over stdio, analysis is selected at startup (subject to enabled toolsets):

- **SonarQube Cloud:** Vortex analysis (`run_advanced_code_analysis`) with a workspace mount and at least one entitled organization; local analysis otherwise. Vortex analysis only accepts entitled organizations.
- **SonarQube Server:** Vortex analysis for entitled instances (requires a workspace mount); local analysis for instances without Vortex.

Local analysis uses SonarQube for IDE if connected or `analyze_code_snippet`. Without a mount, snippet analysis requires `fileContent`.

On Cloud stdio, `SONARQUBE_ORG` limits the entitlement check to that organization. To use snippets for all organizations, set `SONARQUBE_FORCE_LOCAL_ANALYSIS=true`, enable the `analysis` toolset, and restart. This setting only affects Cloud stdio.

Over HTTP/HTTPS, Cloud and Server support `analyze_code_snippet` when the MCP server has a startup `SONARQUBE_TOKEN` and the `analysis` toolset is enabled. The startup token is required for analyzer initialization (Cloud plugin downloads are anonymous); calls use the caller’s token and, on Cloud, the organization selected for the request to retrieve quality profiles and active rules. Without a startup token, snippet analysis and analyzer downloads are disabled, even with `SONARQUBE_FORCE_LOCAL_ANALYSIS=true`. Vortex entitlement is not required.

### Selective Tool Enablement

MCP clients load every enabled tool — its name, description, and input schema — into the agent's context on every conversation. Limiting that list with `SONARQUBE_TOOLSETS` cuts context usage and the token cost of each session.

By default, only important toolsets are enabled. Enable additional toolsets only when you need them.

Agentic readiness is also selected by default on stdio when the organization is entitled. On HTTP it requires explicit `agentic-readiness` opt-in through `SONARQUBE_TOOLSETS`. Selecting a toolset does not bypass its transport, version, or entitlement requirements.

| Environment variable  | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `SONARQUBE_TOOLSETS`  | Comma-separated list of toolsets to enable. When set, only these toolsets will be available. If not set, default important toolsets are enabled (`analysis`, `ide`, `issues`, `projects`, `quality-gates`, `rules`, `duplications`, `measures`, `security-hotspots`, `dependency-risks`, `coverage`, `cag`). **Note:** The `projects` toolset is always enabled as it's required to find project keys for other operations. Vortex context tools (deprecated name: Context Augmentation/CAG) and Vortex analysis tools (deprecated name: Advanced Analysis/A3S) are only available in stdio mode and share a single combined organization entitlement — an org must be entitled to both to use either. Cloud built-in analysis checks the organization selected at runtime; proxied context tools use the startup organization. On SonarQube Server, stdio lists Vortex context and `run_advanced_code_analysis` when both the CAG and A3S hubs are entitled. Prefer the unified `vortex` toolset key. The deprecated `cag` and `analysis` keys still work; a startup warning and a deprecation note in the server instructions are emitted when they are used without `vortex`. In Streamable HTTP mode, clients can send a `SONARQUBE_TOOLSETS` HTTP header to narrow this further per-request, but cannot enable toolsets beyond what the server was launched with (see [Streamable HTTP transport](#2-http-streamable-http) below). |
| `SONARQUBE_READ_ONLY` | When set to `true`, enables read-only mode which disables all write operations (changing issue status for example). This filter is cumulative with `SONARQUBE_TOOLSETS` if both are set. Default: `false`. In Streamable HTTP mode, clients can send a `SONARQUBE_READ_ONLY` HTTP header to further restrict individual requests to read-only, but cannot lift a server-level read-only restriction (see [Streamable HTTP transport](#2-http-streamable-http) below).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |

<details>
<summary>Available Toolsets</summary>

| Toolset               | Key                 | Description                                                                                                                                                 |
|-----------------------|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Analysis**          | `analysis`          | Code analysis tools (local analysis via `analyze_code_snippet`, **deprecated** in favor of `analyze_file_list`/Vortex analysis)                                                                      |
| **IDE**               | `ide`               | SonarQube for IDE bridge tools (file analysis, automatic analysis toggle) — currently also included in `analysis`                                           |
| **Issues**            | `issues`            | Search and manage SonarQube issues                                                                                                                          |
| **Security Hotspots** | `security-hotspots` | Search and review Security Hotspots                                                                                                                         |
| **Projects**          | `projects`          | Browse and search SonarQube projects                                                                                                                        |
| **Quality Gates**     | `quality-gates`     | Access quality gates and their status                                                                                                                       |
| **Rules**             | `rules`             | Browse and search SonarQube rules                                                                                                                           |
| **Sources**           | `sources`           | Access source code and SCM information                                                                                                                      |
| **Duplications**      | `duplications`      | Find code duplications across projects                                                                                                                      |
| **Measures**          | `measures`          | Retrieve metrics and measures (includes both measures and metrics tools)                                                                                    |
| **Languages**         | `languages`         | List supported programming languages                                                                                                                        |
| **Portfolios**        | `portfolios`        | Manage portfolios and enterprises (Cloud and Server)                                                                                                        |
| **System**            | `system`            | System administration tools (Server only)                                                                                                                   |
| **Webhooks**          | `webhooks`          | Manage webhooks                                                                                                                                             |
| **Dependency Risks**  | `dependency-risks`  | Analyze dependency risks and security issues (SCA)                                                                                                          |
| **Coverage**          | `coverage`          | Test coverage analysis and improvement tools                                                                                                                |
| **Vortex Context**    | `cag`               | Vortex context tools — stdio only. **Deprecated** in favor of `vortex` (old name: Context Augmentation/CAG)                                                 |
| **Vortex**            | `vortex`            | Unified, **recommended** toolset surfacing both Vortex context and Vortex analysis tools under one name (stdio only; Cloud needs combined org entitlement; Server needs both hubs entitled) |
| **Agentic Readiness** | `agentic-readiness` | Agentic Readiness Assessment tools (SonarQube Cloud, requires org entitlement)                                                                              |
| **Architecture**      | `architecture`      | Read architecture, replace intended models and manage project directives (not enabled by default)                                                        |

#### Examples

**Enable analysis, issues, and quality gates toolsets (using Docker with SonarQube Cloud):**

```bash
docker run --init --pull=always -i --rm \
  -e SONARQUBE_TOKEN="<token>" \
  -e SONARQUBE_ORG="<org>" \
  -e SONARQUBE_TOOLSETS="analysis,issues,quality-gates" \
  sonarsource/sonarqube-mcp
```

Note: The `projects` toolset is always enabled automatically, so you don't need to include it in `SONARQUBE_TOOLSETS`.

**Enable read-only mode (using Docker with SonarQube Cloud):**

```bash
docker run --init --pull=always -i --rm \
  -e SONARQUBE_TOKEN="<token>" \
  -e SONARQUBE_ORG="<org>" \
  -e SONARQUBE_READ_ONLY="true" \
  sonarsource/sonarqube-mcp
```

</details>

#### SonarQube Cloud

For stdio, configure the following environment variables:

| Environment variable | Description                                                                                                               | Required |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------- | -------- |
| `SONARQUBE_TOKEN`    | Your SonarQube Cloud [token](https://docs.sonarsource.com/sonarqube-cloud/managing-your-account/managing-tokens/)         | Yes      |
| `SONARQUBE_ORG`      | Optional fixed SonarQube Cloud organization [key](https://sonarcloud.io/account/organizations)                            | No       |
| `SONARQUBE_URL`      | Custom SonarQube Cloud URL (defaults to `https://sonarcloud.io`). Use this for SonarQube Cloud US: `https://sonarqube.us` | No       |

**Examples:**

- **SonarQube Cloud**: Only `SONARQUBE_TOKEN` is required. `SONARQUBE_ORG` fixes the organization when set.
- **SonarQube Cloud US**: Set `SONARQUBE_TOKEN` and `SONARQUBE_URL=https://sonarqube.us`; `SONARQUBE_ORG` is optional.

#### SonarQube Server

| Environment variable | Description                                                                                                                                 | Required |
|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------|----------|
| `SONARQUBE_TOKEN`     | Your SonarQube Server **USER** [token](https://docs.sonarsource.com/sonarqube-server/latest/user-guide/managing-tokens/#generating-a-token) | Yes      |
| `SONARQUBE_URL`       | Your SonarQube Server URL                                                                                                                   | Yes      |

> **Version requirement:** SonarQube Server **2025.1** (SQS) or **25.1** (SonarQube Community Build) or later is required. At startup, the MCP server reads the connected instance version and exits with an error if it is too old (for example, legacy 9.x/10.x Server releases and Community Build 24.x are not supported). SonarQube Cloud is not subject to this check.

> ⚠️ Connection to SonarQube Server requires a token of type **USER** and will not function properly if project tokens or global tokens are used.

> 💡 **Configuration Tip (stdio mode)**: A token without a URL defaults to SonarQube Cloud. Set `SONARQUBE_URL` for SonarQube Server or a different Cloud region. `SONARQUBE_ORG` fixes the Cloud organization when set.

In stdio, setting `SONARQUBE_ORG` fixes the Cloud organization. Tool `organization` arguments are omitted from schemas and rejected, like `projectKey` when `SONARQUBE_PROJECT_KEY` is set.

With `SONARQUBE_ORG` unset, agents can call `list_organizations` to discover organization keys, names, IDs, and UUIDs accessible to your user account, then pass a key as the optional `organization` argument on organization-aware tools. Stdio retains a uniquely detected organization as its default; zero or multiple organizations leave it unresolved. A tool argument applies only to that call and never changes the detected default. Snippet profile and rule lookups use the organization selected for that call.

For HTTP/HTTPS token requests, server-level `SONARQUBE_ORG` remains supported for compatibility but is deprecated and logs a startup warning. It fixes the organization for every request and rejects client organization headers and tool `organization` arguments. When no server organization is configured, an optional client `SONARQUBE_ORG` header fixes the organization for that request and disallows tool `organization` arguments. Without the header, use the tool argument. Tools that require an organization report discovery guidance when all are missing. Organization discovery and tools whose APIs consume only resource identifiers do not require an organization argument. Organization-aware issue search and dependency-risk entitlement checks use the selected organization. When OAuth is configured, server-level `SONARQUBE_ORG` is rejected. OAuth requests also reject organization headers; select organizations through tool arguments.

Vortex context tools use the configured or uniquely detected startup organization. Runtime organization arguments do not reconfigure the proxied context engine; unresolved startup organizations skip that proxy. The built-in `run_advanced_code_analysis` tool checks combined Vortex entitlement for the organization selected on each invocation.

### Transport Modes

The [MCP specification](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports) defines two transport mechanisms: **Stdio** and **Streamable HTTP**. The SonarQube MCP Server supports both:

| MCP transport       | Server mode                           | Typical use                                                                                                            |
|---------------------|---------------------------------------|------------------------------------------------------------------------------------------------------------------------|
| **Stdio**           | Default (no `SONARQUBE_TRANSPORT`)    | Local MCP clients that launch the server as a subprocess (Cursor, Claude Code, VS Code, etc.)                          |
| **Streamable HTTP** | `SONARQUBE_TRANSPORT=http` or `https` | Remote or multi-user deployments; clients connect to `/mcp` over HTTP(S) (e.g. Windsurf with a self-hosted server URL) |

> **Note:** **Streamable HTTP** is the current MCP network transport. The older SSE-only HTTP transport from earlier MCP versions is deprecated and not supported.

#### 1. **Stdio** (Default - Recommended for Local Development)
The recommended mode for local development and single-user setups, used by most MCP clients.


> The README is long; the above is its first 40000 characters. Full content: https://github.com/SonarSource/sonarqube-mcp-server
