sonarqube-mcp
Provides read-only tools for interacting with SonarCloud, enabling discovery of projects, retrieval of quality metrics, Quality Gate status checks, issue search with filtering, and cross-project ranking by worst metric values.
Provides read-only tools for interacting with SonarQube instances, enabling discovery of projects, retrieval of quality metrics, Quality Gate status checks, issue search with filtering, and cross-project ranking by worst metric values.
Click on "Deploy 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 show me the top 5 worst-coverage projects"
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
MCP server for SonarQube. Lets an LLM agent (Claude Code, Cursor, OpenCode, etc.) discover projects, pull headline metrics, check Quality Gate status, search issues with severity/type filters, and rank projects by the worst value of any metric.
Python, FastMCP, stdio transport.
Works with any SonarQube 9.x / 10.x instance (self-hosted) and with SonarCloud.
Why another SonarQube MCP?
A few community SonarQube MCPs exist, but they tend to stop at single-project reads. This one adds cross-project ranking (sonarqube_worst_metrics) — the operation a lead actually runs during a triage session: "show me the top 10 worst-coverage services in the org". All tools are read-only and safely parameterised (Pydantic input validation, severity / type whitelists).
Related MCP server: sonarqube-api-mcp
Design highlights
Tool annotations — all five tools carry
readOnlyHint: True,destructiveHint: False,idempotentHint: True. Nothing can mutate SonarQube from this server.Structured output — every tool returns a typed payload (TypedDict) + a markdown summary, so clients with and without structured-content support both get a usable response.
Structured errors — 401 / 403 / 404 / 400 / 429 / 5xx mapped to actionable hints (e.g. "regenerate token", "check project key with sonarqube_list_projects").
Pydantic input validation for every argument; severity / type filters are checked against the valid SonarQube enum before the request is sent.
Cross-project worst-metric ranking — batches
/api/measures/searchcalls under the hood, sorts ascending or descending based on whether higher is worse for the chosen metric.
Features (5 tools)
Discovery
sonarqube_list_projects— paginated project search with optional text filter
Single-project insight
sonarqube_project_metrics— measures for one project (default set covers bugs / coverage / smells / ratings / ncloc / tests / alert_status)sonarqube_quality_gate_status— Quality Gate status + per-condition failures
Issue triage
sonarqube_get_issues— issue search filtered by severity / type / resolution status
Cross-project ranking
sonarqube_worst_metrics— top-N projects sorted by the worst value of a metric (e.g. worst coverage, most bugs)
Installation
Requires Python 3.10+.
# via uvx (recommended — no install, just run)
uvx --from sonarqube-mcp sonarqube-mcp
# or via pipx
pipx install sonarqube-mcpConfiguration
claude mcp add sonarqube -s project \
--env SONARQUBE_URL=https://sonar.example.com \
--env SONARQUBE_TOKEN=squ_your_token \
--env SONARQUBE_SSL_VERIFY=true \
-- uvx --from sonarqube-mcp sonarqube-mcpOr in .mcp.json:
{
"mcpServers": {
"sonarqube": {
"type": "stdio",
"command": "uvx",
"args": ["--from", "sonarqube-mcp", "sonarqube-mcp"],
"env": {
"SONARQUBE_URL": "https://sonar.example.com",
"SONARQUBE_TOKEN": "${SONARQUBE_TOKEN}",
"SONARQUBE_SSL_VERIFY": "true"
}
}
}
}Check:
claude mcp list
# sonarqube: uvx --from sonarqube-mcp sonarqube-mcp - ✓ ConnectedEnvironment variables
Variable | Required | Description |
| yes | SonarQube URL (no trailing slash) |
| yes | Bearer token. Generate in: My Account → Security → Tokens |
| no |
|
Note on HTTP proxies. The client intentionally disables env-based proxy discovery (trust_env=False) because self-hosted SonarQube is typically reachable only on an internal network. If you connect to SonarCloud or any SonarQube that lives behind a corporate proxy, you'll currently need to drop the proxy variables at the process level — a SONARQUBE_TRUST_ENV_PROXY knob is planned for a follow-up release.
Example usage
"List all SonarQube projects matching 'einvy'"
"What's the Quality Gate status for
einvy:aut_einvy?""Show me the top 10 projects with the most bugs"
"Find all BLOCKER / CRITICAL vulnerabilities in
einvy:aut_einvy""What's the coverage on
einvy:qa_assistant?""Top 5 worst-coverage projects matching query 'einvy'"
Metric directions (used by sonarqube_worst_metrics)
Higher is worse (sorted descending — more is worse):
bugs, code_smells, vulnerabilities, duplicated_lines_density, reliability_rating, security_rating, security_review_rating, sqale_rating, open_issues
Lower is worse (sorted ascending — less is worse):
coverage, line_coverage, branch_coverage, test_success_density, tests
Ratings in SonarQube are numeric strings "1" (A, best) through "5" (E, worst).
Safety
All tools are
readOnlyHint: True— nothing can mutate SonarQube.No
POST/PUT/DELETEis ever called.Severity / type / qualifier inputs are validated against SonarQube enums before the API call, so the tool fails fast on typos rather than hitting the API.
Performance characteristics
Every tool makes one HTTP call to SonarQube except
sonarqube_worst_metrics, which makes one search call + ⌈candidate_pool/100⌉ bulk-measures calls. Default settings land at ≤ 2 calls.Single-tool response time on a healthy SonarQube instance: typically < 500 ms.
Pagination is passed through to SonarQube (
p+psparams) — no full-result buffering in the MCP server.sonarqube_worst_metricscapscandidate_poolat 500 — on instances with thousands of projects, pre-filter withquery=before ranking (see the tool docstring).SonarQube has no published hard rate limit. If 429 is received the server surfaces an actionable error ("Wait 30-60 s before retrying; reduce page_size").
Development
git clone https://github.com/mshegolev/sonarqube-mcp.git
cd sonarqube-mcp
pip install -e '.[dev]'
pytestLicense
MIT © Mikhail Shchegolev
Available Tools
5 toolssonarqube_get_issuesARead-onlyIdempotent
Search issues for a SonarQube project.
Wraps /api/issues/search. Use the filter parameters to narrow
results — e.g. severities=['BLOCKER','CRITICAL'] for triage, or
types=['VULNERABILITY'] for a security sweep.
Pagination: if has_more is True, call again with page + 1.
SonarQube caps total pagination at 10 000 issues; tighten the filters
if you need to go deeper.
Examples:
- Use when: "Triage top BLOCKER / CRITICAL bugs in einvy:aut_einvy"
→ severities=['BLOCKER','CRITICAL'], types=['BUG'].
- Use when: "Security sweep on the PR"
→ types=['VULNERABILITY'], pull_request='42'.
- Use when: "Show closed issues from March 2024"
→ resolved=True (then post-process by creation_date).
- Don't use when: You want an issue count only — get_issues
always returns full issue objects; for a cheap count call with
page_size=1 and read total from the response.
- Don't use when: You want Security Hotspots — they live on
/api/hotspots/search (this tool rejects them with a clear
error so you won't get silently empty results).
Inputs: project_key (required), severities, types, resolved, +4 more. Returns: project_key, total, returned, page, +6 more
sonarqube_list_projectsARead-onlyIdempotent
List SonarQube projects (components with qualifier TRK).
Use this first to discover which project keys exist before calling
sonarqube_project_metrics or sonarqube_get_issues.
Pagination: if has_more is True, call again with page + 1.
Results are sorted by SonarQube default order (component name ascending).
Examples:
- Use when: "What SonarQube projects contain 'backend' in the name?"
→ query='backend', default pagination.
- Use when: The user gives a project name but not its key.
- Don't use when: You already have the project key and only need its
metrics (call sonarqube_project_metrics directly — one fewer
round trip).
- Don't use when: You need Quality Gate status (that's
sonarqube_quality_gate_status; this tool doesn't return it).
Returns:
dict with keys projects_count / total / page /
page_size / has_more / next_page / query /
projects (list).
Inputs: query, page, page_size. Returns: projects_count, total, page, page_size, +4 more
sonarqube_project_metricsARead-onlyIdempotent
Fetch measures for a single project.
Wraps /api/measures/component. Returns both the raw list
(measures) and a dict keyed by metric name (measures_by_metric)
— handy when the agent wants to look up a single value quickly.
To find valid metric keys, call with the default set first — SonarQube ignores unknown metric keys and returns what it knows.
Examples:
- Use when: "What's the code coverage of einvy:aut_einvy?"
→ project_key='einvy:aut_einvy', default metric_keys.
- Use when: "Coverage on the feature/new-auth branch?"
→ add branch='feature/new-auth'.
- Use when: "Metrics on PR #42?" → pull_request='42'.
- Don't use when: You want to compare many projects — use
sonarqube_worst_metrics which bulk-fetches and ranks.
- Don't use when: You want the Quality Gate's per-condition
breakdown — that's sonarqube_quality_gate_status.
Inputs: project_key (required), metric_keys, branch, pull_request. Returns: project_key, project_name, qualifier, measures_count, +2 more
sonarqube_quality_gate_statusARead-onlyIdempotent
Fetch the Quality Gate status for a project.
Wraps /api/qualitygates/project_status. Returns the overall status
(OK / WARN / ERROR / NONE) plus a per-condition
breakdown — exactly what's needed for "why is my QG failing?" or
"is PR #42 passing the gate?" queries.
NONE means the project exists but has no Quality Gate attached or
no analysis yet.
Examples:
- Use when: "Is einvy:aut_einvy passing its Quality Gate?"
→ project_key='einvy:aut_einvy'.
- Use when: "Which conditions fail on PR #42?"
→ project_key=..., pull_request='42'.
- Use when: "Does feature/xyz still pass the gate?"
→ add branch='feature/xyz'.
- Don't use when: You want raw metric values without
the pass/fail verdict — sonarqube_project_metrics is leaner.
- Don't use when: You want the list of failing projects
org-wide — use sonarqube_worst_metrics with
metric='alert_status' or aggregate manually.
Inputs: project_key (required), branch, pull_request. Returns: project_key, status, passed, conditions_count, +2 more
sonarqube_worst_metricsARead-onlyIdempotent
Rank projects by the worst value of a single metric.
Algorithm:
Pull up to
candidate_poolprojects (optionally filtered byquery).Bulk-fetch
metricfor all of them in one/api/measures/searchcall.Sort descending or ascending depending on whether higher is worse (e.g. bugs → descending, coverage → ascending).
Return the top
limit.
For fine-grained metrics (bugs, vulnerabilities, code_smells,
ratings, duplicated_lines_density, open_issues) higher is worse.
For coverage, tests, line_coverage, branch_coverage —
lower is worse.
Examples:
- Use when: "Top 10 worst-coverage services across the org"
→ metric='coverage', limit=10.
- Use when: "Which einvy:* projects have the most bugs?"
→ metric='bugs', query='einvy', limit=5.
- Use when: "What projects have the worst security rating?"
→ metric='security_rating'.
- Don't use when: You only care about one project — use
sonarqube_project_metrics (one API call instead of two).
- Don't use when: You want branch-specific ranking — SonarQube's
/api/measures/search endpoint doesn't accept branch, so
this tool always ranks main-branch values.
Inputs: metric (required), limit, query, candidate_pool. Returns: metric, direction, limit, candidates_scanned, +3 more
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool targets a distinct SonarQube operation: listing projects, searching issues, fetching single-project metrics, checking quality gate status, and ranking projects by a metric. No overlap in purpose.
All tools have a 'sonarqube_' prefix, but the suffix pattern is inconsistent: 'get_issues' and 'list_projects' follow verb_noun, while 'project_metrics', 'quality_gate_status', and 'worst_metrics' use noun-based names. This mixed convention may cause confusion.
With 5 tools, the server is well-scoped for SonarQube interaction. Each tool earns its place without redundancy or clutter.
The set covers essential read operations (projects, issues, metrics, quality gate, ranking). Minor gaps exist, such as no tool for listing all metric keys or performing write operations, but these are reasonable omissions for a focused MCP server.
Maintenance
Related MCP Connectors
MCP server providing access to the Scorecard API to evaluate and optimize LLM systems.
The Remote MCP server acts as a standardized bridge between LLM applications (like Claude, ChatGPT, and Cursor) and external services, enabling AI agents to access external tools and resources. Its primary capability is providing a centralized search tool to discover other MCP servers and their respective tools. Unlike local implementations, it runs remotely with OAuth authentication and permission controls for security.
MCP server for Pentest-Tools.com: run scans, manage findings and reports via your preffered LLM.
Related MCP Servers
- FlicenseAqualityDmaintenanceA read-only MCP server that provides AI assistants with structured access to SonarQube projects, issues, metrics, and rules. It enables safe analysis of code quality and security findings through a set of validated, safety-first tools.6-
- AlicenseBqualityDmaintenanceRead-only MCP server that exposes SonarQube Web API tools for issue retrieval, quality gate status, and source context, enabling coding agents to fix code issues.8166 npm1MIT
- AlicenseAqualityDmaintenanceA Model Context Protocol (MCP) server for interacting with SonarQube code quality platform.333 PyPI1MIT
- AlicenseAqualityDmaintenanceA Model Context Protocol (MCP) server that provides AI assistants with access to SonarQube code quality, security, and project analytics data.768 npmMIT