
sonarsource/sonarqube-mcp-server
Developer toolsOfficial SonarQube MCP Server for code quality and security in AI agents
Overview
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. 🔒 : Your SonarQube token is a sensitive credential. Follow these security practices: - in command-line arguments – they get saved in shell history - – set tokens in environment variables before running commands - to version control - in config files when possible The fastest way to get started is the – an interactive tool that produces a ready-to-use configuration for your preferred AI agent client. 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. Read below if you want to build it locally.
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
🚀 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 .. (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.
💡 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:
{
"sonarqube": {
"command": "docker",
"args": [
"run",
"--init",
"--pull=always",
"-i",
"--rm",
"-e",
"SONARQUBE_TOKEN",
"-e",
"SONARQUBE_ORG",
"sonarsource/sonarqube-mcp"
],
"env": {
"SONARQUBE_TOKEN": "",
"SONARQUBE_ORG": ""
}
}
}
- To connect with SonarQube Server:
{
"sonarqube": {
"command": "docker",
"args": [
"run",
"--init",
"--pull=always",
"-i",
"--rm",
"-e",
"SONARQUBE_TOKEN",
"-e",
"SONARQUBE_URL",
"sonarsource/sonarqube-mcp"
],
"env": {
"SONARQUBE_TOKEN": "",
"SONARQUBE_URL": ""
}
}
}
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
Depending on your environment, you should provide specific environment variables.
Base
You should add the following variable when running the MCP Server:
| Environment variable | Description |
|---|---|
STORAGE_PATH |
Mandatory absolute path to a writable directory where SonarQube MCP Server will store its files (e.g., for creation, updates, and persistence), it is automatically provided when using the container image |
SONARQUBE_PROJECT_KEY |
Optional default project key. When set, all tools that require a project key will use this value automatically — the projectKey parameter is removed from their schema entirely. Useful when working on a single project. |
SONARQUBE_IDE_PORT |
Optional port number between 64120 and 64130 used to connect SonarQube MCP Server with SonarQube for IDE. |
SONARQUBE_FORCE_LOCAL_ANALYSIS |
Set to true to use analyze_code_snippet instead of Vortex analysis on Cloud stdio, including for entitled organizations. Requires the analysis toolset. Default: false. Has no effect on SonarQube Server or Cloud HTTP. |
SONARQUBE_DEBUG_ENABLED |
When set to true, enables debug logging. Debug logs are written to both the log file and STDERR. Useful for troubleshooting connectivity or configuration issues. Default: false. |
SONARQUBE_LOG_TO_FILE_DISABLED |
When set to true, disables writing logs to disk entirely. No log files will be created under STORAGE_PATH/logs/. Useful in containerized or ephemeral environments where file logging is undesirable. Default: false. |
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.
{
"args": [
"run", "-i", "--rm", "--init", "--pull=always",
"-e", "SONARQUBE_TOKEN",
"-e", "SONARQUBE_ORG",
"-v", "/path/to/your/project:/app/mcp-workspace",
"sonarsource/sonarqube-mcp"
]
}
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.
| Environment variable | Description |
|---|---|
SONARQUBE_TOOLSETS |
Comma-separated list of toolsets to enable. When set, only these toolsets will be available. If not set, default important toolsets are enabled (analysis, ide, issues, projects, quality-gates, rules, duplications, measures, security-hotspots, dependency-risks, coverage, cag). Note: The projects toolset is always enabled as it’s required to find project keys for other operations. Vortex context tools (deprecated name: Context Augmentation/CAG) and Vortex analysis tools (deprecated name: Advanced Analysis/A3S) are only available in stdio mode and share a single combined organization entitlement — an org must be entitled to both to use either. Cloud built-in analysis checks the organization selected at runtime; proxied context tools use the startup organization. On SonarQube Server, stdio lists Vortex context and run_advanced_code_analysis when both the CAG and A3S hubs are entitled. Prefer the unified vortex toolset key. The deprecated cag and analysis keys still work; a startup warning and a deprecation note in the server instructions are emitted when they are used without vortex. In Streamable HTTP mode, clients can send a SONARQUBE_TOOLSETS HTTP header to narrow this further per-request, but cannot enable toolsets beyond what the server was launched with (see Streamable HTTP transport below). |
SONARQUBE_READ_ONLY |
When set to true, enables read-only mode which disables all write operations (changing issue status for example). This filter is cumulative with SONARQUBE_TOOLSETS if both are set. Default: false. In Streamable HTTP mode, clients can send a SONARQUBE_READ_ONLY HTTP header to further restrict individual requests to read-only, but cannot lift a server-level read-only restriction (see Streamable HTTP transport below). |
SonarQube Cloud
For stdio, configure the following environment variables:
| Environment variable | Description | Required |
|---|---|---|
SONARQUBE_TOKEN |
Your SonarQube Cloud token | Yes |
SONARQUBE_ORG |
Optional fixed SonarQube Cloud organization key | No |
SONARQUBE_URL |
Custom SonarQube Cloud URL (defaults to https://sonarcloud.io). Use this for SonarQube Cloud US: https://sonarqube.us |
No |
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
| Environment variable | Description | Required |
|---|---|---|
SONARQUBE_TOKEN |
Your SonarQube Server USER token | Yes |
SONARQUBE_URL |
Your SonarQube Server URL | Yes |
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:
| MCP transport | Server mode | Typical use |
|---|---|---|
| Stdio | Default (no SONARQUBE_TRANSPORT) |
Local MCP clients that launch the server as a subprocess (Cursor, Claude Code, VS Code, etc.) |
| Streamable HTTP | SONARQUBE_TRANSPORT=http or https |
Remote or multi-user deployments; clients connect to /mcp over HTTP(S) (e.g. Windsurf with a self-hosted server URL) |
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:
{
"mcpServers": {
"sonarqube": {
"command": "docker",
"args": ["run", "--init", "--pull=always", "-i", "--rm", "-e", "SONARQUBE_TOKEN", "-e", "SONARQUBE_ORG", "sonarsource/sonarqube-mcp"],
"env": {
"SONARQUBE_TOKEN": "",
"SONARQUBE_ORG": ""
}
}
}
}
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.
| Environment variable | Description | Default |
|---|---|---|
SONARQUBE_TRANSPORT |
Set to http to enable Streamable HTTP transport |
Not set (stdio) |
SONARQUBE_HTTP_PORT |
Port number (1024-65535), or 0 for an OS-assigned port |
8080 |
SONARQUBE_HTTP_HOST |
Host to bind (defaults to localhost for security) | 127.0.0.1 |
SONARQUBE_HTTP_ALLOWED_ORIGINS |
Comma-separated browser origins allowed for CORS (e.g. https://my-app.example.com) |
Not set |
SONARQUBE_MCP_IN_CONTAINER |
Set to true when running inside a container. The official Docker image sets this automatically; set it yourself when using other OCI runtimes (Podman, Kubernetes, Nomad, etc.). |
false |
Note: HTTP/HTTPS accepts the user’s SonarQube token through Authorization: Bearer . 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.
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.
| Environment variable | Description | Default |
|---|---|---|
SONARQUBE_TRANSPORT |
Set to https to enable Streamable HTTP transport over TLS |
Not set (stdio) |
SONARQUBE_HTTP_PORT |
Port number (typically 8443 for HTTPS), or 0 for an OS-assigned port |
8080 |
SONARQUBE_HTTP_HOST |
Host to bind (defaults to localhost for security) | 127.0.0.1 |
SONARQUBE_HTTP_ALLOWED_ORIGINS |
Comma-separated browser origins allowed for CORS (e.g. https://my-app.example.com) |
Not set |
SONARQUBE_MCP_IN_CONTAINER |
Set to true when running inside a container. The official Docker image sets this automatically; set it yourself when using other OCI runtimes (Podman, Kubernetes, Nomad, etc.). |
false |
SSL Certificate Configuration (Optional):
| Environment variable | Description | Default |
|---|---|---|
SONARQUBE_HTTPS_KEYSTORE_PATH |
Path to keystore file (.p12 or .jks) | /etc/ssl/mcp/keystore.p12 |
SONARQUBE_HTTPS_KEYSTORE_PASSWORD |
Keystore password | sonarlint |
SONARQUBE_HTTPS_KEYSTORE_TYPE |
Keystore type (PKCS12 or JKS) | PKCS12 |
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):
docker run --init --pull=always -p 127.0.0.1:8443:8443 \
-v $(pwd)/keystore.p12:/etc/ssl/mcp/keystore.p12:ro \
-e SONARQUBE_TRANSPORT=https \
-e SONARQUBE_HTTP_HOST=0.0.0.0 \
-e SONARQUBE_HTTP_PORT=8443 \
sonarsource/sonarqube-mcp
For a server accessible from the network (remote deployments):
docker run --init --pull=always -p 8443:8443 \
-v $(pwd)/keystore.p12:/etc/ssl/mcp/keystore.p12:ro \
-e SONARQUBE_TRANSPORT=https \
-e SONARQUBE_HTTP_HOST=0.0.0.0 \
-e SONARQUBE_HTTP_PORT=8443 \
sonarsource/sonarqube-mcp
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.
{
"mcpServers": {
"sonarqube-https": {
"url": "https://your-server:8443/mcp",
"headers": {
"Authorization": "Bearer ",
"SONARQUBE_TOOLSETS": "issues,quality-gates",
"SONARQUBE_READ_ONLY": "true"
}
}
}
}
Client Configuration (SonarQube Server):
{
"mcpServers": {
"sonarqube-https": {
"url": "https://your-server:8443/mcp",
"headers": {
"Authorization": "Bearer ",
"SONARQUBE_TOOLSETS": "issues,quality-gates",
"SONARQUBE_READ_ONLY": "true"
}
}
}
}
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.
| Endpoint | Method | Description | Example response |
|---|---|---|---|
/health |
GET |
Liveness probe. Returns 200 OK with an empty body once the server is accepting requests. |
(empty body) |
/info |
GET |
Returns the MCP server version as JSON. Useful for verifying the deployed server version. | {"version":"1.16.0"} |
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.
Proxy
The SonarQube MCP Server supports HTTP and SOCKS5 proxies through standard Java proxy system properties.
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.
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
Agentic Readiness
Note: Agentic Readiness tools are only available on SonarQube Cloud and require the feature to be enabled for your organization.
-
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:
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-.jar (for example, sonarqube-mcp-server-1.19.0.2785.jar).
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:
SonarQube server version is not supported, minimal version is SQS 2025.1 or SQCB 25.1
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:
docker pull sonarsource/sonarqube-mcp
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:
docker run --init --pull=always -i --rm -e SONARQUBE_TOKEN -e SONARQUBE_ORG sonarsource/sonarqube-mcp
“I want to pin to a specific version”
Browse available tags at sonarsource/sonarqube-mcp and reference the version you want:
docker pull sonarsource/sonarqube-mcp:1.19.0.2785
docker run --init -i --rm \
-e SONARQUBE_TOKEN -e SONARQUBE_ORG \
sonarsource/sonarqube-mcp:1.19.0.2785
In your MCP client config, use sonarsource/sonarqube-mcp: 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.
Install
docker run --init --pull=always -i --rm -e SONARQUBE_TOKEN -e SONARQUBE_ORG sonarsource/sonarqube-mcpConfiguration
{
"mcpServers": {
"sonarqube": {
"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>"
}
}
}
}