
SonarQube MCP Server
Official SonarQube MCP server: bring code quality, security, and coverage analysis from SonarQube Server or Cloud into AI agents.
Add to your client
Copy the config for your MCP client and paste it into its config file.
docker pull sonarsource/sonarqube-mcpPaste into ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"sonarqube-mcp-server": {
"command": "docker",
"args": [
"run",
"--init",
"--pull=always",
"-i",
"--rm",
"-e",
"SONARQUBE_TOKEN",
"-e",
"SONARQUBE_ORG",
"sonarsource/sonarqube-mcp"
],
"env": {
"SONARQUBE_TOKEN": "<your-token>",
"SONARQUBE_ORG": "<your-org>"
}
}
}
}Requires Docker to be installed and running.
Step-by-step guides: Add to Claude Desktop · Add to Cursor · Add to Windsurf
Before you start
- Docker (or another OCI-compatible runtime such as Podman/nerdctl), or Java 21+ to run the standalone JAR
- A SonarQube Cloud or SonarQube Server account
- A SonarQube token (SONARQUBE_TOKEN); for SonarQube Server it must be a USER token
- For SonarQube Cloud: your organization key (SONARQUBE_ORG); for SonarQube Server: your server URL (SONARQUBE_URL)
About SonarQube MCP Server
Official SonarSource MCP server that integrates SonarQube Server or SonarQube Cloud with AI agents for code quality and security. It exposes tools to search/manage issues, review Security Hotspots, check quality gates, retrieve measures and metrics, find coverage gaps and duplications, analyze dependency risks (SCA), browse projects/branches/pull requests, and analyze code snippets or files directly in the agent context. Runs via the sonarsource/sonarqube-mcp container image (or a standalone JAR with Java 21+) and supports stdio and Streamable HTTP/HTTPS transports.
Tools & capabilities (48)
analyze_code_snippetAnalyze file content with SonarQube analyzers to identify code quality and security issues; optionally filter results to a specific code snippet. Reads from a mounted workspace via filePath, or accepts full fileContent.
analyze_file_listAnalyze files in the current working directory using a running SonarQube for IDE instance (available when SonarQube for IDE integration is enabled).
toggle_automatic_analysisEnable or disable SonarQube for IDE automatic analysis of files as they are modified.
run_advanced_code_analysisRun advanced code analysis on SonarQube Cloud for a single file (requires org entitlement and a mounted workspace).
search_files_by_coverageSearch for files in a project sorted by coverage (worst first) to identify files needing test coverage improvements.
get_file_coverage_detailsGet line-by-line coverage for a file, including uncovered lines and partially covered branches.
search_dependency_risksSearch software composition analysis (SCA) issues / dependency risks for a project, application, or portfolio (SonarQube Server Enterprise with Advanced Security).
list_enterprisesList enterprises available in SonarQube Cloud that you have access to (returns enterprise IDs for use with other tools).
change_sonar_issue_statusChange the status of a SonarQube issue to accept, falsepositive, or reopen.
search_sonar_issues_in_projectsSearch for SonarQube issues across your organization's projects, with filters for severity, software quality, status, branch, and pull request.
search_security_hotspotsSearch for Security Hotspots in a project, with filters for status, resolution, files, branch, and new-code period.
show_security_hotspotGet detailed information about a specific Security Hotspot, including rule details, code context, flows, and comments.
change_security_hotspot_statusReview a Security Hotspot by changing its status (TO_REVIEW / REVIEWED, with a resolution when reviewed).
list_languagesList all programming languages supported in the SonarQube instance.
get_component_measuresGet SonarQube measures for a component (project, directory, or file).
search_metricsSearch for SonarQube metrics (paginated).
list_portfoliosList enterprise portfolios available in SonarQube with filtering and pagination (Cloud and Server).
search_my_sonarqube_projectsFind SonarQube projects (paginated).
list_branchesList long-lived branches for a project (names safe for the branch parameter on other tools).
list_pull_requestsList all pull requests for a project; returns pull request keys/IDs usable with other tools.
get_project_quality_gate_statusGet the Quality Gate status for a SonarQube project (by branch, pull request, project key/ID, or analysis ID).
list_quality_gatesList all quality gates in your SonarQube instance.
show_ruleShow detailed information about a SonarQube rule by key.
search_duplicated_filesSearch for files with code duplications in a project (auto-paginates by default).
get_duplicationsGet duplications for a specific file (requires Browse permission on the file's project).
get_raw_sourceGet source code as raw text from SonarQube (requires See Source Code permission).
get_scm_infoGet SCM (commit) information for SonarQube source files.
get_system_healthGet the health status (GREEN/YELLOW/RED) of a SonarQube Server instance.
get_system_infoGet detailed SonarQube Server system configuration (JVM, database, search indexes, settings); requires Administer permissions.
get_system_logsGet SonarQube Server system logs in plain text (access, app, ce, deprecation, es, web).
ping_systemPing the SonarQube Server system to check if it's alive (returns 'pong').
get_system_statusGet state information about SonarQube Server (status, version, id).
create_webhookCreate a new webhook for a SonarQube organization or project (requires Administer permission).
list_webhooksList all webhooks for a SonarQube organization or project (requires Administer permission).
search_by_signature_patternsContext Augmentation: find code elements (classes, methods, interfaces) by their declaration signatures using regex patterns.
search_by_body_patternsContext Augmentation: find code elements by their implementation body using regex patterns.
get_upstream_call_flowContext Augmentation: trace what functions call a given function (callers and entry points).
get_downstream_call_flowContext Augmentation: trace what functions a given function calls (impact analysis and execution flow).
get_source_codeContext Augmentation: get complete source code (signature and body) for a code element by its fully qualified name.
get_type_hierarchyContext Augmentation: get the full inheritance hierarchy for a class-like structure.
get_referencesContext Augmentation: get direct inbound and outbound code references for a class or module.
get_current_architectureContext Augmentation: get a hierarchical architecture graph filtered by path prefix and depth.
get_intended_architectureContext Augmentation: get user-defined architectural constraints (allowed module dependencies).
get_guidelinesContext Augmentation: get coding guidelines based on project issues, catalog categories, or a combination.
check_dependencyContext Augmentation: check a third-party dependency (by purl) for security vulnerabilities, supply-chain malware, and license compliance.
start_agentic_readiness_assessmentStart an agentic readiness assessment for a project (SonarQube Cloud, requires org entitlement); returns an assessmentId.
get_agentic_readiness_assessmentRetrieve the result of an agentic readiness assessment by assessmentId (poll until completed).
list_agentic_readiness_assessmentsList all agentic readiness assessments for a project (newest first).
What this server can do
SonarQube MCP Server provides tools for these capabilities — tap one to see every MCP server that does the same:
When to use it
- Understand and fix a failing quality gate before merging a pull request or releasing
- Triage and fix the highest-priority issues, code smells, and security vulnerabilities flagged by SonarQube
- Identify files with the lowest test coverage and pinpoint exact uncovered lines to add tests
- Review Security Hotspots and dependency risks (SCA) to prepare for a security audit
- Analyze a code snippet or file on the fly for quality and security issues during code review
- Generate project health reports (quality gate status, bugs, hotspots, coverage) and compare branches
Security notes
Your SonarQube token is a sensitive credential. Avoid hardcoding tokens in command-line arguments (they are saved in shell history); prefer environment variables. Never commit tokens to version control, and use environment-variable substitution in config files. For SonarQube Server, the token must be a USER token (project or global tokens will not work). In Streamable HTTP/HTTPS mode the server is stateless and each request must carry the user's own token via an `Authorization: Bearer <token>` header; HTTPS with TLS is recommended for multi-user production deployments. The server collects anonymous usage telemetry (no source code or IP) which can be disabled with `TELEMETRY_DISABLED=true`.
SonarQube MCP Server FAQ
Do I connect to SonarQube Cloud or SonarQube Server?
Both are supported. In stdio mode the presence of SONARQUBE_ORG determines the target: if SONARQUBE_ORG is set, SonarQube Cloud is used; otherwise SonarQube Server is used (set SONARQUBE_URL to your server URL). For SonarQube Cloud US, set SONARQUBE_URL=https://sonarqube.us.
What token do I need?
A SonarQube token via SONARQUBE_TOKEN. For SonarQube Cloud, a personal/account token plus your organization key (SONARQUBE_ORG). For SonarQube Server, the token must be a USER token (project or global tokens will not work) plus your server URL (SONARQUBE_URL).
Can I run it without Docker?
Yes. You can download a pre-built standalone JAR from the SonarSource binaries repository and run it with `java -jar` using Java 21 or later (set STORAGE_PATH plus your token/org or URL). You can also build it from source with Gradle.
How do I limit which tools are exposed?
Use SONARQUBE_TOOLSETS to enable only specific toolsets (e.g. analysis,issues,quality-gates; the projects toolset is always enabled). Set SONARQUBE_READ_ONLY=true to disable all write operations. In Streamable HTTP mode these can also be sent as per-request headers to further narrow scope (but not expand it).
Does it support remote/multi-user deployments?
Yes. Set SONARQUBE_TRANSPORT=http or https to enable Streamable HTTP transport; clients connect to /mcp and must send their own token via an `Authorization: Bearer <token>` header. HTTPS with TLS is recommended for multi-user production deployments.
Alternatives to SonarQube MCP Server
Compare all alternatives →Microsoft's official browser-automation MCP using Playwright's accessibility tree (no vision model).
Up-to-date, version-specific library documentation injected into your coding agent.
Code intelligence engine that indexes repos into a persistent knowledge graph for AI coding agents.
Compare SonarQube MCP Server with: