> 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-for-vs-code/ai-capabilities/integrations.md).

# AI integrations

Set up SonarQube CLI or a self-hosted SonarQube MCP Server for AI agents detected by SonarQube for VS Code.

Open **SonarQube Setup** > **AI Integrations** to connect SonarQube to AI agents in your IDE. The view has separate cards for **SonarQube CLI** and **SonarQube MCP Server**. Expand **Manage agents** in either card to see the agents detected in the IDE or through a locally installed agent CLI. An agent appearing in the list means it was detected; it does not mean SonarQube integration has been completed.

Choose the setup that fits your agent:

* **SonarQube CLI** provides local analysis while an agent edits code. Install and sign in to the CLI, then run its integration for each supported agent
* **SonarQube MCP Server** gives an agent access to project information such as issues, quality gates, and coverage. Configure a self-hosted MCP entry for a supported agent using a SonarQube for VS Code connected-mode connection. This setup does not require the SonarQube CLI or CLI authentication

Use both setups if needed. Refresh the view to check CLI, authentication, agent, and MCP configuration states.

## Set up SonarQube CLI for an agent

1. Check the installation status in the **SonarQube CLI** card. If the CLI is **Not detected**, select **Install SonarQube CLI**. Follow the prompts in the terminal that opens. If an installation is **Unavailable**, open the troubleshooting guide and fix the installation before continuing
2. If you need to sign in, select **Sign in with SonarQube CLI**. The extension uses a recommended or sole IDE connection, or asks you to select one. It pre-fills the server URL and, for SonarQube Cloud, the organization. Enter your credentials in the CLI terminal. The extension does not pass your IDE token to the CLI. If you're already signed in, the view keeps your CLI authentication, even if it differs from your IDE connection
3. Expand **Manage agents** in the CLI card. For each agent that supports CLI integration, select **Integrate for all projects** and respond to any prompts in the terminal. Repeat for each agent you want to integrate
4. When the terminal closes, check its result and refresh the view. The view confirms CLI installation and authentication. It does not verify whether each agent integration completed, so **Integrate for all projects** may remain available after a successful run

GitHub Copilot in VS Code and GitHub Copilot CLI are separate targets. If a detected agent has no CLI integration action, use the guidance shown in its row. Select **SonarQube CLI guide** for CLI documentation.

## Configure a self-hosted SonarQube MCP Server

The SonarQube MCP Server is a Model Context Protocol (MCP) server that runs locally and enables a seamless connection between your AI agents and your SonarQube platform. The tools are designed to bridge the divide between productivity and quality. Please see the full details in the SonarQube [SonarQube MCP Server](https://docs.sonarsource.com/sonarqube-mcp-server/) documentation.

When you use SonarQube MCP Server with SonarQube for IDE, the MCP server can trigger analysis in the editor. Creating a self-hosted MCP entry uses your selected [connected-mode connection](/sonarqube-for-vs-code/connect-your-ide/setup.md); it works independently of SonarQube CLI installation and authentication. This view only configures a self-hosted MCP server, not the SonarQube Server-hosted or SonarQube Cloud-hosted MCP server.

1. Set up a connected-mode connection to SonarQube Server or SonarQube Cloud
2. In **SonarQube Setup** > **AI Integrations**, expand **Manage agents** in the **SonarQube MCP Server** card. Each supported agent row shows the configuration file that will be updated
3. Select **Set up** for the agent you want to configure, then select the IDE connection to use. Repeat for any other agents you want to configure. The extension updates only the selected agent's configuration file
4. Use **Open configuration** to inspect an existing entry. Select **MCP configuration guide** for manual setup instructions

When detected, GitHub Copilot in VS Code, Claude Code, Cursor, Windsurf, and Kiro can use self-hosted file setup. Codex and GitHub Copilot CLI appear as **Available through CLI** because this view does not configure their self-hosted MCP files.

{% hint style="info" %}
"Windsurf" refers to the legacy Windsurf-branded application. Its current name, Devin Desktop, is not yet detected for self-hosted file setup. See the Devin Desktop guide for its manual setup path instead.
{% endhint %}

The MCP card counts configured entries only among agents with supported self-hosted configuration files. Its status describes the file it inspected:

* **Not configured**: Select **Set up** to create the SonarQube entry
* **Configured**: A self-hosted SonarQube entry exists. Select **Open configuration** to inspect it
* **Managed by CLI**: The inspected file contains an entry managed by the SonarQube CLI. Open the file to inspect it; self-hosted setup does not change that entry
* **Needs attention**: The file is malformed or its `sonarqube` entry cannot be managed by this view. Select **Open configuration** to inspect the diagnostic. An existing MCP connection may still work

At startup, the extension refreshes `SONARQUBE_IDE_PORT` only in a recognized self-hosted entry that already has that key. It does not add a missing key or change the server URL, token, or other settings.

The view currently checks for an MCP entry named `sonarqube`. A URL-based, cloud-hosted entry with that name may show **Needs attention**, but the extension does not replace it. An entry under another name remains untouched but is not recognized as the SonarQube entry, so **Set up** may create a separate `sonarqube` entry.

The extension preserves unrelated configuration when it updates a supported file. It does not replace malformed configuration with an empty file or overwrite an entry managed by the SonarQube CLI. If it detects legacy agent instructions in your workspace, **Open file** opens those instructions for review.

Self-hosted MCP setup is unavailable in remote IDE windows. Use the documentation links or open an existing configuration file.

## Use GitHub Copilot tools in VS Code <a href="#github-copilot" id="github-copilot"></a>

SonarQube for VS Code also provides tools to the GitHub Copilot extension. These tools are available with your [installation](/sonarqube-for-vs-code/getting-started/installation.md) and work best in Copilot **Agent** mode. Ask Copilot to perform a SonarQube-related action or call a tool by name.

> **Note:** Organizations and enterprises on a Copilot Business or Copilot Enterprise plan must have the **MCP servers in Copilot** policy enabled by an administrator before MCP can be used with Copilot.

### SonarQube for IDE tools <a href="#sonarqube-for-ide-tools" id="sonarqube-for-ide-tools"></a>

* Potential Security Issues
  * `#sonarqube_getPotentialSecurityIssues`
  * Lists security issues and taint vulnerabilities in a file. The tool takes a file path as an argument
* Exclude File or Folder from Analysis
  * `#sonarqube_excludeFiles`
  * Updates the SonarQube for IDE analysis settings to exclude files and folders using known [file exclusions](/sonarqube-for-vs-code/using/file-exclusions.md)
* Set up Connected Mode
  * `#sonarqube_setUpConnectedMode`
  * Guides you through [connected-mode setup](/sonarqube-for-vs-code/connect-your-ide/setup.md) with SonarQube Server or SonarQube Cloud
* Analyze File
  * `#sonarqube_analyzeFile`
  * Analyzes a file, including a file you previously excluded

For more GitHub Copilot CLI features, see the [SonarQube plugin for GitHub Copilot CLI](/agent-centric-development-cycle/developer-tools/agent-plugins/github-copilot-cli.md).


---

# 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-for-vs-code/ai-capabilities/integrations.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.
