sonarqube-api-mcp
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.
README
sonarqube-api-mcp
Docker-free SonarQube MCP server for read-only access to the SonarQube Web API.
Run it with:
npx sonarqube-api-mcp
Requirements
- 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.
Configuration
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.
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 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"
}
}
}
}
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 build
prepublishOnly runs the build before publishing.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。