> For the complete documentation index, see [llms.txt](https://docs.sonarsource.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sonarsource.com/sonarqube-mcp-server/setup/build.md).

# Build

As described in the [IDE/CLI quickstart guides](/sonarqube-mcp-server/setup/quickstart-guides.md), the easiest way to launch the SonarQube MCP Server is with the [sonarsource/sonarqube-mcp](https://hub.docker.com/r/sonarsource/sonarqube-mcp/tags) container image, but you have other options.

To run the server as a standalone JAR without Docker, download a pre-built release from the [SonarSource binaries repository](https://binaries.sonarsource.com/?prefix=Distribution/sonarqube-mcp-server/). Every released version is published there as `sonarqube-mcp-server-<version>.jar` (for example, `sonarqube-mcp-server-1.20.0.2929.jar`).

## Run from JAR

Download the JAR for the version you want from the [binaries repository](https://binaries.sonarsource.com/?prefix=Distribution/sonarqube-mcp-server/), then configure your MCP client to run it with Java 21 or later. Add the following to your MCP configuration's JSON file.

The main difference between the server setup of SonarQube Cloud and SonarQube Server is:

* SonarQube Cloud requires a User token. Set `SONARQUBE_ORG` to your organization key, or omit it in stdio mode when your token belongs to exactly one organization (see [SONARQUBE\_ORG](/sonarqube-mcp-server/reference/environment-variables.md#sonarqube_org)).
  * If your SonarQube Cloud organization is in the US region, be sure to define SONARQUBE\_URL as `https://sonarqube.us` when configuring your connection. See the list of [common variables](/sonarqube-mcp-server/reference/environment-variables.md#common-variables) for complete details.
* SonarQube Server and SonarQube Community Build require a User token and server URL.

### SonarQube Cloud

```jsonc
{
  "sonarqube": {
    "command": "java",
    "args": [
        "-jar",
        "<PathToYourSonarQubeMCPServerJAR>"
    ],
    "env": {
        "STORAGE_PATH": "<PathToYourMCPStorage>",
        "SONARQUBE_TOKEN": "<YourSonarQubeUserToken>",
        "SONARQUBE_ORG": "<YourOrganization>"
        // "SONARQUBE_URL": "https://sonarqube.us" // define this parameter to connect to an organization in the US region
    }
  }
}
```

> **Warning:** *User tokens* are required when setting up connected mode or your SonarQube MCP server with SonarQube (Server, Cloud). Your binding won't function properly if you use *project tokens*, *global tokens*, or *scoped organization tokens* during setup.

> **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](/sonarqube-mcp-server/setup/environment-considerations.md#connecting-to-sonarqube-cloud-in-the-us-region) section for details.

### SonarQube Server

```json
{
  "sonarqube": {
    "command": "java",
    "args": [
        "-jar",
        "<PathToYourSonarQubeMCPServerJAR>"
    ],
    "env": {
        "STORAGE_PATH": "<PathToYourMCPStorage>",
        "SONARQUBE_TOKEN": "<YourSonarQubeUserToken>",
        "SONARQUBE_URL": "<YourSonarQubeServerURL>"
    }
  }
}
```

> **Warning:** *User tokens* are required when setting up connected mode or your SonarQube MCP server with SonarQube (Server, Cloud). Your binding won't function properly if you use *project tokens*, *global tokens*, or *scoped organization tokens* during setup.

## Build from source

SonarQube MCP Server requires a Java Development Kit (JDK) version 21 or later to build.

1. Clone the SonarQube MCP Server project from the [sonarqube-mcp-server repository](https://github.com/SonarSource/sonarqube-mcp-server).
2. Run the following Gradle command to clean the project and build the application:

   ```bash
   ./gradlew clean build -x test
   ```

   The JAR file will be created in `build/libs/`.
3. After adding or updating dependencies, regenerate the lock files:

   ```bash
   ./gradlew :dependencies --write-locks
   ./gradlew :its:dependencies --write-locks
   ```
4. Use the [Run from JAR](#run-from-jar) configuration above, pointing `<PathToYourSonarQubeMCPServerJAR>` to the JAR in `build/libs/`.

## Deployment options

Depending on your environment, you may want to deploy your MCP server in different ways. See [Environment considerations](/sonarqube-mcp-server/setup/environment-considerations.md) to choose the right setup.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.sonarsource.com/sonarqube-mcp-server/setup/build.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
