> 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/quickstart-guides/antigravity.md).

# Antigravity

Set up the SonarQube MCP Server with Antigravity and start using Sonar tools with your agent.

[Antigravity](https://antigravity.google/) is Google's multi-surface AI coding platform, available as a desktop app, CLI, IDE, and SDK. Use this MCP server setup when you want Sonar tools available within an Antigravity workflow.

## Choose your setup

The SonarQube MCP Server lets an AI agent query your SonarQube projects. With it, Antigravity can look up issues, quality gates, and coverage while it works. You can use a server that SonarQube hosts, run your own, or have the SonarQube CLI set it up for you. Choose how to connect:

| Option                                                               | Is best for                                                                         | What you get                                                                                                       | Who sets it up                                     |
| -------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------- |
| [Automated setup](#automated-setup-with-the-sonarqube-cli)           | Automatic configuration in Antigravity                                              | The MCP server, secrets detection, and Sonar Vortex analysis                                                       | You                                                |
| [SonarQube Cloud-hosted](#connect-to-a-sonarqube-hosted-mcp-server)  | SonarQube Cloud users                                                               | Nothing to install and a smaller, fixed subset of tools. No Sonar Vortex.                                          | You connect                                        |
| [SonarQube Server-hosted](#connect-to-a-sonarqube-hosted-mcp-server) | SonarQube Server 2026.3 and later (Developer, Enterprise, and Data Center editions) | Nothing to install on your machine. No Sonar Vortex.                                                               | An administrator installs it, and then you connect |
| [Self-hosted MCP server](#set-up-a-self-hosted-mcp-server)           | Full control                                                                        | The MCP server that you run yourself, with the Sonar Vortex analysis and context tools through the Stdio transport | You                                                |

For any option except the automated setup, the [configuration generator](https://mcp.sonarqube.com/config-generator.html) gives you a snippet to paste into your `~/.gemini/config/mcp_config.json` file.

## Automated setup with the SonarQube CLI

Use the [Antigravity setup flow](/sonarqube-cli/integrations/antigravity.md). It configures the MCP server automatically and also adds secrets detection and Vortex analysis. The setup flow does not install Vortex context for Antigravity because Antigravity has no session-start hook.

Vortex context is available with a self-hosted MCP server. See the [Vortex context tools](/sonarqube-mcp-server/reference/tools.md#vortex-context) and the [Sonar Vortex analysis](/agent-centric-development-cycle/inside-your-agent-the-agentic-loop/sonar-vortex-analysis.md) and [Sonar Vortex context](/agent-centric-development-cycle/inside-your-agent-the-agentic-loop/sonar-vortex-context.md) pages for more detail.

To install the SonarQube plugin for Antigravity instead, run the following command. The plugin does not include Vortex context. See the [SonarQube plugin for Antigravity](/agent-centric-development-cycle/developer-tools/agent-plugins/antigravity.md) page for details.

```bash
agy plugin install https://github.com/SonarSource/sonarqube-agent-plugins
```

## Connect to a SonarQube-hosted MCP server

To avoid running and maintaining your own MCP infrastructure while always using the current server version, connect to a SonarQube-hosted MCP server:

* SonarQube Cloud-hosted: for SonarQube Cloud users. The MCP server is embedded in SonarQube Cloud, so there's nothing to install, and it exposes a smaller, fixed subset of tools. To connect, see the [SonarQube Cloud-hosted](/sonarqube-mcp-server/setup/sonarqube-cloud-hosted.md) page.
* SonarQube Server-hosted: for SonarQube Server users on Developer, Enterprise, and Data Center editions, version 2026.3 and newer. An administrator installs the MCP server extension on your instance, and then you [connect your AI agent](/sonarqube-mcp-server/setup/sonarqube-server-hosted.md#connect-your-ai-agent). To install the extension, see the [SonarQube Server-hosted](/sonarqube-mcp-server/setup/sonarqube-server-hosted.md#install-the-mcp-server) page.

Neither the SonarQube Cloud-hosted nor the SonarQube Server-hosted option supports Sonar Vortex, which requires local filesystem access. To use Sonar Vortex analysis, use the automated setup or a self-hosted MCP server. Sonar Vortex context requires a self-hosted MCP server.

To get the connection snippet for either option, use the [configuration generator](https://mcp.sonarqube.com/config-generator.html) and select the matching hosting method.

## Set up a self-hosted MCP server

A self-hosted MCP server runs on your machine or in your own environment, and you manage it yourself. Set it up in one of two ways:

* [Install it from the Antigravity MCP Store](#install-from-the-antigravity-mcp-store).
* [Configure it manually](#configure-manually), using the configuration generator or by hand.

### Before you start

Set the following [common variables](/sonarqube-mcp-server/reference/environment-variables.md#common-variables). `SONARQUBE_TOKEN` applies to stdio transport only. For HTTP, HTTPS, or the SonarQube Cloud-hosted MCP server, use the `Authorization: Bearer <YourSonarQubeUserToken>` header instead.

* `SONARQUBE_TOKEN`: Your SonarQube user token (stdio transport).
* `SONARQUBE_ORG`: Your SonarQube Cloud organization key. Required for SonarQube Cloud only.
* `SONARQUBE_URL`: Your SonarQube Server or Community Build URL. Also required for SonarQube Cloud in the US region (`https://sonarqube.us`). Not needed for SonarQube Cloud in the EU region.

> **Important:** Your SonarQube token is a sensitive credential. Use environment variables to pass tokens rather than hardcoding them in configuration files. Never commit tokens to version control.

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

When using Sonar Vortex, your `SONARQUBE_TOKEN` lets your local MCP server configured for [Stdio](/sonarqube-mcp-server/setup/self-hosted.md#local-server-stdio) mode authenticate to the SonarQube Cloud API. See [Sonar Vortex analysis](/agent-centric-development-cycle/inside-your-agent-the-agentic-loop/sonar-vortex-analysis.md) and [Sonar Vortex context](/agent-centric-development-cycle/inside-your-agent-the-agentic-loop/sonar-vortex-context.md) for more information.

### Install from the Antigravity MCP Store

1. Select the three-dots menu, `...`, at the top of the **agent side panel**.
2. Select **MCP Servers**.
3. Search for `SonarQube`, hover over the entry, and select **Install**.
4. Enter your SonarQube user token. Add your organization key for SonarQube Cloud, or your server URL for SonarQube Server. For SonarQube Cloud US, also set the URL to `https://sonarqube.us`.

### Configure manually

The SonarQube MCP Server supports three transport modes. Use [Stdio](/sonarqube-mcp-server/setup/self-hosted.md#local-server-stdio) for local development and most use cases, [HTTPS](/sonarqube-mcp-server/setup/self-hosted.md#https-streamable-http-over-tls) for production and team deployments, and [HTTP](/sonarqube-mcp-server/setup/self-hosted.md#http-streamable-http) only on trusted internal networks.

Use the official [SonarQube MCP Server configuration generator](https://mcp.sonarqube.com/config-generator.html) to get a configuration code snippet for your setup:

1. Identify the target MCP Client.
2. Find your [#common-variables](/sonarqube-mcp-server/reference/environment-variables.md#common-variables).
3. Choose a [hosting method](/sonarqube-mcp-server/setup/environment-considerations.md#hosting-method).
4. Enter the information into the configuration generator.
5. Paste the generated configuration into your configuration file.

To configure by hand instead, select a transport tab.

{% tabs %}
{% tab title="STDIO (RECOMMENDED)" %}
Use [Stdio](/sonarqube-mcp-server/setup/self-hosted.md#local-server-stdio) for local development or when you're the only user. It's also the transport mode used in your [Sonar Vortex analysis](/agent-centric-development-cycle/inside-your-agent-the-agentic-loop/sonar-vortex-analysis.md) and [Sonar Vortex context](/agent-centric-development-cycle/inside-your-agent-the-agentic-loop/sonar-vortex-context.md) workflows.

Add the following to your `~/.gemini/config/mcp_config.json` file. To open the file, select the three-dots menu, `...`, at the top of the **agent side panel**, and then select **MCP Store** > **Manage MCP Servers** > **View raw config**.

> **Note:** This code sample configures the MCP server using [Stdio](/sonarqube-mcp-server/setup/self-hosted.md#local-server-stdio) transport, where `SONARQUBE_TOKEN` is passed as an environment variable.
>
> For [HTTPS](/sonarqube-mcp-server/setup/self-hosted.md#https-streamable-http-over-tls), [HTTP](/sonarqube-mcp-server/setup/self-hosted.md#http-streamable-http), or the [SonarQube-hosted MCP server](#connect-to-a-sonarqube-hosted-mcp-server), the `SONARQUBE_TOKEN` header is deprecated. Pass the token using the `"Authorization": "Bearer <YourSonarQubeUserToken>"` header instead.

**Antigravity with SonarQube Cloud**

```jsonc
{
  "mcpServers": {
    "sonarqube": {
      "command": "docker",
      "args": [
        "run",
        "--init",
        "--pull=always",
        "-i",
        "--rm",
        "-e",
        "SONARQUBE_TOKEN",
        "-e",
        "SONARQUBE_ORG",
        //"-e",
        //"SONARQUBE_URL",
        "sonarsource/sonarqube-mcp"
      ],
      "env": {
        "SONARQUBE_TOKEN": "<YourSonarQubeUserToken>",
        "SONARQUBE_ORG": "<YourSonarQubeOrganizationKey>",
        //"SONARQUBE_URL": "https://sonarqube.us"
      }
    }
  }
}
```

**Antigravity 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": "<YourSonarQubeUserToken>",
        "SONARQUBE_URL": "<YourSonarQubeServerURL>"
      }
    }
  }
}
```

> **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.

Set the required environment variables before starting Antigravity:

```bash
SONARQUBE_TOKEN="<YourSonarQubeUserToken>"
SONARQUBE_ORG="<YourSonarQubeOrganizationKey>" # For SonarQube Cloud, empty otherwise.
SONARQUBE_URL="<YourSonarQubeURL>" # For SonarQube Server, SonarQube Cloud US region (https://sonarqube.us), and SonarQube Community Build. Empty otherwise.
```

> **Tip:** To verify the connection, ask your AI agent to call the SonarQube MCP `ping_system` tool. For example: *"Ping the SonarQube MCP server."*

> **Note:** Restart Antigravity for the new MCP server configuration to take effect.
> {% endtab %}

{% tab title="HTTPS" %}
Use HTTPS when connecting Antigravity to a shared MCP server deployed for a team. This requires an [HTTPS transport server](/sonarqube-mcp-server/setup/self-hosted.md#https-streamable-http-over-tls) to be running and accessible.

Add the following to your `~/.gemini/config/mcp_config.json` file:

```json
{
  "mcpServers": {
    "sonarqube": {
      "type": "https",
      "url": "https://<YourSonarQubeMCPServer>:8443/mcp",
      "headers": {
        "Authorization": "Bearer <YourSonarQubeUserToken>"
      }
    }
  }
}
```

> **Tip:** To verify the connection, ask your AI agent to call the SonarQube MCP `ping_system` tool. For example: *"Ping the SonarQube MCP server."*

> **Note:** Restart Antigravity for the new MCP server configuration to take effect.
> {% endtab %}

{% tab title="HTTP" %}

> **Important:** The [HTTP](/sonarqube-mcp-server/setup/self-hosted.md#http-streamable-http) transport mode is not recommended. Use [Stdio](/sonarqube-mcp-server/setup/self-hosted.md#stdio) for local development or [HTTPS](/sonarqube-mcp-server/setup/self-hosted.md#https-streamable-http-over-tls) for multi-user production deployments.

Use HTTP only on a trusted internal network or for local testing. This requires an [HTTP transport server](/sonarqube-mcp-server/setup/self-hosted.md#http-streamable-http) to be running.

Add the following to your `~/.gemini/config/mcp_config.json` file:

```json
{
  "mcpServers": {
    "sonarqube": {
      "type": "http",
      "url": "http://<YourSonarQubeMCPServer>:8080/mcp",
      "headers": {
        "Authorization": "Bearer <YourSonarQubeUserToken>"
      }
    }
  }
}
```

> **Tip:** To verify the connection, ask your AI agent to call the SonarQube MCP `ping_system` tool. For example: *"Ping the SonarQube MCP server."*

> **Note:** Restart Antigravity for the new MCP server configuration to take effect.
> {% endtab %}
> {% endtabs %}

## Use Sonar tools from Antigravity

Once connected, Antigravity can call SonarQube MCP tools on your behalf. See the SonarQube MCP [Tools](/sonarqube-mcp-server/reference/tools.md) page for the full list of available tools.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sonarsource.com/sonarqube-mcp-server/setup/quickstart-guides/antigravity.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
