Semgrep vs SonarQube

Semgrep MCP and SonarQube MCP both bring static code analysis to an agent, but they emphasize different slices of code health. Semgrep is the fast, semantic, rule-based scanner: its official server lets an agent scan code for security vulnerabilities across 30+ languages, write and run custom rules, inspect a file's abstract syntax tree, run a supply-chain (dependency) scan, and pull findings from the Semgrep AppSec Platform. SonarQube is Sonar's broader code-quality and security platform; its official server connects to SonarQube Cloud, Server, and the local SonarQube for IDE analyzers, and lets an agent analyze a snippet or files directly, then search issues, security hotspots, and software-composition (dependency) risks across the organization, manage issue and hotspot status, and inspect coverage. The deciding question is whether you want Semgrep's rule-driven, security-and-AppSec focus with custom-rule authoring, or SonarQube's wider quality-plus-security platform with coverage and issue-state management. Here is a balanced look.

How they compare

DimensionSemgrepSonarQube
Primary focusSecurity-first static analysis — find vulnerabilities fast with semantic, rule-based scanning, plus AppSec Platform findings.Code quality and security together — issues, security hotspots, dependency risks, and test coverage as one platform view.
Custom rulesFirst-class — write and run custom Semgrep rules (semgrep_scan_with_custom_rule), inspect the rule schema, and read a file's AST.Uses SonarQube's analyzers and rule sets across languages rather than ad-hoc custom-rule authoring through the server.
Coverage and quality metricsNot a focus — Semgrep centers on vulnerability and supply-chain findings rather than test-coverage reporting.Built in — search files by coverage, pull per-file coverage details, and run advanced quality analysis alongside security.
Issue lifecycleSurfaces findings (semgrep_findings) for the agent to act on; the workflow is scan-and-report driven.Manage state directly — change issue status and change security-hotspot status across projects in the organization.
Deployment surfaceRuns Semgrep's engine locally to scan code and can pull cloud AppSec Platform findings.Connects to SonarQube Cloud, SonarQube Server, and the local SonarQube for IDE analyzers from one server.

Verdict

Choose by what you want to measure. Reach for Semgrep MCP when security is the priority and you value rule-driven scanning — finding vulnerabilities fast across many languages, writing and running custom rules, scanning the supply chain, and pulling AppSec Platform findings. Reach for SonarQube MCP when you want a broader code-quality-plus-security view — issues, security hotspots, dependency risks, and test coverage in one place, with the ability to change issue and hotspot status across the organization. In short: Semgrep for rule-driven, security-and-AppSec scanning with custom rules; SonarQube for quality, security, and coverage with issue-state management.

FAQ

Can both find dependency (supply-chain) issues?
Yes. Semgrep's server includes a supply-chain scan tool for dependency vulnerabilities, and SonarQube's server can search software-composition-analysis dependency risks across your projects. They differ in surrounding scope: Semgrep is security-rule-centric, SonarQube wraps dependency risk into a broader quality and coverage view.
Which lets me write custom rules?
Semgrep. Its server supports running scans with custom rules and exposes the rule schema and a file's abstract syntax tree, which is ideal for authoring and testing your own patterns. SonarQube relies on its built-in analyzers and rule sets rather than ad-hoc custom-rule authoring through the server.