Gemini CLI

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

Gemini CLIarrow-up-right is Google's terminal-based AI assistant. Use this setup when you want Sonar tools available within a Gemini CLI workflow.

Set up MCP for Gemini CLI

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

Install the SonarQube MCP Server extension using the following command:

gemini extensions install https://github.com/SonarSource/sonarqube-mcp-server
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.

Set the required environment variables before starting Gemini:

SONARQUBE_TOKEN="<YourSonarQubeUserToken>"
SONARQUBE_ORG="<YourOrganizationName>" // For SonarQube Cloud, empty otherwise.
SONARQUBE_URL="<YourSonarQubeURL>" // For SonarQube Server, SonarQube Cloud US region, and SonarQube Community Build. Empty otherwise.
circle-exclamation
circle-check

Check out this video of Gemini CLI & SonarQube MCP Server for more insights.

Use Sonar tools from Gemini CLI

Once connected, Gemini CLI can call SonarQube MCP tools on your behalf. See the Tools page for the full list of available tools.

circle-info

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

Last updated

Was this helpful?