
Sonarqube Mcp
io.github.mshegolev由 GitHub 账号 mshegolev 发布v0.1.0更新于 Oct 25, 2026
SonarQube MCP — projects, metrics, quality gate, issues, worst-metric ranking.
概览
本地 MCP 服务器,让助手读取 SonarQube 或 SonarCloud 的项目、指标、质量门禁与问题,并按最差指标对项目排名。
- 可以做什么
- 分页列出并搜索 SonarQube 项目,支持文本过滤,并返回其他调用所需的项目键。读取单个项目的度量值,如缺陷、覆盖率、代码异味、评级、代码行数和测试数。查看项目的质量门禁状态及各条件未通过项。按严重级别、类型和解决状态筛选搜索问题。按指定指标的最差值对实例内项目排名,例如覆盖率最差的十个服务。
- 适用场景
- 适合在代码质量排查或评审时使用:让助手提取 SonarQube 数据、检查项目是否通过质量门禁、列出阻断级或严重问题,或按指标比较多个项目,而无需打开网页界面。
- 运行要求
- 以 Python 包形式通过 stdio 在本机运行(需 Python 3.10 及以上),通常用 uvx 或 pipx 启动。需要 SONARQUBE_URL 和在 SonarQube 账户安全设置中生成的 SONARQUBE_TOKEN 令牌。SONARQUBE_SSL_VERIFY 可选,默认 true。需要能访问 SonarQube 或 SonarCloud 实例的网络;基于环境变量的代理发现被禁用。
安装
在 SourceWeft 中
- 打开 控制台中的 Sonarqube Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
sonarqube-mcp
[PyPI] [Python] [License: MIT]
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).
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+.
Configuration
Or in .mcp.json:
Check:
Environment variables
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
License
MIT © Mikhail Shchegolev
来源:README.md,提交 9c5b64f
工具
0版本历史
1- v0.1.0最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分