sonarqube-api-mcp
Provides read-only access to the SonarQube Web API, enabling issue retrieval, quality gate status checks, rule details, component measures, and source code context for project analysis.
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-api-mcp get fix plan for new code issues in project hvmb-app"
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-api-mcp
Docker-free SonarQube MCP server for read-only access to the SonarQube Web API.
Run it with:
npx sonarqube-api-mcpRequirements
Node.js 20+
SonarQube token with permission to browse the target project
No Docker
This package uses the public SonarQube Web API only. It does not use private SonarQube UI GraphQL endpoints.
It is designed for coding-agent workflows like:
"fix all new code issues"
"fix all overall code issues"
"fix issues for this SonarQube project name"
The server stays read-only: it fetches SonarQube issues, source context, rule details, and quality data so the calling agent can edit the checked-out repository.
Related MCP server: sonarqube-mcp
Configuration
Configure the server entirely through environment variables in mcp.json.
Variable | Required | Description |
| Yes | SonarQube base URL. Trailing slashes are normalized. |
| Yes | SonarQube token. Sent as Basic Auth using |
| No | Default project key used by project-scoped tools when |
Startup fails clearly when SONAR_HOST_URL or SONAR_TOKEN is missing.
Published package usage
{
"mcpServers": {
"sonarqube": {
"command": "npx",
"args": ["-y", "sonarqube-api-mcp"],
"env": {
"SONAR_HOST_URL": "https://sonarqube.yourcompany.com",
"SONAR_TOKEN": "YOUR_SONAR_TOKEN",
"SONAR_PROJECT_KEY": "hvmb-app"
}
}
}
}Local package development
Build first:
npm install
npm run buildThen point your MCP client at the compiled entrypoint:
{
"mcpServers": {
"sonarqube-local": {
"command": "node",
"args": ["/absolute/path/to/sonarqube-api-mcp/dist/index.js"],
"env": {
"SONAR_HOST_URL": "https://sonarqube.yourcompany.com",
"SONAR_TOKEN": "YOUR_SONAR_TOKEN",
"SONAR_PROJECT_KEY": "hvmb-app"
}
}
}
}Default project key
Set SONAR_PROJECT_KEY once and omit projectKey from project-scoped tool calls.
{
"mcpServers": {
"sonarqube": {
"command": "npx",
"args": ["-y", "sonarqube-api-mcp"],
"env": {
"SONAR_HOST_URL": "https://sonarqube.yourcompany.com",
"SONAR_TOKEN": "YOUR_SONAR_TOKEN",
"SONAR_PROJECT_KEY": "hvmb-app"
}
}
}
}Example tool input:
{
"resolved": false,
"severities": ["BLOCKER", "CRITICAL"]
}Per-tool project override
Every project-scoped tool accepts projectKey or projectName, which override SONAR_PROJECT_KEY for that call.
{
"projectKey": "another-project",
"branch": "main",
"metricKeys": ["coverage", "bugs", "vulnerabilities"]
}If your infrastructure creates a SonarQube project per branch, pass the SonarQube project name directly:
{
"projectName": "repo-name-feature-branch",
"scope": "new_code"
}If a name matches multiple projects, the tool returns candidates and asks the caller to retry with projectKey.
Tools
search_sonar_projects
Searches /api/projects/search to find project keys by SonarQube project name or key.
Inputs:
queryoptional stringpageSizeoptional number, defaults to100
get_sonar_fix_plan
Gets unresolved issues grouped by file for agentic fixing workflows.
Use this for prompts like "fix all new code issues" or "fix all overall code issues".
Inputs:
projectKeyoptional, falls back toSONAR_PROJECT_KEYprojectNameoptional, resolved through/api/projects/searchscopeoptional,new_codeoroverall, defaults tonew_codebranchoptionalpullRequestoptionalseveritiesoptional string arraystatusesoptional string arraytypesoptional string arrayimpactSeveritiesoptional string array for newer SonarQube versionsimpactSoftwareQualitiesoptional string array for newer SonarQube versionspageSizeoptional number, defaults to100maxIssuesoptional number, defaults to200includeSourceoptional boolean, defaults totrueincludeRulesoptional boolean, defaults tofalsecontextLinesoptional number, defaults to5
Example for new code:
{
"projectName": "hvmb-app-feature-branch",
"scope": "new_code",
"includeSource": true,
"includeRules": true
}Example for overall code:
{
"projectKey": "hvmb-app",
"scope": "overall",
"maxIssues": 500
}Returns clean JSON with:
resolved project identity
issue count and truncation flag
optional rule details keyed by rule key
files sorted by issue count
issues per file
merged source ranges around affected lines
get_sonar_issue_context
Gets one issue plus surrounding source lines and optional rule details.
Inputs:
issueKeyrequiredbranchoptionalpullRequestoptionalcontextLinesoptional number, defaults to5includeRuleoptional boolean, defaults totrue
search_sonar_issues
Searches /api/issues/search and handles pagination.
Inputs:
projectKeyoptional, falls back toSONAR_PROJECT_KEYprojectNameoptional, resolved through/api/projects/searchbranchoptionalpullRequestoptionalseveritiesoptional string arraystatusesoptional string arraytypesoptional string arrayimpactSeveritiesoptional string array for newer SonarQube versionsimpactSoftwareQualitiesoptional string array for newer SonarQube versionsinNewCodePeriodoptional booleanresolvedoptional boolean, defaults tofalsepageSizeoptional number, defaults to100
Returns clean JSON with issue key, rule, severity, type, message, component, filePath, line, textRange, effort, status, and tags.
get_quality_gate_status
Calls /api/qualitygates/project_status.
Inputs:
projectKeyoptional, falls back toSONAR_PROJECT_KEYprojectNameoptional, resolved through/api/projects/searchbranchoptionalpullRequestoptional
get_rule_details
Calls /api/rules/show.
Inputs:
ruleKeyrequired
get_component_measures
Calls /api/measures/component.
Inputs:
projectKeyoptional, falls back toSONAR_PROJECT_KEYprojectNameoptional, resolved through/api/projects/searchmetricKeysrequired string arraybranchoptionalpullRequestoptional
get_sonar_sources
Calls /api/sources/lines.
Inputs:
componentrequiredfromoptional numbertooptional numberbranchoptionalpullRequestoptional
Errors
SonarQube API errors are wrapped as JSON strings containing:
endpointstatusmessage
HTML error pages are never returned directly.
Development
npm install
npm run buildprepublishOnly runs the build before publishing.
Available Tools
8 toolsget_component_measuresGet component measuresC
Get read-only SonarQube component measures for metric keys.
Inputs: metricKeys (required), projectKey, projectName, branch, +1 more.
get_quality_gate_statusGet quality gate statusC
Get read-only SonarQube quality gate status for a project.
Inputs: projectKey, projectName, branch, pullRequest.
get_rule_detailsGet rule detailsC
Get read-only SonarQube rule details.
Inputs: ruleKey (required).
get_sonar_fix_planGet SonarQube fix planA
Return unresolved SonarQube issues grouped by file with optional source context for fixing new-code or overall-code issues.
Inputs: projectKey, projectName, branch, pullRequest, +11 more.
get_sonar_issue_contextGet issue contextB
Get one SonarQube issue with source lines around the affected range.
Inputs: issueKey (required), branch, pullRequest, contextLines, +1 more.
get_sonar_sourcesGet source linesA
Get read-only SonarQube source lines for a component.
Inputs: component (required), from, to, branch, +1 more.
search_sonar_issuesSearch SonarQube issuesC
Search read-only SonarQube issues through /api/issues/search.
Inputs: projectKey, projectName, branch, pullRequest, +8 more.
search_sonar_projectsSearch SonarQube projectsB
Find SonarQube project keys by project name or key.
Inputs: query, pageSize.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool targets a distinct aspect of SonarQube (measures, quality gate, rules, issues, sources, projects) with no overlapping purposes. An agent can clearly differentiate between them.
Tools mostly follow a verb_noun pattern, but there is inconsistency in the use of the 'sonar' prefix: some include it (get_sonar_fix_plan) while others do not (get_component_measures). This mixed style reduces clarity.
Eight tools is well-scoped for a SonarQube API server, covering the core read operations without being excessive or insufficient.
The tool surface covers essential read-only operations (measures, quality gate, rules, issues, sources, projects). Minor gaps like a dedicated list_rules tool are present, but agents can work around using search_sonar_issues.
Related MCP Connectors
The Cortex MCP server provides read-only access to real-time engineering context from the Cortex developer portal, allowing AI coding assistants to answer natural language questions about your organization's catalog (microservices, libraries, domains, teams, infrastructure), scorecards (engineering standards and best practices), initiatives (goals and deadlines), and Engineering Intelligence metrics. It includes tools for querying documentation, tracking personal entities, and accessing AI-assisted insights across the entire Cortex ecosystem.
One MCP server for all your MCP servers: code mode, per-tool permissions, approvals and audit.
Read-only MCP server for AIStatusDashboard status, incidents, metrics, and fallback recommendations.
Permission-aware onboarding MCP server: answers about a codebase, filtered by the caller's role.
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-
- AlicenseAqualityCmaintenanceAn MCP server for SonarQube that enables LLM agents to discover projects, analyze code quality metrics, check Quality Gate status, search issues with filters, and rank projects by worst-performing metrics. It provides read-only, safe access to SonarQube instances with structured outputs and error handling.564 PyPI1MIT
- AlicenseAqualityDmaintenanceA Model Context Protocol (MCP) server for interacting with SonarQube code quality platform.333 PyPI1MIT
- AlicenseNot gradedqualityDmaintenanceA read-only MCP server for AI coding agents to inspect repositories, audit code quality, route engineering skills, and plan safe issue/PR workflows.1MIT