
SonarQube MCP Server
io.github.SonarSource由 GitHub 帳號 SonarSource 發布v1.31.0更新於 Nov 3, 2026
在AI助理中直接使用SonarQube Server或Cloud分析程式碼質量與安全性。
AI 翻譯由 AI 模型根據下方的原文描述翻譯,可能有誤。
原文描述
Analyze code quality and security with SonarQube Server or Cloud directly in AI assistants.
概覽
SonarQube 的本機 MCP 服務;無需登入;STDIO。
暫無 AI 概覽:以下資訊來自註冊中心條目和服務本身。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 SonarQube MCP Server,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
SonarQube MCP Server
The SonarQube MCP Server is a Model Context Protocol (MCP) server that enables seamless integration with SonarQube Server or Cloud for code quality and security. It also supports the analysis of code snippet directly within the agent context.
Start with the quick setup, or learn more about the SonarQube product family.
Quick setup
Security best practices
🔒 Important: Your SonarQube token is a sensitive credential. Follow these security practices:
When using CLI commands:
- Avoid hardcoding tokens in command-line arguments – they get saved in shell history
- Use environment variables – set tokens in environment variables before running commands
When using configuration files:
- Never commit tokens to version control
- Use environment variable substitution in config files when possible
🚀 Generate your configuration
The fastest way to get started is the SonarQube MCP Server Configuration Generator – an interactive tool that produces a ready-to-use configuration for your preferred AI agent client.
Manual setup
If you prefer to configure things yourself, the simplest method is to use our container image at sonarsource/sonarqube-mcp. Use sonarsource/sonarqube-mcp for automatic updates (with --pull=always), or pin to a version tag (e.g., sonarsource/sonarqube-mcp:1.19.0.2785) for reproducible deployments. Some releases are also tagged with the SonarQube Server version they are aligned with, in the form <SQS major>.<SQS minor>.<patch> (e.g., sonarsource/sonarqube-mcp:2026.5.0), where the patch number is incremented for each MCP release targeting that SonarQube Server version. Read below if you want to build it locally.
Note: While the examples below use
docker, any OCI-compatible container runtime works (e.g., Podman, nerdctl). Simply replacedockerwith your preferred tool.
Antigravity
SonarQube MCP Server is available in the Antigravity MCP Store. Follow these instructions:
- Open the Agent Side Panel
- Click the three dots (...) at the top right and select MCP Servers
- Search for
SonarQubeand select Install - Provide the required SonarQube User token. You can also provide your organization key for SonarQube Cloud or the SonarQube URL if connecting to SonarQube Server.
For SonarQube Cloud US, set the URL to https://sonarqube.us.
Alternatively, you can manually configure the server via mcp_config.json:
- To connect with SonarQube Cloud:
In the Agent Side Panel, click the three dots (...) -> MCP Store -> Manage MCP Servers -> View raw config, and add the following:
For SonarQube Cloud US, manually add "SONARQUBE_URL": "https://sonarqube.us" to the env section and "-e", "SONARQUBE_URL" to the args array.
- To connect with SonarQube Server:
Claude Code
- To connect with SonarQube Cloud:
For SonarQube Cloud US, add --env SONARQUBE_URL=https://sonarqube.us to the command.
- To connect with SonarQube Server:
Codex CLI
Manually edit the configuration file at ~/.codex/config.toml and add the following configuration:
- To connect with SonarQube Cloud:
For SonarQube Cloud US, add "SONARQUBE_URL" = "https://sonarqube.us" to the env section and "-e", "SONARQUBE_URL" to the args array.
- To connect with SonarQube Server:
Cursor
- To connect with SonarQube Cloud:
For SonarQube Cloud US, manually add "SONARQUBE_URL": "https://sonarqube.us" to the env section in your MCP configuration after installation.
- To connect with SonarQube Server:
Gemini CLI
Note: The Gemini CLI extension has moved to the sonarqube-agent-plugins repository. Please install it from there going forward.
You can install our MCP server extension by using the following command:
You will need to set the required environment variables before starting Gemini:
Environment Variables Required:
-
For SonarQube Cloud:
SONARQUBE_TOKEN- Your SonarQube Cloud tokenSONARQUBE_ORG- Your organization keySONARQUBE_URL- (Optional) Set tohttps://sonarqube.usfor SonarQube Cloud US
-
For SonarQube Server:
SONARQUBE_TOKEN- Your SonarQube Server USER tokenSONARQUBE_URL- Your SonarQube Server URL
Once installed, the extension will be installed under <home>/.gemini/extensions/sonarqube/gemini-extension.json.
GitHub Copilot CLI
After starting Copilot CLI, run the following command to add the SonarQube MCP server:
You will have to provide different information about the MCP server, you can use tab to navigate between fields.
- To connect with SonarQube Cloud:
For SonarQube Cloud US, add -e, SONARQUBE_URL to Arguments and SONARQUBE_URL=https://sonarqube.us to Environment Variables.
- To connect with SonarQube Server:
The configuration file is located at ~/.copilot/mcp-config.json.
GitHub Copilot coding agent
GitHub Copilot coding agent can leverage the SonarQube MCP server directly in your CI/CD.
To add the secrets to your Copilot environment, follow the Copilot documentation. Only secrets with names prefixed with COPILOT_MCP_ will be available to your MCP configuration.
In your GitHub repository, navigate under Settings -> Copilot -> Coding agent, and add the following configuration in the MCP configuration section:
- To connect with SonarQube Cloud:
For SonarQube Cloud US, add "-e", "SONARQUBE_URL" to the args array and "SONARQUBE_URL": "COPILOT_MCP_SONARQUBE_URL" to the env section, then set the secret COPILOT_MCP_SONARQUBE_URL=https://sonarqube.us.
- To connect with SonarQube Server:
Kiro
Create a .kiro/settings/mcp.json file in your workspace directory (or edit if it already exists), add the following configuration:
- To connect with SonarQube Cloud:
For SonarQube Cloud US, add "-e", "SONARQUBE_URL" to the args array and "SONARQUBE_URL": "https://sonarqube.us" to the env section.
- To connect with SonarQube Server:
VS Code
You can use the following buttons to simplify the installation process within VS Code.
For SonarQube Cloud US, manually add "SONARQUBE_URL": "https://sonarqube.us" to the env section in your MCP configuration after installation.
Windsurf
SonarQube MCP Server is available as a Windsurf plugin. Follow these instructions:
- Open Windsurf Settings > Cascade > MCP Servers and select Open MCP Marketplace
- Search for
sonarqubeon the Cascade MCP Marketplace - Choose the SonarQube MCP Server and select Install
- Add the required SonarQube User token. Optionally add a default organization key for SonarQube Cloud, or add the SonarQube URL for SonarQube Server or Community Build.
For SonarQube Cloud US, set the URL to https://sonarqube.us.
Zed
Navigate to the Extensions view in Zed and search for SonarQube MCP Server. When installing the extension, you will be prompted to provide the necessary environment variables:
- When using SonarQube Cloud:
For SonarQube Cloud US, add "sonarqube_url": "https://sonarqube.us" to the configuration.
- When using SonarQube Server:
The docker_path is the path to a docker executable. Examples:
Linux/macOS: /usr/bin/docker or /usr/local/bin/docker
Windows: C:\Program Files\Docker\Docker\resources\bin\docker.exe
💡 Tip: We recommend pulling the latest image regularly or before reporting issues to ensure you have the most up-to-date features and fixes.
Manual installation
You can manually install the SonarQube MCP server by copying the following snippet in the MCP servers configuration file:
- To connect with SonarQube Cloud:
- To connect with SonarQube Server:
Integration with SonarQube for IDE
The SonarQube MCP Server can integrate with SonarQube for IDE to further enhance your development workflow, providing better code analysis and insights directly within your IDE.
Configuration
When using SonarQube for IDE, the SONARQUBE_IDE_PORT environment variable should be set with the correct port number. SonarQube for VS Code includes a Quick Install button, which automatically sets the correct port configuration.
For example, with SonarQube Cloud:
When running the MCP server in a container on Linux, the container cannot access the SonarQube for IDE embedded server running on localhost. To allow the container to connect to the SonarQube for IDE server, add the
--network=hostoption to your container run command.
Configuration
Depending on your environment, you should provide specific environment variables.
Base
You should add the following variable when running the MCP Server:
Workspace Mount (Reducing Context Bloat)
By default, analysis tool analyze_code_snippet requires the agent to pass the full file content as a fileContent argument. For large files or when analyzing many files in a session, this significantly increases context window usage and cost.
Solution: mount your project directory into the container at /app/mcp-workspace. When this mount is detected, the server reads files directly from disk using the project-relative filePath argument — file content never passes through the agent context.
With a mount, analysis tools read files directly using filePath; fileContent is not needed.
Over stdio, analysis is selected at startup (subject to enabled toolsets):
- SonarQube Cloud: Vortex analysis (
run_advanced_code_analysis) with a workspace mount and at least one entitled organization; local analysis otherwise. Vortex analysis only accepts entitled organizations. - SonarQube Server: Vortex analysis for entitled instances (requires a workspace mount); local analysis for instances without Vortex.
Local analysis uses SonarQube for IDE if connected or analyze_code_snippet. Without a mount, snippet analysis requires fileContent.
On Cloud, SONARQUBE_ORG limits the entitlement check to that organization. To use snippets for all organizations, set SONARQUBE_FORCE_LOCAL_ANALYSIS=true, enable the analysis toolset, and restart. This setting has no effect on Server.
Over HTTP/HTTPS, Server supports snippet analysis with a startup SONARQUBE_TOKEN; Cloud exposes no analysis tools.
Selective Tool Enablement
MCP clients load every enabled tool — its name, description, and input schema — into the agent's context on every conversation. Limiting that list with SONARQUBE_TOOLSETS cuts context usage and the token cost of each session.
By default, only important toolsets are enabled. Enable additional toolsets only when you need them.
Available Toolsets
Examples
Enable analysis, issues, and quality gates toolsets (using Docker with SonarQube Cloud):
Note: The projects toolset is always enabled automatically, so you don't need to include it in SONARQUBE_TOOLSETS.
Enable read-only mode (using Docker with SonarQube Cloud):
SonarQube Cloud
For stdio, configure the following environment variables:
Examples:
- SonarQube Cloud: Only
SONARQUBE_TOKENis required.SONARQUBE_ORGfixes the organization when set. - SonarQube Cloud US: Set
SONARQUBE_TOKENandSONARQUBE_URL=https://sonarqube.us;SONARQUBE_ORGis optional.
SonarQube Server
Version requirement: SonarQube Server 2025.1 (SQS) or 25.1 (SonarQube Community Build) or later is required. At startup, the MCP server reads the connected instance version and exits with an error if it is too old (for example, legacy 9.x/10.x Server releases and Community Build 24.x are not supported). SonarQube Cloud is not subject to this check.
⚠️ Connection to SonarQube Server requires a token of type USER and will not function properly if project tokens or global tokens are used.
💡 Configuration Tip (stdio mode): A token without a URL defaults to SonarQube Cloud. Set
SONARQUBE_URLfor SonarQube Server or a different Cloud region.SONARQUBE_ORGfixes the Cloud organization when set.
In stdio, setting SONARQUBE_ORG fixes the Cloud organization. Tool organization arguments are omitted from schemas and rejected, like projectKey when SONARQUBE_PROJECT_KEY is set.
With SONARQUBE_ORG unset, agents can call list_organizations to discover organization keys, names, IDs, and UUIDs accessible to your user account, then pass a key as the optional organization argument on organization-aware tools. Stdio retains a uniquely detected organization as its default; zero or multiple organizations leave it unresolved. A tool argument applies only to that call and never changes the detected default. Snippet profile and rule lookups use the organization selected for that call.
For HTTP/HTTPS token requests, server-level SONARQUBE_ORG remains supported for compatibility but is deprecated and logs a startup warning. It fixes the organization for every request and rejects client organization headers and tool organization arguments. When no server organization is configured, an optional client SONARQUBE_ORG header fixes the organization for that request and disallows tool organization arguments. Without the header, use the tool argument. Tools that require an organization report discovery guidance when all are missing. Organization discovery and tools whose APIs consume only resource identifiers do not require an organization argument. Organization-aware issue search and dependency-risk entitlement checks use the selected organization. When OAuth is configured, server-level SONARQUBE_ORG is rejected. OAuth requests also reject organization headers; select organizations through tool arguments.
Vortex context tools use the configured or uniquely detected startup organization. Runtime organization arguments do not reconfigure the proxied context engine; unresolved startup organizations skip that proxy. The built-in run_advanced_code_analysis tool checks combined Vortex entitlement for the organization selected on each invocation.
Transport Modes
The MCP specification defines two transport mechanisms: Stdio and Streamable HTTP. The SonarQube MCP Server supports both:
Note: Streamable HTTP is the current MCP network transport. The older SSE-only HTTP transport from earlier MCP versions is deprecated and not supported.
1. Stdio (Default - Recommended for Local Development)
The recommended mode for local development and single-user setups, used by most MCP clients.
Example - Docker with SonarQube Cloud:
2. HTTP (Streamable HTTP)
Unencrypted Streamable HTTP transport. Use HTTPS instead for multi-user deployments.
⚠️ Not Recommended: Use Stdio for local development or HTTPS (Streamable HTTP) for multi-user production deployments.
Note: HTTP/HTTPS accepts the user's SonarQube token through Authorization: Bearer <token>. Sonar's hosted Cloud service also supports OAuth. For SonarQube Cloud token requests, the organization is resolved as follows:
SONARQUBE_ORGis an optional request header that fixes the organization for that request. Deprecated server-level configuration fixes it for all requests and rejects client organization headers and tool organization arguments.- Organization-aware tools accept an optional
organizationargument when neither server configuration nor the request header fixes the organization. Supplying the argument when the organization is fixed is rejected. - Without a default, agents can call
list_organizationsusing only their token, then pass the chosen key to subsequent tools.
Clients can also narrow the visible tools per-request by supplying SONARQUBE_TOOLSETS and/or SONARQUBE_READ_ONLY headers; these apply additional filtering on top of the server-level configuration — they can only reduce the scope, never expand it.
No session state is maintained between requests.
Deprecated: For SonarQube tokens, the
SONARQUBE_TOKENrequest header is still accepted for backward compatibility but will be removed in a future version. Migrate toAuthorization: Bearer <token>.
3. HTTPS (Streamable HTTP over TLS) (Recommended for Multi-User Production Deployments)
Secure Streamable HTTP transport with TLS encryption. Requires SSL certificates.
✅ Recommended for Production: Use HTTPS when deploying the MCP server for multiple users over Streamable HTTP. The server binds to
127.0.0.1(localhost) by default for security.
SSL Certificate Configuration (Optional):
Example - Docker with SonarQube Cloud:
Note: When running in a container, set
SONARQUBE_HTTP_HOST=0.0.0.0so the container listens on all interfaces and the runtime's port mapping works, and setSONARQUBE_MCP_IN_CONTAINER=trueto tell the server it is inside a container. The official Docker image sets the latter automatically; set it yourself when using other OCI runtimes (Podman, Kubernetes, Nomad, etc.). The host-side port flag controls who can reach the server from outside the container.SONARQUBE_HTTP_HOST=0.0.0.0only controls where the server listens inside the container — browser CORS still allows localhost origins by default.
For a server running locally on your machine (accessible only from localhost):
For a server accessible from the network (remote deployments):
Client Configuration (SonarQube Cloud):
For SonarQube token requests, optionally set SONARQUBE_ORG in client headers to fix the request organization, or omit it to select organizations through tool arguments.
Client Configuration (SonarQube Server):
Note:
SONARQUBE_TOOLSETSandSONARQUBE_READ_ONLYare optional per-request headers that narrow the server-level tool set for that specific request. They can only reduce scope — they cannot enable toolsets or lift restrictions beyond what the server was launched with.
Note: For local development, use Stdio transport instead (the default). HTTPS Streamable HTTP is intended for multi-user production deployments with proper SSL certificates.
Hosted SonarQube Cloud OAuth
OAuth support targets Sonar's hosted SonarQube Cloud MCP service. Use an OAuth-capable MCP client and sign in when prompted; no OAuth server settings are needed in your client configuration. Existing SonarQube token clients remain supported.
The mcp:tools:read and mcp:tools:write scopes independently control access to read and write tools, subject to your Cloud permissions. Use list_organizations and tool organization arguments to select an organization.
Self-hosted deployments continue to use SonarQube tokens; OAuth for SonarQube Server is not supported yet.
Service Endpoints
When running in Streamable HTTP mode (http or https), the server exposes a few unauthenticated service endpoints in addition to the MCP endpoint at /mcp. These are intended for service-to-service use (monitoring, orchestration, client compatibility checks) and do not require an Authorization header.
These endpoints are not available when running with the Stdio transport.
Custom Certificates
If your SonarQube Server uses a self-signed certificate or a certificate from a private Certificate Authority (CA), you can add custom certificates to the container that will automatically be installed.
Configuration
Using Volume Mount
Mount a directory containing your certificates when running the container:
Supported Certificate Formats
The container supports the following certificate formats:
.crtfiles (PEM or DER encoded).pemfiles (PEM encoded)
MCP Configuration with Certificates
When using custom certificates, you can modify your MCP configuration to mount the certificates:
Note: Running the server from a JAR instead of the container? The volume mount above installs certificates into the container's OS trust store, which the server also reads. If you cannot use the OS trust store — notably on Windows, where it is not consulted — point the JVM at a Java truststore holding the CA certificate:
-Djavax.net.ssl.trustStore=/path/to/truststore.p12 -Djavax.net.ssl.trustStoreType=PKCS12 -Djavax.net.ssl.trustStorePassword=<passphrase>. It is added on top of the default trusted certificates.
Proxy
The SonarQube MCP Server supports HTTP and SOCKS5 proxies through standard Java proxy system properties.
Configuration
HTTP/HTTPS Proxy
You can configure proxy settings using Java system properties. These can be set as environment variables or passed as JVM arguments.
Common Proxy Properties:
HTTP/HTTPS Proxy Authentication:
SOCKS5 Proxy
SOCKS5 proxies are supported.
Client Certificate (Mutual TLS)
If your SonarQube Server requires clients to present a certificate during the TLS handshake (mutual TLS), you can provide a PKCS12 keystore by mounting it into the container and passing its location via JAVA_OPTS.
Configuration
Using a PKCS12 keystore
Mount your .p12 or .pfx file into the container and set the JAVA_OPTS environment variable with the keystore properties:
Note: The certificate file must be readable by the container process. Check and fix permissions if needed:
Omit -Djavax.net.ssl.keyStorePassword if the keystore has no passphrase. Note that the passphrase used here would be visible through docker inspect or process list.
MCP Configuration with a Client Certificate
Using a PKCS12 keystore with a standalone JAR
When running the server from a JAR, pass the keystore properties as JVM arguments before -jar:
Omit -Djavax.net.ssl.keyStorePassword if the keystore has no passphrase.
MCP Configuration with a Client Certificate (JAR)
Note: PEM certificate and key files (separate
.crt/.keyfiles) must be converted to PKCS12 format first. Useopenssl pkcs12 -export -in client.crt -inkey client.key -out client.p12to convert them.
Tools
Analysis
-
analyze_code_snippet - Analyze file content with SonarQube analyzers to identify code quality and security issues. Always analyzes the complete file content for accuracy. Optionally filter results to a specific code snippet.
Deprecated:
analyze_code_snippetwill be removed in a future release. Connect SonarQube for IDE to useanalyze_file_list, or enable Vortex analysis for your organization to userun_advanced_code_analysis(see below).Usage:
- With workspace mounted (recommended): pass
filePath(project-relative) — the server reads the file directly, keeping file content out of the agent context window - Without workspace mount: pass complete
fileContentfor full file analysis (reports all issues) - Add optional
codeSnippetto filter results - only issues within the snippet will be reported (snippet location auto-detected)
Parameters:
organization- SonarQube Cloud organization key - Optional String, Cloud onlyprojectKey- The SonarQube project key - Required String (Ignored whenSONARQUBE_PROJECT_KEYis defined)filePath- Project-relative path of the file to analyze (e.g.,src/main/java/MyClass.java). Used when the workspace is mounted at/app/mcp-workspace- StringfileContent- Complete file content as a string. Required when workspace is not mounted - StringcodeSnippet- Code snippet to filter issues (must match content in fileContent) - Stringlanguage- Language of the code (e.g., 'java', 'python', 'js', 'ts', 'tsx', 'jsx') - Stringscope- Scope of the file: MAIN or TEST (default: MAIN) - String
Supported Languages: Java, Kotlin, Python, Ruby, Go, JavaScript (
js,jsx), TypeScript (ts,tsx), JSP, PHP, XML, HTML, CSS, CloudFormation, Kubernetes, Terraform, Azure Resource Manager, Ansible, Docker, Secrets detection - With workspace mounted (recommended): pass
When integration with SonarQube for IDE is enabled: (these two tools are tagged under both the analysis and ide toolsets)
-
analyze_file_list - Analyze files in the current working directory using SonarQube for IDE. This tool connects to a running SonarQube for IDE instance to perform code quality analysis on a list of files.
file_absolute_paths- List of absolute file paths to analyze - Required String[]
-
toggle_automatic_analysis - Enable or disable SonarQube for IDE automatic analysis. When enabled, SonarQube for IDE will automatically analyze files as they are modified in the working directory. When disabled, automatic analysis is turned off.
enabled- Enable or disable the automatic analysis - Required Boolean
On SonarQube Server, stdio lists Vortex context tools and run_advanced_code_analysis when both the CAG and A3S hubs are entitled.
When Vortex analysis is available:
Requires having the workspace mounted at
/app/mcp-workspace
- run_advanced_code_analysis - Run Vortex analysis on a single file. SonarQube Server uses the nil UUID placeholder.
organization- SonarQube Cloud organization key - Optional String, Cloud onlyprojectKey- The key of the project - Required String (Ignored whenSONARQUBE_PROJECT_KEYis defined)branch- Branch name used to retrieve the latest analysis context - Required StringfilePath- Project-relative path of the file to analyze (e.g.,src/main/java/MyClass.java). - Required StringfileScope- Defines in which scope the file originates from: 'MAIN' or 'TEST' (default: MAIN) - String
Coverage
-
search_files_by_coverage - Search for files in a project sorted by coverage (ascending - worst coverage first). This tool helps identify files that need test coverage improvements.
projectKey- The project key to search in - Required String (Ignored whenSONARQUBE_PROJECT_KEYis defined)branch- Optional branch name for branch-based analysis. Uselist_branchesto discover valid names - StringpullRequest- Optional pull request key/ID. Uselist_pull_requeststo discover valid keys - StringmaxCoverage- Maximum coverage threshold (0-100). Only return files with coverage <= this value - NumberpageIndex- Page index (1-based, default: 1) - NumberpageSize- Page size (default: 100, max: 500) - Number
-
get_file_coverage_details - Get line-by-line coverage information for a specific file, including which exact lines are uncovered and which have partially covered branches. This tool helps identify precisely where to add test coverage. Use after identifying files with low coverage via search_files_by_coverage.
key- File key (e.g. my_project:src/foo/Bar.java) - Required Stringbranch- Optional branch name for branch-based analysis. Uselist_branchesto discover valid names - StringpullRequest- Optional pull request key/ID. Uselist_pull_requeststo discover valid keys - Stringfrom- First line to analyze (1-based, default: 1) - Numberto- Last line to analyze (inclusive). If not specified, all lines are returned - Number
Dependency Risks
Note: Dependency risks require SonarQube Advanced Security. On SonarQube Server, version 2025.4 Enterprise or higher is required.
- search_dependency_risks - Search for software composition analysis issues (dependency risks) of a SonarQube project, paired with releases that appear in the analyzed project, application, or portfolio.
organization- SonarQube Cloud organization key - Optional String, Cloud onlyprojectKey- Project key - Required String (Ignored whenSONARQUBE_PROJECT_KEYis defined)branch- Optional branch name for branch-based analysis. Uselist_branchesto discover valid names - StringpullRequest- Optional pull request key/ID. Uselist_pull_requeststo discover valid keys - StringpageIndex- Optional page index (1-based, default: 1) - IntegerpageSize- Optional page size. Must be greater than 0 and less than or equal to 500 (default: 100) - Integer
Enterprises
Note: Enterprises are only available when connecting to SonarQube Cloud.
- list_enterprises - List the enterprises available in SonarQube Cloud that you have access to. Use this tool to discover enterprise IDs that can be used with other tools.
enterpriseKey- Optional enterprise key to filter results - String
Issues
-
change_sonar_issue_status - Change the status of a SonarQube issue to "accept", "falsepositive" or to "reopen" an issue.
key- Issue key - Required Stringstatus- New issue's status - Required Enum {"accept", "falsepositive", "reopen"}comment- Optional comment explaining the status change - String
-
search_sonar_issues_in_projects - Search for SonarQube issues in my organization's projects.
organization- SonarQube Cloud organization key - Optional String, Cloud onlyprojectKeys- Optional list of SonarQube project keys - String[]branch- Optional branch name for branch-based analysis. Uselist_branchesto discover valid names - StringpullRequest- Optional pull request key/ID. Uselist_pull_requeststo discover valid keys - Stringseverities- Optional list of severities to filter by. Possible values: INFO, LOW, MEDIUM, HIGH, BLOCKER - String[]impactSoftwareQualities- Optional list of software qualities to filter by. Possible values: MAINTAINABILITY, RELIABILITY, SECURITY - String[]issueStatuses- Optional list of issue statuses to filter by. Possible values: OPEN, CONFIRMED, FALSE_POSITIVE, ACCEPTED, FIXED, IN_SANDBOX - String[]tags- Optional list of issue tags to filter by. Tags are lowercase - String[]inNewCodePeriod- Only return issues in the new code period. Requires exactly one entry acrossprojectKeysandfiles- BooleanissueKey- Optional issue key to fetch a specific issue - StringpageIndex- Optional 1-based page index (default: 1) - IntegerpageSize- Optional page size. Must be greater than 0 and less than or equal to 500 (default: 100) - Integer
Security Hotspots
-
search_security_hotspots - Search for Security Hotspots in a SonarQube project.
projectKey- Project or application key - Required String (Ignored whenSONARQUBE_PROJECT_KEYis defined)hotspotKeys- Comma-separated list of specific Security Hotspot keys to retrieve - String[]branch- Optional branch name for branch-based analysis. Uselist_branchesto discover valid names - StringpullRequest- Optional pull request key/ID. Uselist_pull_requeststo discover valid keys - Stringfiles- Optional list of file paths to filter - String[]status- Optional status filter: TO_REVIEW, REVIEWED - Stringresolution- Optional resolution filter: FIXED, SAFE, ACKNOWLEDGED - StringsinceLeakPeriod- Filter hotspots created since the leak period (new code) - BooleanonlyMine- Show only hotspots assigned to me - BooleanpageIndex- Optional 1-based page index (default: 1) - IntegerpageSize- Optional page size. Must be greater than 0 and less than or equal to 500 (default: 100) - Integer
-
show_security_hotspot - Get detailed information about a specific Security Hotspot, including rule details, code context, flows, and comments.
hotspotKey- Security Hotspot key - Required String
-
change_security_hotspot_status - Review a Security Hotspot by changing its status. When marking as REVIEWED, you must specify a resolution (FIXED, SAFE, or ACKNOWLEDGED).
hotspotKey- Security Hotspot key - Required Stringstatus- New status - Required Enum {"TO_REVIEW", "REVIEWED"}resolution- Resolution when status is REVIEWED - Enum {"FIXED", "SAFE", "ACKNOWLEDGED"}comment- Optional review comment - String
Languages
- list_languages - List all programming languages supported in this SonarQube instance.
q- Optional pattern to match language keys/names against - String
Measures
- get_component_measures - Get SonarQube measures for a component (project, directory, file).
projectKey- The project key - Required String whenSONARQUBE_PROJECT_KEYis not configuredbranch- Optional branch name for branch-based analysis. Uselist_branchesto discover valid names - StringmetricKeys- Optional metric keys to retrieve (e.g. ncloc, complexity, violations, coverage) - String[]pullRequest- Optional pull request key/ID. Uselist_pull_requeststo discover valid keys - String
Metrics
- search_metrics - Search for SonarQube metrics.
pageIndex- Optional 1-based page index (default: 1) - IntegerpageSize- Optional page size. Must be greater than 0 and less than or equal to 500 (default: 100) - Integer
Portfolios
-
list_portfolios - List enterprise portfolios available in SonarQube with filtering and pagination options.
For SonarQube Server:
q- Optional search query to filter portfolios by name or key - Stringfavorite- If true, only returns favorite portfolios - BooleanpageIndex- Optional 1-based page number (default: 1) - IntegerpageSize- Optional page size, max 500 (default: 100) - Integer
For SonarQube Cloud:
enterpriseId- Enterprise uuid. Can be omitted only if 'favorite' parameter is supplied with value true - Stringq- Optional search query to filter portfolios by name - Stringfavorite- Required to be true if 'enterpriseId' parameter is omitted. If true, only returns portfolios favorited by the logged-in user. Cannot be true when 'draft' is true - Booleandraft- If true, only returns drafts created by the logged-in user. Cannot be true when 'favorite' is true - BooleanpageIndex- Optional index of the page to fetch (default: 1) - IntegerpageSize- Optional size of the page to fetch (default: 50) - Integer
Projects
-
list_organizations - List SonarQube Cloud organizations that a user is a member of, including keys, names, IDs, and UUIDs. Use a returned key as
organizationon subsequent tools. -
search_my_sonarqube_projects - Find SonarQube projects. The response is paginated.
organization- SonarQube Cloud organization key - Optional String, Cloud onlypageIndex- Optional 1-based page index (default: 1) - IntegerpageSize- Optional page size. Must be greater than 0 and less than or equal to 500 (default: 500) - Integerq- Optional search query to filter projects by name (partial match) or key (exact match) - String
-
list_branches - List analyzed branches for a project.
- SonarQube Cloud: returns long-lived (
LONG) and short-lived (SHORT) branches withtypeandmergeBranchfields. OptionalbranchTypesfilter:ALL(default),LONG, orSHORT. - SonarQube Server: returns all analyzed branches (name, quality gate, analysis date). No
type,mergeBranch, orbranchTypesfilter. - Use returned branch names as the
branchparameter on other tools. For pull request analysis, uselist_pull_requestsinstead. projectKey- Project key (e.g. my_project) - Required String (Ignored whenSONARQUBE_PROJECT_KEYis defined)branchTypes- (SonarQube Cloud only) Optional filter:ALL(default),LONG, orSHORT- Enum {"ALL", "LONG", "SHORT"}
- SonarQube Cloud: returns long-lived (
-
list_pull_requests - List all pull requests for a project. Use this tool to discover pull requests for PR-decorated analysis (coverage, issues, quality gate). Returns the pull request key/ID which can be used with other tools. For branch-based analysis without pull requests, use
list_branchesinstead.projectKey- Project key (e.g. my_project) - Required String (Ignored whenSONARQUBE_PROJECT_KEYis defined)
Quality Gates
-
get_project_quality_gate_status - Get the Quality Gate Status for the SonarQube project.
analysisId- Optional analysis ID - Stringbranch- Optional branch name for branch-based analysis. Uselist_branchesto discover valid names - StringprojectId- Optional project ID - StringprojectKey- Optional project key - StringpullRequest- Optional pull request key/ID. Uselist_pull_requeststo discover valid keys - String
-
list_quality_gates - List all quality gates in my SonarQube.
organization- SonarQube Cloud organization key - Optional String, Cloud only
Rules
- show_rule - Shows detailed information about a SonarQube rule.
organization- SonarQube Cloud organization key - Optional String, Cloud onlykey- Rule key - Required String
Duplications
-
search_duplicated_files - Search for files with code duplications in a SonarQube project. By default, automatically fetches all duplicated files across all pages (up to 10,000 files max). Returns only files with duplications.
projectKey- Project key - Required String (Ignored whenSONARQUBE_PROJECT_KEYis defined)branch- Optional branch name for branch-based analysis. Uselist_branchesto discover valid names - StringpullRequest- Optional pull request key/ID. Uselist_pull_requeststo discover valid keys - StringpageSize- Optional number of results per page for manual pagination (max: 500). If not specified, auto-fetches all duplicated files - IntegerpageIndex- Optional page number for manual pagination (starts at 1). If not specified, auto-fetches all duplicated files - Integer
-
get_duplications - Get duplications for a file. Require Browse permission on file's project.
key- File key - Required Stringbranch- Optional branch name for branch-based analysis. Uselist_branchesto discover valid names - StringpullRequest- Optional pull request key/ID. Uselist_pull_requeststo discover valid keys - String
Sources
-
get_raw_source - Get source code as raw text from SonarQube. Require 'See Source Code' permission on file.
key- File key - Required Stringbranch- Optional branch name for branch-based analysis. Uselist_branchesto discover valid names - StringpullRequest- Optional pull request key/ID. Uselist_pull_requeststo discover valid keys - String
-
get_scm_info - Get SCM information of SonarQube source files. Require See Source Code permission on file's project.
key- File key - Required Stringcommits_by_line- Group lines by SCM commit if value is false, else display commits for each line - Stringfrom- First line to return. Starts at 1 - Numberto- Last line to return (inclusive) - Number
System
Note: System tools are only available when connecting to SonarQube Server.
-
get_system_health - Get the health status of SonarQube Server instance. Returns GREEN (fully operational), YELLOW (usable but needs attention), or RED (not operational).
-
get_system_info - Get detailed information about SonarQube Server system configuration including JVM state, database, search indexes, and settings. Requires 'Administer' permissions.
-
get_system_logs - Get SonarQube Server system logs in plain-text format. Requires system administration permission.
name- Optional name of the logs to get. Possible values: access, app, ce, deprecation, es, web. Default: app - String
-
ping_system - Ping the SonarQube Server system to check if it's alive. Returns 'pong' as plain text.
-
get_system_status - Get state information about SonarQube Server. Returns status (STARTING, UP, DOWN, RESTARTING, DB_MIGRATION_NEEDED, DB_MIGRATION_RUNNING), version, and id.
Webhooks
-
create_webhook - Create a new webhook for the SonarQube organization or project. Requires 'Administer' permission on the specified project, or global 'Administer' permission.
organization- SonarQube Cloud organization key - Optional String, Cloud onlyname- Webhook name - Required Stringurl- Webhook URL - Required StringprojectKey- Optional project key for project-specific webhook - Stringsecret- Optional webhook secret for securing the webhook payload - String
-
list_webhooks - List all webhooks for the SonarQube organization or project. Requires 'Administer' permission on the specified project, or global 'Administer' permission.
organization- SonarQube Cloud organization key - Optional String, Cloud onlyprojectKey- Optional project key to list project-specific webhooks - String
Context Augmentation
Architecture Tools
-
search_by_signature_patterns - Find code elements (classes, methods, interfaces, ...) by their declaration signatures using regex patterns.
include_code_regex_list- List of regex patterns to match against signatures - Required String[]exclude_code_regex_list- List of regex patterns to exclude from results - String[]include_glob- File filter glob pattern (e.g.,*.java) - Stringexclude_glob- File exclusion glob pattern - Stringfields- Comma-separated list of fields to include in the response - Stringlimit- Maximum number of results to return (default: 10) - Integerregex_lists_operator- How to combine multiple patterns:OR(default) orAND- String
-
search_by_body_patterns - Find code elements by their implementation body using regex patterns. Useful for locating where APIs or patterns are actually used.
include_code_regex_list- List of regex patterns to match in code bodies - Required String[]exclude_code_regex_list- List of regex patterns to exclude from results - String[]include_glob- File filter glob pattern - Stringexclude_glob- File exclusion glob pattern - Stringfields- Comma-separated list of fields to include in the response - Stringlimit- Maximum number of results to return (default: 10) - Integerregex_lists_operator- How to combine multiple patterns:OR(default) orAND- String
-
get_upstream_call_flow - Trace what functions call a given function. Useful for finding all callers and entry points, and understanding what breaks if a signature changes.
fqn- Fully qualified name of the function - Required Stringdepth- Call chain depth (0=function only, 1=direct callers, etc.) - Integerfields- Comma-separated list of fields to include in the response - String
-
get_downstream_call_flow - Trace what functions a given function calls. Useful for impact analysis and understanding execution flow.
fqn- Fully qualified name of the function - Required Stringdepth- Call chain depth (0=function only, 1=direct callees, etc.) - Integerfields- Comma-separated list of fields to include in the response - String
-
get_source_code - Get complete source code (signature and body) for a code element by its fully qualified name.
fqn- Fully qualified name of the element - Required Stringfields- Comma-separated list of fields to include in the response - String
-
get_type_hierarchy - Get the full inheritance hierarchy for a class-like structure (class, interface, enum, record, exception, struct). Essential for understanding inheritance trees and refactoring.
fqn- Fully qualified name of the class-like structure - Required Stringfields- Comma-separated list of fields to include in the response - String
-
get_references - Get direct inbound and outbound code references for a class or module. Returns only direct (non-transitive) references.
fqn- Fully qualified name of the class or module - Required Stringfields- Comma-separated list of fields to include in the response - String
-
get_current_architecture - Get a hierarchical architecture graph filtered by path prefix and depth. Useful for exploring module structure and high-level dependencies.
depth- Hierarchy depth (0=root only, 1=root + children, etc.) - Required Integerpath_prefix- Optional path prefix to filter nodes (e.g.,com.example.service) - Stringecosystem- Optional ecosystem to filter by (java,cs,py,js,ts) - String
-
get_intended_architecture - Get user-defined architectural constraints specifying which modules are allowed to depend on others.
Guidelines Tools
- get_guidelines - Get coding guidelines based on SonarQube project issues, catalog categories, or a combination of both.
mode- Guidelines retrieval mode:project_based,category_based, orcombined- Required Stringcategories- List of category names (required forcategory_basedandcombinedmodes) - String[]languages- List of target languages in SonarQube repository key format (required whencategoriesis provided) - String[]file_paths- Optional list of file paths to filter guidelines by - String[]
Third-party Dependency Tools
- check_dependency - Check a third-party dependency for security vulnerabilities, supply-chain malware, and license compliance before adding or updating it.
purl- Package URL (purl) with version, per purl-spec. Format:pkg:<type>/<namespace>/<name>@<version>(e.g.pkg:npm/[email protected],pkg:maven/org.apache.logging.log4j/[email protected],pkg:pypi/[email protected]) - Required String
Context Augmentation Environment Variables
- To be provided when not using git, or when the git branch name doesn't match the branch name in SonarQube.
Project-Specific Configuration (Recommended)
First, export the SONARQUBE_TOKEN environment variable with a valid Personal Access Token (PAT) for your project.
Then, mount the project workspace to give the Context Augmentation server direct access to your source files:
Important: In a project-scoped config, do not put SONARQUBE_TOKEN in the env block. Export it as an environment variable (export SONARQUBE_TOKEN=...). Docker will forward it into the container via -e SONARQUBE_TOKEN.
Agentic Readiness
Note: Agentic Readiness tools are only available on SonarQube Cloud and require the feature to be enabled for your organization.
The feature flag is checked at startup in stdio mode. Over HTTP/HTTPS, add agentic-readiness to the server's SONARQUBE_TOOLSETS to enable the tools.
-
start_agentic_readiness_assessment - Start an agentic readiness assessment for a project. Returns immediately with status
PENDINGand anassessmentId. Useget_agentic_readiness_assessmentto poll for results.projectKey- The project key - Required String (Ignored whenSONARQUBE_PROJECT_KEYis defined)branch- Branch to assess. Omit to use the project's default branch - String
-
get_agentic_readiness_assessment - Retrieve the result of an assessment. Re-call with the same
assessmentIduntil status isCOMPLETED,FAILED, orINTERRUPTED. When completed, returns the overall level and a per-pillar breakdown with recommended actions and evidence.assessmentId- The assessment ID returned bystart_agentic_readiness_assessment- Required String
-
list_agentic_readiness_assessments - List all assessments for a project, newest first. Use
get_agentic_readiness_assessmentfor full pillar-level results.projectKey- The project key to list assessments for - Required String (Ignored whenSONARQUBE_PROJECT_KEYis defined)branch- Filter assessments by branch name. Omit to list assessments for all branches - StringpageIndex- 1-based page index (default: 1) - NumberpageSize- Number of items per page, max 100 (default: 50) - Number
Architecture
Note: Add architecture to SONARQUBE_TOOLSETS to enable these tools in stdio or HTTP mode. SonarQube Cloud requires a Team or Enterprise plan. SonarQube Server advertises current architecture only; intended reads and writes are Cloud-only until public project UUID resolution is available.
-
architecture_get - Read current dependencies or intended groups and constraints. Current views show at most 150 nodes; narrow the view with
componentorlanguage. Omitted siblings may remain undiscoverable, so a capped view is not a complete graph export.Current graph reads are limited to two concurrent calls per tool instance. Additional calls wait up to five seconds for capacity before returning a busy error. Each accepted call still downloads and processes the full selected graph.
Parameters:
target-currentorintendedon Cloud;currenton Server - Required EnumprojectKey- The project key - Required String (Ignored whenSONARQUBE_PROJECT_KEYis defined)organization- SonarQube Cloud organization key when none is configured; required forcurrent- Optional Stringcomponent- Exact returned current node key (Java:module:package) or intended group key (labels joined by/); no wildcards; top level when omitted - Stringdepth- Levels below the start (default: 1 forcurrent, all forintended) - Numberlanguage-java,cs,js,tsorpy; all when omitted - String
-
architecture_set - Replace the whole intended model on Cloud. Start from an unfiltered
architecture_getresponse and usedryRun: trueto review changes. Hidden on Server or whenSONARQUBE_READ_ONLY=true. OAuth requires both read and write scopes.Data-loss limitations: Omitted perspectives and groups are removed. Perspective labels, descriptions and imported pattern links are preserved when supplied in the exported model. Imported patterns remain references: the public export does not expand their groups or constraints, and imported contents cannot be edited here. Partial views and an empty overall model are rejected. Supply the whole response to retain its revision check; concurrent edits can still race the check. Definite HTTP client rejections are relayed directly. Uncertain writes return a recovery export when the desired state cannot be verified; no automatic rollback is attempted.
Parameters:
target-intended- Required EnumprojectKey- The project key - Required String (Ignored whenSONARQUBE_PROJECT_KEYis defined)organization- SonarQube Cloud organization key when none is configured - Optional Stringmodel- JSON from the whole unfiltered response or itsmodelsarray - Required StringdryRun-trueto preview,falseto apply - Required Booleanrevision- Exported revision; defaults to the whole response's revision. Bare arrays without it cannot detect changes since export - String
Example Prompts
Once you've set up the SonarQube MCP Server, here are some example prompts for common real-world scenarios:
Fixing a Failing Quality Gate
Pre-Release and Pre-Merge Checks
Improving Code Quality
Understanding and Fixing Issues
Security and Dependency Management
Code Review Assistance
Project Health Monitoring
Team Collaboration
Build
Prefer the sonarsource/sonarqube-mcp container image.
To run the server as a standalone JAR without Docker, download a pre-built release from the SonarSource binaries repository. Every released version is published there as sonarqube-mcp-server-<version>.jar (for example, sonarqube-mcp-server-1.19.0.2785.jar).
Run from JAR
Download the JAR for the version you want from the binaries repository, then configure your MCP client to run it with Java 21 or later:
- To connect with SonarQube Cloud:
- To connect with SonarQube Server:
Build from source
SonarQube MCP Server requires a Java Development Kit (JDK) version 21 or later to build.
Run the following Gradle command to clean the project and build the application:
The JAR file will be created in build/libs/.
After adding or updating dependencies, regenerate the lock files:
Use the Run from JAR configuration above, pointing <path_to_sonarqube_mcp_server_jar> to the JAR in build/libs/.
Troubleshooting
Application logs are written to the STORAGE_PATH/logs/mcp.log file by default. To disable file logging entirely, set SONARQUBE_LOG_TO_FILE_DISABLED=true.
Common Issues
"SonarQube server version is not supported"
The MCP server checks the connected SonarQube Server version during startup. If the instance is older than 2025.1 (SQS) or 25.1 (SQCB), startup fails with:
Solution: Upgrade SonarQube Server to a supported release. This check applies only when connecting to SonarQube Server (SONARQUBE_URL without SONARQUBE_ORG), not to SonarQube Cloud.
"Feature is not working" or "Missing tools/functionality"
You may be running an outdated Docker image. Docker caches images locally, so you won't automatically receive updates.
Solution: Update to the latest version:
After pulling the latest image, restart your MCP client to use the updated version.
Optionally, add the --pull=always flag to your docker run command to always check for and pull the latest version:
"I want to pin to a specific version"
Browse available tags at sonarsource/sonarqube-mcp and reference the version you want:
In your MCP client config, use sonarsource/sonarqube-mcp:<version> instead of sonarsource/sonarqube-mcp and remove --pull=always so Docker does not silently upgrade the image.
Data and telemetry
This server collects anonymous usage data and sends it to SonarSource to help improve the product. No source code or IP address is collected, and SonarSource does not share the data with anyone else. Collection of telemetry can be disabled with the following system property or environment variable: TELEMETRY_DISABLED=true. Click here to see a sample of the data that are collected.
License
Copyright 2025 SonarSource.
Licensed under the SONAR Source-Available License v1.0. Using the SonarQube MCP Server in compliance with this documentation is a Non-Competitive Purpose and so is allowed under the SSAL.
Your use of SonarQube via MCP is governed by the SonarQube Cloud Terms of Service or SonarQube Server Terms and Conditions, including use of the Results Data solely for your internal software development purposes.
來源:README.md,提交 1f264f0
工具
0版本歷史
3- v1.31.0最新Nov 3, 2026
- v1.30.0Oct 23, 2026
- v1.21.0Sep 16, 2026
評分
已滿足適用檢查項的 40%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
請在儲存庫或註冊中心條目中宣告授權條款。