Provides read-only access to SonarQube projects, metrics, and rules, allowing users to search for issues, retrieve quality dashboards, and access detailed information about code bugs, vulnerabilities, and security hotspots.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@SonarQube MCP Serverlist all critical bugs and vulnerabilities in the 'web-app' project"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
SonarQube MCP Server
A read-only Model Context Protocol (MCP) server that gives AI assistants structured access to SonarQube — issues, metrics, rules, and projects.
Features
6 read-only tools covering the full SonarQube quality workflow
Safe by design — no mutations, every tool returns a consistent
{"ok": ...}envelopeInput validation before any API call (severities, types, statuses)
Structured errors with machine-readable
error_codefieldsWorks with SonarQube Community, Developer, and Enterprise editions
Requirements
Python 3.10+
A running SonarQube instance
A SonarQube user token (
squ_...)
Installation
Or install from source:
Quick Start
Or with python -m:
Configuration
Environment Variables
Variable | Required | Default | Description |
| No |
| Base URL of your SonarQube instance |
| Yes | — | User token for authentication |
| No |
| HTTP request timeout in seconds |
Copy .env.example to .env and fill in your values:
Generating a Token
In SonarQube: My Account → Security → Generate Tokens. A user token (squ_...) with Browse permission on the target projects is sufficient for all read-only operations.
MCP Client Integration
Claude Code
Add to your Claude Code MCP settings (~/.claude/claude_code_config.json):
Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
Tools
All tools are read-only (readOnlyHint: true, destructiveHint: false).
check_status
Verify connectivity and retrieve server version.
Response:
list_projects
List or search SonarQube projects with pagination.
Parameter | Type | Default | Description |
|
| — | Filter by project name or key |
|
|
| Page number (1-indexed) |
|
|
| Results per page (1–500) |
Response:
search_issues
Search issues across all projects or scoped to one project, with rich filtering.
Parameter | Type | Default | Description |
|
| — | Scope to a specific project |
|
| — | CSV: |
|
| — | CSV: |
|
| — | CSV: |
|
| — | CSV of tag names |
|
| — |
|
|
|
| Page number |
|
|
| Results per page (1–500) |
Example — find all open blockers in a project:
get_issue
Get full detail for a single issue by key, including text range, effort, assignee, comments, and data-flow information.
Parameter | Type | Description |
|
| Issue key (e.g. |
get_project_metrics
Retrieve the quality dashboard for a project. Returns a standard set of metrics by default, or a custom selection.
Parameter | Type | Default | Description |
|
| — | Required. Project key |
|
| See below | CSV of metric keys |
Default metrics: bugs, vulnerabilities, code_smells, security_hotspots, coverage, duplicated_lines_density, ncloc, sqale_index, reliability_rating, security_rating, sqale_rating, alert_status, quality_gate_details
Response:
get_rule
Retrieve the description and metadata for a SonarQube rule.
Parameter | Type | Description |
|
| Rule key (e.g. |
Error Handling
All tools return a consistent envelope. On failure:
| Cause |
| Invalid or missing token (HTTP 401) |
| Token lacks permissions (HTTP 403) |
| Project, issue, or rule does not exist (HTTP 404) |
| Cannot reach the SonarQube instance |
| Request exceeded |
| Bad parameter value (e.g. unknown severity) |
| Other non-2xx SonarQube response |
| Unexpected server-side error |
Development
Setup
Running Tests
Project Layout
Architecture Notes
create_server()is a factory that capturessettingsandclientin closure scope — makes unit testing straightforward by injecting a pre-builtSonarQubeSettings.@_safe_toolwraps every tool so it never raises — exceptions are caught and returned as structured error envelopes._clamp()keepspage_sizewithin SonarQube's supported API limits (1–500).Settings use a
frozen=Truedataclass — immutable after load, safe to share across tool closures.
License
MIT