loading…
Search for a command to run...
loading…
Read-only MCP server that exposes SonarQube Web API tools for issue retrieval, quality gate status, and source context, enabling coding agents to fix code issue
Read-only MCP server that exposes SonarQube Web API tools for issue retrieval, quality gate status, and source context, enabling coding agents to fix code issues.
Docker-free SonarQube MCP server for read-only access to the SonarQube Web API.
Run it with:
npx sonarqube-api-mcp
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:
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.
Configure the server entirely through environment variables in mcp.json.
| Variable | Required | Description |
|---|---|---|
SONAR_HOST_URL |
Yes | SonarQube base URL. Trailing slashes are normalized. |
SONAR_TOKEN |
Yes | SonarQube token. Sent as Basic Auth using Authorization: Basic base64("${SONAR_TOKEN}:"). |
SONAR_PROJECT_KEY |
No | Default project key used by project-scoped tools when projectKey and projectName are omitted. |
Startup fails clearly when SONAR_HOST_URL or SONAR_TOKEN is missing.
{
"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"
}
}
}
}
Build first:
npm install
npm run build
Then 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"
}
}
}
}
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"]
}
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.
search_sonar_projectsSearches /api/projects/search to find project keys by SonarQube project name or key.
Inputs:
query optional stringpageSize optional number, defaults to 100get_sonar_fix_planGets 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:
projectKey optional, falls back to SONAR_PROJECT_KEYprojectName optional, resolved through /api/projects/searchscope optional, new_code or overall, defaults to new_codebranch optionalpullRequest optionalseverities optional string arraystatuses optional string arraytypes optional string arrayimpactSeverities optional string array for newer SonarQube versionsimpactSoftwareQualities optional string array for newer SonarQube versionspageSize optional number, defaults to 100maxIssues optional number, defaults to 200includeSource optional boolean, defaults to trueincludeRules optional boolean, defaults to falsecontextLines optional number, defaults to 5Example 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:
get_sonar_issue_contextGets one issue plus surrounding source lines and optional rule details.
Inputs:
issueKey requiredbranch optionalpullRequest optionalcontextLines optional number, defaults to 5includeRule optional boolean, defaults to truesearch_sonar_issuesSearches /api/issues/search and handles pagination.
Inputs:
projectKey optional, falls back to SONAR_PROJECT_KEYprojectName optional, resolved through /api/projects/searchbranch optionalpullRequest optionalseverities optional string arraystatuses optional string arraytypes optional string arrayimpactSeverities optional string array for newer SonarQube versionsimpactSoftwareQualities optional string array for newer SonarQube versionsinNewCodePeriod optional booleanresolved optional boolean, defaults to falsepageSize optional number, defaults to 100Returns clean JSON with issue key, rule, severity, type, message, component, filePath, line, textRange, effort, status, and tags.
get_quality_gate_statusCalls /api/qualitygates/project_status.
Inputs:
projectKey optional, falls back to SONAR_PROJECT_KEYprojectName optional, resolved through /api/projects/searchbranch optionalpullRequest optionalget_rule_detailsCalls /api/rules/show.
Inputs:
ruleKey requiredget_component_measuresCalls /api/measures/component.
Inputs:
projectKey optional, falls back to SONAR_PROJECT_KEYprojectName optional, resolved through /api/projects/searchmetricKeys required string arraybranch optionalpullRequest optionalget_sonar_sourcesCalls /api/sources/lines.
Inputs:
component requiredfrom optional numberto optional numberbranch optionalpullRequest optionalSonarQube API errors are wrapped as JSON strings containing:
endpointstatusmessageHTML error pages are never returned directly.
npm install
npm run build
prepublishOnly runs the build before publishing.
Выполни в терминале:
claude mcp add sonarqube-api-mcp -- npx Не уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории development