
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 分