SonarQube MCP server

Integrates with SonarQube to provide code quality metrics, issue tracking, and quality gate status information for software development projects
Back to servers
Provider
Marc Tremblay
Release date
Mar 20, 2025
Language
Rust
Stats
38 stars

The SonarQube MCP Server enables AI assistants to access SonarQube's code quality metrics, issues, and analysis results through the Model Context Protocol. This integration allows you to retrieve code metrics, access and filter issues, check quality status, and analyze project quality over time.

Installation and Configuration

Setting Up with Claude Desktop

  1. First, edit your Claude Desktop configuration:

    • Open Claude Desktop
    • Navigate to SettingsDeveloperEdit Config
    • Add one of the configurations below to the mcpServers section
  2. Restart Claude Desktop to apply the changes

Using Docker

{
  "mcpServers": {
    "sonarqube": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "SONARQUBE_URL",
        "-e",
        "SONARQUBE_TOKEN",
        "-e",
        "SONARQUBE_ORGANIZATION",
        "sapientpants/sonarqube-mcp-server"
      ],
      "env": {
        "SONARQUBE_URL": "https://sonarqube.example.com",
        "SONARQUBE_TOKEN": "your-sonarqube-token",
        "SONARQUBE_ORGANIZATION": "your-organization-key (optional)"
      }
    }
  }
}

Using NPX

{
  "mcpServers": {
    "sonarqube": {
      "command": "npx",
      "args": [
        "-y",
        "sonarqube-mcp-server@latest"
      ],
      "env": {
        "SONARQUBE_URL": "https://sonarqube.example.com",
        "SONARQUBE_TOKEN": "your-sonarqube-token",
        "SONARQUBE_ORGANIZATION": "your-organization-key (optional)"
      }
    }
  }
}

Environment Variables

The server requires the following environment variables:

  • SONARQUBE_URL - URL of your SonarQube instance (default: https://next.sonarqube.com/sonarqube)
  • SONARQUBE_TOKEN - Authentication token for SonarQube API access
  • SONARQUBE_ORGANIZATION - (Optional) Organization key for SonarQube Cloud

Available Tools

SonarQube Tools

Projects

List all SonarQube projects with pagination.

Parameters:

  • page (optional) - Page number for results pagination
  • page_size (optional) - Number of items per page

Metrics

Get available metrics from SonarQube.

Parameters:

  • page (optional) - Page number for results pagination
  • page_size (optional) - Number of items per page

Issues

Get issues from a SonarQube project with extensive filtering options.

Parameters:

  • project_key (required) - The unique identifier for the SonarQube project
  • branch (optional) - Filter issues for a specific branch
  • pull_request (optional) - Filter issues for a specific pull request
  • hotspots (optional) - Filter for security hotspots
  • severity (optional) - Filter issues by severity (INFO, MINOR, MAJOR, CRITICAL, BLOCKER)
  • page (optional) - Page number for results pagination
  • page_size (optional) - Number of items per page
  • statuses (optional) - Filter issues by status (array of: OPEN, CONFIRMED, REOPENED, RESOLVED, CLOSED, TO_REVIEW, IN_REVIEW, REVIEWED)
  • resolutions (optional) - Filter issues by resolution (array of: FALSE-POSITIVE, WONTFIX, FIXED, REMOVED)
  • resolved (optional) - Whether to return only resolved issues (true) or unresolved issues (false)
  • types (optional) - Filter issues by type (array of: CODE_SMELL, BUG, VULNERABILITY, SECURITY_HOTSPOT)
  • rules (optional) - Array of rule keys to filter issues
  • tags (optional) - Array of tags to filter issues
  • created_after (optional) - Return issues created after the given date (format: YYYY-MM-DD)
  • created_before (optional) - Return issues created before the given date (format: YYYY-MM-DD)
  • created_at (optional) - Return issues created on the given date
  • created_in_last (optional) - Return issues created during a time span before the current time (e.g., "1d" for issues created in the last day)
  • Many more filtering options available

Measures Component

Get measures for a specific component.

Parameters:

  • component (required) - Component key
  • metric_keys (required) - Comma-separated list or array of metric keys
  • additional_fields (optional) - Additional fields to return in the response
  • branch (optional) - Branch name
  • pull_request (optional) - Pull request key
  • period (optional) - Period index

Measures Components

Get measures for multiple components.

Parameters:

  • component_keys (required) - Comma-separated list or array of component keys
  • metric_keys (required) - Comma-separated list or array of metric keys
  • Additional parameters available for filtering and pagination

Measures History

Get measures history for a component.

Parameters:

  • component (required) - Component key
  • metrics (required) - Comma-separated list or array of metric keys
  • from (optional) - Start date (format: YYYY-MM-DD)
  • to (optional) - End date (format: YYYY-MM-DD)
  • Additional parameters available

System API Tools

System Health

Get the health status of the SonarQube instance. No parameters required.

System Status

Get the status of the SonarQube instance. No parameters required.

System Ping

Ping the SonarQube instance to check if it is up. No parameters required.

Usage Examples

To use the MCP server with Claude, you'll need to have properly configured it as shown in the installation section. Once configured, you can ask Claude to use the SonarQube tools through natural language requests.

For example:

  • "Can you list all SonarQube projects available in my organization?"
  • "Show me the critical issues in project 'my-project'"
  • "What are the code coverage metrics for 'my-component'?"
  • "Check the health status of my SonarQube instance"

Claude will then use the appropriate tool with the correct parameters to retrieve the information from your SonarQube instance.

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later