/ ディレクトリ / プレイグラウンド / SonarQube
● 公式 SonarSource 🔑 自分のキーが必要

SonarQube

作者 SonarSource · SonarSource/sonarqube-mcp-server

SonarQube の問題、ホットスポット、品質ゲートのステータスを AI ワークフローに取り込み、SonarQube UI を開かずに検出結果と修正草案を優先順位付けします。

SonarSource の公式 MCP は、SonarQube Server と SonarCloud API をラップします。 重大度、タイプ、コンポーネント、または作成者ごとに問題をクエリします。 セキュリティホットスポットを検査します。 品質ゲートのステータスと新しいコードのデルタを読み取ります。 毎週の質の高いレビューと PR 時のトリアージに最適です。

なぜ使うのか

主な機能

ライブデモ

実際の動作

sonarqube.replay ▶ 準備完了
0/0

インストール

クライアントを選択

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "sonarqube": {
      "command": "npx",
      "args": [
        "-y",
        "sonarqube-mcp-server"
      ]
    }
  }
}

Claude Desktop → Settings → Developer → Edit Config を開く。保存後、アプリを再起動。

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "sonarqube": {
      "command": "npx",
      "args": [
        "-y",
        "sonarqube-mcp-server"
      ]
    }
  }
}

Cursor は Claude Desktop と同じ mcpServers スキーマを使用。プロジェクト設定はグローバルより優先。

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "sonarqube": {
      "command": "npx",
      "args": [
        "-y",
        "sonarqube-mcp-server"
      ]
    }
  }
}

Cline サイドバーの MCP Servers アイコンをクリックし、"Edit Configuration" を選択。

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "sonarqube": {
      "command": "npx",
      "args": [
        "-y",
        "sonarqube-mcp-server"
      ]
    }
  }
}

Claude Desktop と同じ形式。Windsurf を再起動して反映。

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "sonarqube",
      "command": "npx",
      "args": [
        "-y",
        "sonarqube-mcp-server"
      ]
    }
  ]
}

Continue はマップではなくサーバーオブジェクトの配列を使用。

~/.config/zed/settings.json
{
  "context_servers": {
    "sonarqube": {
      "command": {
        "path": "npx",
        "args": [
          "-y",
          "sonarqube-mcp-server"
        ]
      }
    }
  }
}

context_servers に追加。保存時に Zed がホットリロード。

claude mcp add sonarqube -- npx -y sonarqube-mcp-server

ワンライナー。claude mcp list で確認、claude mcp remove で削除。

ユースケース

実用的な使い方: SonarQube

レビュー前に PR で SonarQube の新しい問題を優先順位付けする

👤 糸くずではなく人間に焦点を当てたいレビュアー ⏱ ~15 min beginner

使うタイミング: PR には 15 件の新しいソナー結果が含まれています。 30 秒の要約が必要です。修正すべき点と細かい点は何ですか。

前提条件
  • 分析の実行 + 参照を備えたソナー トークン — Sonar UI → アカウント → セキュリティ → トークンの生成
  • プロジェクトキー — ソナー プロジェクトの URL: /dashboard?id=<key>
フロー
  1. ブランチの新しいコードの問題をプルする
    プロジェクト <key>、ブランチ <pr-branch>、sinceLeakPeriod=true の問題をリストします。 重大度ごとにグループ化します。✓ コピーしました
    → 新しい発見をグループ化
  2. 修正の価値を分類する
    各ブロッカー/クリティカルについて、file:line とルールを表示します。 本物のバグとノイズのように見えるマーク。✓ コピーしました
    → トリアージリスト
  3. 修正案の提案
    実際のバグについては、ファイルシステム MCP 経由でソース スニペットを取得し、それぞれに最小限のパッチを提案します。✓ コピーしました
    → 問題ごとの差分提案

結果: レビュー担当者が考慮すべき 3 つの事項が正確に記載された 1 画面の PR トリアージ。

注意点
  • 深刻度の低い「匂い」が本物の虫をかき消してしまう — トリアージのために重大度を常に BLOCKER、CRITICAL、MAJOR にフィルターします。 MINOR/INFO を別のバッチに
組み合わせ: github · filesystem

プロジェクト全体にわたる週次の品質傾向レポートを生成する

👤 エンジニアリングマネージャー ⏱ ~25 min intermediate

使うタイミング: Monday morning: where is tech debt trending across our 12 services?

フロー
  1. List projects and gate status
    List all projects with quality gate status. Flag any project that went from PASS to FAIL this week.✓ コピーしました
    → Regressions highlighted
  2. Summarize hotspots and new bugs
    For each failing project, pull open security hotspots and new bugs from the last 7 days. Top 3 per project.✓ コピーしました
    → Actionable issue list per project
  3. Format as a Markdown digest
    Produce a markdown report: section per project, table of new bugs/hotspots, coverage delta.✓ コピーしました
    → Report ready to post

結果: A weekly quality digest for your leadership review — consistent format every week.

注意点
  • Projects with auto-generated code pollute the report — Exclude them via Sonar's sonar.exclusions; don't filter in the LLM — fix upstream
組み合わせ: notion

Review and triage security hotspots with context

👤 Appsec / security-champ engineers ⏱ ~45 min advanced

使うタイミング: Quarterly security review: have all TO_REVIEW hotspots been decisioned?

