SonarQube MCP server

OfficialSonar563Config last verified Jun 1, 2026

Sonar's official MCP server brings SonarQube code quality, security, and coverage analysis into your AI agent.

The SonarQube MCP Server is Sonar's official integration that connects an AI agent to SonarQube Cloud, SonarQube Server, and the local SonarQube for IDE analyzers. The agent can run analysis directly on a code snippet or on files in the working directory, then search the resulting issues, security hotspots, and software-composition-analysis dependency risks across your organization's projects. It can pull quality gate status, component measures, metrics, coverage details file by file, and code duplications so the model knows whether a change is shippable.

Beyond reading findings, the agent can change an issue's status, review a security hotspot, fetch raw source and SCM blame, list languages and quality gates, and manage webhooks. An advanced context-augmentation toolset (stdio mode, with the right entitlement) lets the agent trace call flows, inspect type hierarchies, query architecture graphs, and check third-party dependencies for vulnerabilities. The canonical setup runs the published mcp/sonarqube Docker image over stdio, authenticating with a token in SONARQUBE_TOKEN plus either SONARQUBE_ORG for SonarQube Cloud or SONARQUBE_URL for a self-hosted SonarQube Server.

Quick install

Copy-paste configs are provided for all 8 supported clients. Pick your client below.

Add to ~/.claude.json

~/.claude.json
json
{
  "mcpServers": {
    "sonarqube": {
      "command": "docker",
      "args": [
        "run",
        "--init",
        "--pull=always",
        "-i",
        "--rm",
        "-e",
        "SONARQUBE_TOKEN",
        "-e",
        "SONARQUBE_ORG",
        "mcp/sonarqube"
      ],
      "env": {
        "SONARQUBE_TOKEN": "<SONARQUBE_TOKEN>",
        "SONARQUBE_ORG": "<SONARQUBE_ORG>"
      }
    }
  }
}
Or via CLI
bash
claude mcp add sonarqube -- docker run --init --pull=always -i --rm -e SONARQUBE_TOKEN -e SONARQUBE_ORG mcp/sonarqube

Available tools

ToolDescription
analyze_code_snippetAnalyzes file content with SonarQube analyzers to identify code quality and security issues.
analyze_file_listAnalyzes files in the current working directory using SonarQube for IDE.
toggle_automatic_analysisEnables or disables SonarQube for IDE automatic analysis.
run_advanced_code_analysisRuns advanced code analysis on SonarQube Cloud for a single file.
search_files_by_coverageSearches for files in a project sorted by test coverage.
get_file_coverage_detailsGets line-by-line coverage information for a specific file.
search_dependency_risksSearches for software composition analysis (SCA) dependency risks.
list_enterprisesLists the enterprises available in SonarQube Cloud.
change_sonar_issue_statusChanges the status of a SonarQube issue.
search_sonar_issues_in_projectsSearches for SonarQube issues across your organization's projects.
search_security_hotspotsSearches for security hotspots in a SonarQube project.
show_security_hotspotGets detailed information about a specific security hotspot.
change_security_hotspot_statusReviews a security hotspot by changing its status.
list_languagesLists all programming languages supported in this SonarQube instance.
get_component_measuresGets SonarQube measures for a component.
search_metricsSearches for SonarQube metrics.
list_portfoliosLists the enterprise portfolios available in SonarQube.
search_my_sonarqube_projectsFinds SonarQube projects you have access to.
list_pull_requestsLists all pull requests for a project.
get_project_quality_gate_statusGets the quality gate status for a SonarQube project.
list_quality_gatesLists all quality gates in your SonarQube instance.
show_ruleShows detailed information about a SonarQube rule.
search_duplicated_filesSearches for files with code duplications in a SonarQube project.
get_duplicationsGets code duplications for a file.
get_raw_sourceGets source code as raw text from SonarQube.
get_scm_infoGets SCM (blame) information for SonarQube source files.
get_system_healthGets the health status of a SonarQube Server instance.
get_system_infoGets detailed SonarQube Server system configuration information.
get_system_logsGets SonarQube Server system logs in plain text.
ping_systemPings the SonarQube Server system to check if it is alive.
get_system_statusGets state information about a SonarQube Server instance.
create_webhookCreates a new webhook for the SonarQube organization or project.
list_webhooksLists all webhooks for the SonarQube organization or project.
search_by_signature_patternsFinds code elements by their declaration signatures using regex patterns.
search_by_body_patternsFinds code elements by their implementation body using regex patterns.
get_upstream_call_flowTraces what functions call a given function.
get_downstream_call_flowTraces what functions a given function calls.
get_source_codeGets complete source code for a code element by its fully qualified name.
get_type_hierarchyGets the full inheritance hierarchy for a class-like structure.
get_referencesGets direct inbound and outbound code references for a class or module.
get_current_architectureGets a hierarchical architecture graph filtered by path prefix and depth.
get_intended_architectureGets user-defined architectural constraints specifying module dependencies.
get_guidelinesGets coding guidelines derived from a SonarQube project's issues.
check_dependencyChecks a third-party dependency for security vulnerabilities.

Required configuration

  • SONARQUBE_TOKENRequired

    SonarQube Cloud or Server token used to authenticate API calls.

  • SONARQUBE_ORGOptional

    Your SonarQube Cloud organization key. Required for SonarQube Cloud.

  • SONARQUBE_URLOptional

    URL of your SonarQube Server instance. Use instead of SONARQUBE_ORG for self-hosted SonarQube Server; defaults to https://sonarcloud.io.

  • STORAGE_PATHOptional

    Directory for the server's file storage. Mandatory when running the JAR build instead of Docker.

  • SONARQUBE_PROJECT_KEYOptional

    Default project key, which removes the project parameter from tool calls.

  • SONARQUBE_READ_ONLYOptional

    Restricts the server to read-only tools when enabled.

What you can do with it

Gate a change on quality before merge

Before opening a PR, the agent checks the project's quality gate status, coverage, and any new issues introduced, so it only ships code that passes Sonar's bar.

Fix the issues Sonar found

The agent searches open issues and security hotspots in a project, reads the rule explanation, applies a fix in the codebase, then updates the issue status.

FAQ

Is it free?
The MCP server is free and open source from SonarSource. It works with your existing SonarQube plan: SonarQube Cloud has a free tier for public projects, and SonarQube Server Community Edition is free to self-host.
Does it support remote/OAuth?
No. It runs locally over stdio via the mcp/sonarqube Docker image (or a JAR), authenticating with a token in SONARQUBE_TOKEN; there is no hosted remote endpoint or OAuth flow.
Does it work with both SonarQube Cloud and self-hosted Server?
Yes. For SonarQube Cloud set SONARQUBE_TOKEN and SONARQUBE_ORG; for a self-hosted SonarQube Server set SONARQUBE_TOKEN and SONARQUBE_URL pointing at your instance.
← Browse all devops-ci servers