For the complete documentation index, see llms.txt. This page is also available as Markdown.

GitHub Copilot CLI

Set up the SonarQube MCP Server with GitHub Copilot CLI and start using Sonar tools with your agent.

GitHub Copilot CLI is GitHub's terminal-based AI assistant. Use this MCP server setup when you want Sonar tools available within a Copilot CLI interactive session.

If you prefer using the SonarQube-hosted MCP server instead, see SonarQube-hosted MCP server.

For an automated setup, use the GitHub Copilot CLI setup flow. It configures the MCP server automatically and also adds secrets detection, agentic analysis, and context augmentation.

Use the configuration generator

Use the official SonarQube MCP Server configuration generator to get a configuration code snippet for your setup:

  1. Identify the target MCP Client.

  2. Choose a hosting method.

  3. Enter the information into the configuration generator.

  4. Paste the generated configuration into your configuration file.

Manual setup

Environment variables

The following common variables are required. SONARQUBE_TOKEN applies to stdio transport only. For HTTP, HTTPS, or the embedded SonarQube Cloud 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.

Transport options

The SonarQube MCP Server supports three transport modes. Use Stdio for local development and most use cases, HTTPS for production and team deployments, and HTTP only on trusted internal networks.

Use Stdio for local development or when you're the only user. It's also the transport mode used in your agentic analysis and context augmentation workflows.

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

Provide the required information about your MCP server; use Tab to navigate between fields.

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: This code sample configures the MCP server using Stdio transport, where SONARQUBE_TOKEN is passed as an environment variable.

For HTTPS, HTTP, or the SonarQube-hosted MCP server, the SONARQUBE_TOKEN header is deprecated. Pass the token using the "Authorization": "Bearer <YourSonarQubeUserToken>" header instead.

Tip: 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 section for details.

Note: Docker's MCP Hub publishes the mcp/sonarqube image on its own cadence, so it may occasionally lag behind the latest release. The examples below use sonarsource/sonarqube-mcp instead, which receives new releases first and supports versioned tags for stable pinning.

GitHub Copilot CLI with SonarQube Cloud

GitHub Copilot CLI with SonarQube Server

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

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

Tip: Restart your AI agent for good measure, although it might not be required.

HTTPS

Use HTTPS when connecting GitHub Copilot CLI to a shared MCP server deployed for a team. This requires an HTTPS transport server to be running and accessible.

After starting Copilot CLI, run /mcp add and select the remote server type, then enter your server URL and token when prompted.

Alternatively, add the following directly to your ~/.copilot/mcp-config.json file:

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

HTTP

Important: The HTTP transport mode is not recommended. Use Stdio for local development or HTTPS for multi-user production deployments.

Use HTTP only on a trusted internal network or for local testing. This requires an HTTP transport server to be running.

Add the following to your ~/.copilot/mcp-config.json file:

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

Sonar Vortex: agentic analysis and context augmentation features

Set up agentic analysis and context augmentation using the SonarQube plugin or SonarQube CLI. See Make your agent verify its code and Add context to generate better code.

When using these features, your SONARQUBE_TOKEN lets your local MCP server configured for Stdio mode authenticate to the SonarQube Cloud API. See agentic analysis and context augmentation.

SonarQube-hosted MCP server

Connect to a SonarQube-hosted MCP server to skip running your own MCP infrastructure and always use the current server version:

  • SonarQube Cloud-hosted: the MCP server embedded in SonarQube Cloud. It exposes a smaller, fixed subset of tools. See the SonarQube Cloud-hosted page.

  • SonarQube Server-hosted: the MCP server installed as an extension on SonarQube Server (Developer, Enterprise, and Data Center editions), available on SonarQube Server 2026.3 and newer. See the SonarQube Server-hosted page.

Use Sonar tools from GitHub Copilot CLI

Once connected, GitHub Copilot CLI can call SonarQube MCP tools on your behalf. See Tools for all available tools.

Last updated

Was this helpful?