Sponsored by Deepsite.site

SonarQube

Created By
SonarSource7 months ago
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.
Content

SonarQube MCP Server

Build Status Quality Gate Status

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.

Quick setup

The simplest method is to rely on our Docker image hosted at mcp/sonarqube. Read below for how to build locally.

Cursor

  • To connect with SonarQube Cloud:

Install for SonarQube Cloud

  • To connect with SonarQube Server:

Install for SonarQube Server

Claude Code

  • To connect with SonarQube Cloud:

claude mcp add sonarqube --env SONARQUBE_TOKEN=<token> --env SONARQUBE_ORG=<org> -- docker run -i --rm -e SONARQUBE_TOKEN -e SONARQUBE_ORG mcp/sonarqube

  • To connect with SonarQube Server:

claude mcp add sonarqube --env SONARQUBE_TOKEN=<token> --env SONARQUBE_URL=<url> -- docker run -i --rm -e SONARQUBE_TOKEN -e SONARQUBE_URL mcp/sonarqube

Windsurf

SonarQube MCP Server is available as a Windsurf plugin. Follow these instructions:

  1. Click on the Plugins button at the top right of the Cascade view
  2. Search for sonarqube on the Plugin store
  3. Click Install
  4. Add the required SonarQube token. Then add the organization key if you want to connect with SonarQube Cloud, or the SonarQube URL if you want to connect to SonarQube Server or Community Build.

VS Code

You can use the following buttons to simplify the installation process within VS Code.

Install for SonarQube Cloud

Install for SonarQube Server

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",
      "-i",
      "--rm",
      "-e",
      "SONARQUBE_TOKEN",
      "-e",
      "SONARQUBE_ORG",
      "mcp/sonarqube"
    ],
    "env": {
      "SONARQUBE_TOKEN": "<token>",
      "SONARQUBE_ORG": "<org>"
    }
  }
}
  • To connect with SonarQube Server:
{
  "sonarqube": {
    "command": "docker",
    "args": [
      "run",
      "-i",
      "--rm",
      "-e",
      "SONARQUBE_TOKEN",
      "-e",
      "SONARQUBE_URL",
      "mcp/sonarqube"
    ],
    "env": {
      "SONARQUBE_TOKEN": "<token>",
      "SONARQUBE_URL": "<url>"
    }
  }
}

Build

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:

./gradlew clean build -x test

The JAR file will be created in build/libs/.

You will then need to manually copy and paste the MCP configuration, as follows:

  • To connect with SonarQube Cloud:
{
  "sonarqube": {
    "command": "java",
    "args": [
      "-jar",
      "<path_to_sonarqube_mcp_server_jar>"
    ],
    "env": {
      "STORAGE_PATH": "<path_to_your_mcp_storage>",
      "SONARQUBE_TOKEN": "<token>",
      "SONARQUBE_ORG": "<org>"
    }
  }
}
  • To connect with SonarQube Server:
{
  "sonarqube": {
    "command": "java",
    "args": [
      "-jar",
      "<path_to_sonarqube_mcp_server_jar>"
    ],
    "env": {
      "STORAGE_PATH": "<path_to_your_mcp_storage>",
      "SONARQUBE_TOKEN": "<token>",
      "SONARQUBE_URL": "<url>"
    }
  }
}

Configuration

Depending on your environment, you should provide specific environment variables.

Mandatory

You should add the following variable when running the MCP Server:

Environment variableDescription
STORAGE_PATHAn 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 Docker

SonarQube Cloud

To enable full functionality, the following environment variables must be set before starting the server:

Environment variableDescription
SONARQUBE_TOKENYour SonarQube Cloud token
SONARQUBE_ORGYour SonarQube Cloud organization key

SonarQube Server

Environment variableDescription
SONARQUBE_TOKENYour SonarQube Server USER token
SONARQUBE_URLYour SonarQube Server URL

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 Docker container that will automatically be installed.

Using Docker Volume Mount

Mount a directory containing your certificates when running the container:

docker run -i --rm \
  -v /path/to/your/certificates/:/usr/local/share/ca-certificates/:ro \
  -e SONARQUBE_TOKEN="<token>" \
  -e SONARQUBE_URL="<url>" \
  mcp/sonarqube

Supported Certificate Formats

The container supports the following certificate formats:

  • .crt files (PEM or DER encoded)
  • .pem files (PEM encoded)

MCP Configuration with Certificates

When using custom certificates, you can modify your MCP configuration to mount the certificates:

{
  "sonarqube": {
    "command": "docker",
    "args": [
      "run",
      "-i",
      "--rm",
      "-v",
      "/path/to/your/certificates/:/usr/local/share/ca-certificates/:ro",
      "-e",
      "SONARQUBE_TOKEN",
      "-e",
      "SONARQUBE_URL",
      "mcp/sonarqube"
    ],
    "env": {
      "SONARQUBE_TOKEN": "<token>",
      "SONARQUBE_URL": "<url>"
    }
  }
}

Tools

