Claude Code

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

Claude Codearrow-up-right is Anthropic's CLI for Claude that runs in your terminal. Use this setup when you want to use Sonar tools directly from the command line or when working in a terminal-based AI workflow.

For full details on installing MCP servers with Claude Code, refer to the official Anthropic docsarrow-up-right.

Set up MCP for Claude 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

With an HTTP transport server

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

As a local stdio server

The claude mcp add sonarqube command allows you to set up the SonarQube MCP Server as a local stdio server:

circle-exclamation

For SonarQube Cloud:

For SonarQube Server:

circle-check

Manual configuration

For a manual configuration, add this MCP configuration to your ~/.claude.json file.

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.

Claude Code with SonarQube Cloud

circle-check

Claude Code with SonarQube Server

When finished with your setup, you can verify the MCP connection by running mcp__sonarqube__ping_system to test the connection.

Use Sonar tools from Claude Code

Once connected, Claude Code 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?