VS Code with GitHub Copilot

Set up the SonarQube MCP Server in VS Code with GitHub Copilot and start using Sonar tools from your agent.

VS Code with GitHub Copilotarrow-up-right is Microsoft's AI-assisted coding experience in Visual Studio Code. Use this setup when you want Sonar tools available in the Copilot Chat agent mode while you code.

To use the SonarQube MCP server in VS Code, you must first install Copilot Chatarrow-up-right.

Set up MCP for VS Code

Environment variables

The following Common variables are required. Note that 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.

triangle-exclamation

Connection and transport

Automatic configuration

When you're using an AI-enabled IDE such as Cursor, Windsurf, or VS Code with Copilot enabled, and have already completed your Connected mode setup in SonarQube for IDE with SonarQube Server or SonarQube Cloud, a quick select button is available.

  • Select the icon, Configure MCP Server from the CONNECTED MODE view window to use your connected mode credentials to start using the SonarQube MCP Server. The same workflow is available in the AI AGENTS CONFIGURATION view.

If you've connected to a SonarQube Cloud organization in the US region, the configuration details will be shared.

Quick configuration

Use the following link to quickly set up the SonarQube MCP Server in VS Code. This generates a configuration file and automatically fills it with your environment variables. Make sure your environment variables are configured first.

You can also find the SonarQube MCP Serverarrow-up-right in the GitHub MCP Registry, or search for it in VS Code Extensions using the term @mcp sonar to find an Install button.

With an HTTP transport server

Please see the Transport mode article for details and code samples.

Manual configuration

Follow the VS Code instructionsarrow-up-right and add the SonarQube MCP Server to your .vscode/mcp.json file.

For more information on the environment variables and how to retrieve the token and organization information, see the Environment variables page.

circle-exclamation
circle-info

This code sample configures the MCP server using Stdio transport, where SONARQUBE_TOKEN is passed as an environment variable.

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

VS Code with SonarQube Cloud

circle-check

VS Code with SonarQube Server

Use Sonar tools from VS Code

Once connected, you can use the tools provided by the SonarQube MCP Server in agent mode. See the Tools page for the full list of available tools.

See also the VS Code documentationarrow-up-right for more information about using MCP servers in VS Code.

circle-info

Concrete workflow examples for this IDE will be added after engineering review.

Last updated

Was this helpful?