Analysis

  • analyze_code_snippet - Analyze a code snippet with SonarQube analyzers to find SonarQube issues in it.
    • codeSnippet - Code snippet or full file content - Required String
    • language - Optional language of the code snippet - String

Dependency Risks

Note: Dependency risks are only available when connecting to SonarQube Server 2025.4 Enterprise or higher with SonarQube Advanced Security enabled.

  • search_dependency_risks - Search for software composition analysis issues (dependency risks) of a project, paired with releases that appear in the analyzed project, application, or portfolio.
    • projectKey - Project key - String
    • branchKey - Optional branch key - String
    • pullRequestKey - Optional pull request key - String

Languages

  • list_languages - List all programming languages supported in this instance
    • q - Optional pattern to match language keys/names against - 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 String
    • status - New issue's status - Required Enum {"accept", "falsepositive", "reopen"}
  • search_sonar_issues_in_projects - Search for SonarQube issues in my organization's projects

    • projects - Optional list of Sonar projects - String[]
    • pullRequestId - Optional Pull Request's identifier - String
    • p - Optional page number (default: 1) - Integer
    • ps - Optional page size. Must be greater than 0 and less than or equal to 500 (default: 100) - Integer

Measures

  • get_component_measures - Get measures for a component (project, directory, file)
    • component - Optional component key to get measures for - String
    • branch - Optional branch to analyze for measures - String
    • metricKeys - Optional metric keys to retrieve (e.g. nloc, complexity, violations, coverage) - String[]
    • pullRequest - Optional pull request identifier to analyze for measures - String

Metrics

  • search_metrics - Search for metrics
    • p - Optional page number (default: 1) - Integer
    • ps - 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

Portfolios

  • list_portfolios - List portfolios available in SonarQube with filtering and pagination options.

    For SonarQube Server:

    • q - Optional search query to filter portfolios by name or key - String
    • favorite - If true, only returns favorite portfolios - Boolean
    • pageIndex - Optional 1-based page number (default: 1) - Integer
    • pageSize - 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 - String
    • q - Optional search query to filter portfolios by name - String
    • favorite - 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 - Boolean
    • draft - If true, only returns drafts created by the logged-in user. Cannot be true when 'favorite' is true - Boolean
    • pageIndex - Optional index of the page to fetch (default: 1) - Integer
    • pageSize - Optional size of the page to fetch (default: 50) - Integer

Projects

  • search_my_sonarqube_projects - Find Sonar projects in my organization
    • page - Optional page number - String

Quality Gates

  • get_project_quality_gate_status - Get the Quality Gate Status for the project

    • analysisId - Optional analysis ID - String
    • branch - Optional branch key - String
    • projectId - Optional project ID - String
    • projectKey - Optional project key - String
    • pullRequest - Optional pull request ID - String
  • list_quality_gates - List all quality gates in the organization

Rules

  • list_rule_repositories - List rule repositories available in SonarQube

    • language - Optional language key - String
    • q - Optional search query - String
  • show_rule - Shows detailed information about a SonarQube rule

    • key - Rule key - Required String

Sources

  • get_raw_source - Get source code as raw text. Require 'See Source Code' permission on file

    • key - File key - Required String
    • branch - Optional branch key - String
    • pullRequest - Optional pull request id - String
  • get_scm_info - Get SCM information of source files. Require See Source Code permission on file's project

    • key - File key - Required String
    • commits_by_line - Group lines by SCM commit if value is false, else display commits for each line - String
    • from - First line to return. Starts at 1 - Number
    • to - 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

  • 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

  • get_system_status - Get state information about SonarQube Server

Webhooks

  • create_webhook - Create a new webhook for the organization or project. Requires 'Administer' permission on the specified project, or global 'Administer' permission

    • name - Webhook name - Required String
    • url - Webhook URL - Required String
    • projectKey - Optional project key for project-specific webhook - String
    • secret - Optional webhook secret for securing the webhook payload - String
  • list_webhooks - List all webhooks for the organization or project. Requires 'Administer' permission on the specified project, or global 'Administer' permission

    • projectKey - Optional project key to list project-specific webhooks - String

Troubleshooting

Applications logs will be written to the STORAGE_PATH/logs/mcp.log file.

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

Server Config

{
  "mcpServers": {
    "sonarqube": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "SONARQUBE_TOKEN",
        "-e",
        "SONARQUBE_URL",
        "-e",
        "SONARQUBE_ORG",
        "mcp/sonarqube"
      ],
      "env": {
        "SONARQUBE_TOKEN": "<token>",
        "SONARQUBE_URL": "<url>",
        "SONARQUBE_ORG": "<org>"
      }
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
CursorThe AI Code Editor
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
DeepChatYour AI Partner on Desktop
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
WindsurfThe new purpose-built IDE to harness magic
Playwright McpPlaywright MCP server
Tavily Mcp
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Serper MCP ServerA Serper MCP Server
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Amap Maps高德地图官方 MCP Server
ChatWiseThe second fastest AI chatbot™