フロー
  1. List unreviewed hotspots
    List hotspots with status TO_REVIEW for project <key>. Group by rule (e.g. sql-injection, xss).✓ コピーしました
    → Queue by category
  2. Pull code context
    For each hotspot, fetch the source snippet (±10 lines). Judge whether it's a real risk or safe-by-context.✓ コピーしました
    → Per-hotspot safe/risky verdict with reasoning
  3. Apply decisions
    For 'safe' hotspots, propose a resolution comment. I'll review batches of 5 and approve; then we'll apply.✓ コピーしました
    → Decision batches ready to apply

結果: A cleaned-up hotspot queue with auditable reasoning per decision.

注意点
  • Mass-resolving without code context is dangerous — Always require Claude to cite the exact line(s) before marking safe
組み合わせ: filesystem · github

Pre-flight check: will this PR fail the quality gate?

👤 Developers pushing a PR ⏱ ~15 min intermediate

使うタイミング: Before opening PR: did I introduce coverage drops or new blockers?

フロー
  1. Kick off analysis (outside MCP) and wait
    Remind me to run sonar-scanner with branch=<pr-branch> locally. After it completes, I'll come back.✓ コピーしました
    → Analysis ID for this branch
  2. Read branch gate status
    Get quality gate status for branch <pr-branch> in project <key>. Show each condition + actual vs threshold.✓ コピーしました
    → Per-condition PASS/FAIL table
  3. Focus on failing conditions
    For each failing condition, list the top 5 contributing issues/files. Suggest one change per item.✓ コピーしました
    → Concrete fix list

結果: Know exactly which rule fails CI before you open the PR.

注意点
  • Local analysis branch name doesn't match CI's — Pass -Dsonar.branch.name=<exact ci branch> explicitly
組み合わせ: github

Build a prioritized tech-debt backlog from Sonar data

👤 Tech leads planning a debt-paydown sprint ⏱ ~30 min intermediate

使うタイミング: You have a sprint budget for tech debt; you want to pick the highest-ROI items.

フロー
  1. Pull all open issues with effort + severity
    For project <key>, pull open issues with effort (minutes) and severity. Exclude MINOR/INFO.✓ コピーしました
    → Issue set with effort data
  2. Cluster by file and rule
    Group issues by (file, rule). Sum effort per group. Rank top 20 groups — these are the fix-once-fix-many opportunities.✓ コピーしました
    → ROI-ranked groups
  3. Turn top 10 into Linear tickets
    For each of the top 10, create a Linear issue titled 'Refactor <file> to resolve N× <rule>' with estimated hours.✓ コピーしました
    → Tickets created + URLs

結果: A sprint-ready debt backlog sorted by actual cost-to-impact.

注意点
  • Effort estimates are static — they don't reflect your team's velocity — Treat Sonar effort as relative; multiply by your team's calibration factor
組み合わせ: linear

組み合わせ

他のMCPと組み合わせて10倍の力を

sonarqube + github

Auto-comment Sonar triage on GitHub PRs

For PR #342, pull Sonar new-code issues for that branch, summarize critical ones, post as a PR review comment.✓ コピーしました
sonarqube + linear

Convert quality-gate regressions into Linear tickets

Any project that flipped gate to FAIL today: create a P2 Linear issue assigned to the project lead.✓ コピーしました
sonarqube + notion

Weekly quality report posted to Notion

Run the multi-project weekly quality digest; create a Notion page in 'Engineering / Quality / Weekly'.✓ コピーしました

ツール

このMCPが提供する機能

ツール入力呼び出すタイミングコスト
search_issues project_key, severities?, types?, branch?, since?, resolved? Main query tool for bugs/smells/vulns free
get_issue issue_key Drill into one issue's flows and changelog free
search_hotspots project_key, status?, branch? Security review workflows free
get_quality_gate_status project_key, branch? Gate check for CI/PR workflows free
list_projects organization? Discover projects in your org free
get_metrics project_key, metrics: str[], branch? Pull coverage, duplications, tech-debt ratio etc. free

コストと制限

運用コスト

APIクォータ
SonarCloud: generous, undocumented (~hundreds req/min). Server: bounded by your infra.
呼び出しあたりのトークン
Issue searches: 500–3000 tokens depending on page size.
金額
SonarQube Community is free. SonarCloud free for open-source; paid from ~$10/dev/mo.
ヒント
Use ps (page size) 100 and paginate; fetching all issues at once blows context and is slower.

セキュリティ

権限、シークレット、影響範囲

最小スコープ: Browse on the target project
認証情報の保管: SONAR_TOKEN (user or project token) in env; SONAR_URL for on-prem
データ送信先: Calls to sonarcloud.io or your SonarQube URL only
絶対に付与しない: Administer Security Global Admin

トラブルシューティング

よくあるエラーと対処法

401 Unauthorized

SONAR_TOKEN missing or revoked. Regenerate in Sonar UI → Account → Security.

確認: curl -u $SONAR_TOKEN: $SONAR_URL/api/authentication/validate
404 Component key not found

Project key is case-sensitive and differs from display name. Check project Dashboard URL param id=.

Branch not found

Sonar only keeps analyzed branches. Ensure your CI ran sonar-scanner with -Dsonar.branch.name=....

Empty results despite expected issues

Default filter may exclude resolved; pass resolved=false and sinceLeakPeriod=false explicitly.

代替案

SonarQube 他との比較

代替案代わりに使う場面トレードオフ
CodeQL / GitHub Advanced SecurityYou're on GitHub and want code scanning integrated with PRsNarrower rule coverage for non-security issues
Semgrep MCPYou want fast, customizable static rules without a hosted platformNo dashboards / quality-gate concept out of the box

その他

リソース

📖 GitHub の公式 README を読む

🐙 オープンな issue を見る

🔍 400以上のMCPサーバーとSkillsを見る