Model Context Protocol (MCP) server for SonarQube
A Model Context Protocol (MCP) server that integrates with SonarQube to provide AI assistants with access to code quality metrics, issues, and analysis results.
The SonarQube MCP Server enables AI assistants to interact with SonarQube's code quality analysis capabilities through the Model Context Protocol. This integration allows AI assistants to:
Edit claude_desktop_config.json
:
Settings
-> Developer
-> Edit Config
mcpServers
sectionRestart Claude Desktop to apply the changes
{
"mcpServers": {
"sonarqube": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"SONARQUBE_URL",
"-e",
"SONARQUBE_TOKEN",
"-e",
"SONARQUBE_ORGANIZATION",
"sapientpants/sonarqube-mcp-server"
],
"env": {
"SONARQUBE_URL": "https://sonarqube.example.com",
"SONARQUBE_TOKEN": "your-sonarqube-token",
"SONARQUBE_ORGANIZATION": "your-organization-key (optional)"
}
}
}
}
{
"mcpServers": {
"sonarqube": {
"command": "npx",
"args": [
"-y",
"[email protected]"
],
"env": {
"SONARQUBE_URL": "https://sonarqube.example.com",
"SONARQUBE_TOKEN": "your-sonarqube-token",
"SONARQUBE_ORGANIZATION": "your-organization-key (optional)"
}
}
}
}
The SonarQube MCP Server provides the following tools:
projects
: List all SonarQube projects
organization
(optional) - Organization key for SonarQube Cloudpage
(optional) - Page number for results paginationpage_size
(optional) - Number of items per pageissues
: Get issues from a SonarQube project
project_key
(required) - The unique identifier for the SonarQube projectseverity
(optional) - Filter issues by severity (INFO, MINOR, MAJOR, CRITICAL, BLOCKER)organization
(optional) - Organization key for SonarQube Cloudpage
(optional) - Page number for results paginationpage_size
(optional) - Number of items per pagestatuses
(optional) - Filter issues by status (array of: OPEN, CONFIRMED, REOPENED, RESOLVED, CLOSED, TO_REVIEW, IN_REVIEW, REVIEWED)resolutions
(optional) - Filter issues by resolution (array of: FALSE-POSITIVE, WONTFIX, FIXED, REMOVED)resolved
(optional) - Whether to return only resolved issues (true) or unresolved issues (false)types
(optional) - Filter issues by type (array of: CODE_SMELL, BUG, VULNERABILITY, SECURITY_HOTSPOT)rules
(optional) - Array of rule keys to filter issuestags
(optional) - Array of tags to filter issuescreated_after
(optional) - Return issues created after the given date (format: YYYY-MM-DD)created_before
(optional) - Return issues created before the given date (format: YYYY-MM-DD)created_at
(optional) - Return issues created on the given datecreated_in_last
(optional) - Return issues created during a time span before the current time (e.g., "1d" for issues created in the last day)assignees
(optional) - Array of assignee login names to filter issuesauthors
(optional) - Array of author login names to filter issuescwe
(optional) - Array of CWE identifiers to filter vulnerability issueslanguages
(optional) - Array of languages to filter issuesowasp_top10
(optional) - Array of OWASP Top 10 categories to filter issuessans_top25
(optional) - Array of SANS Top 25 categories to filter issuessonarsource_security
(optional) - Array of SonarSource security categories to filter issueson_component_only
(optional) - Return only issues at the specified component level (true) or issues from the component's subtree (false)facets
(optional) - Array of facets to return along with the issuessince_leak_period
(optional) - Return only issues created since the leak periodin_new_code_period
(optional) - Return only issues created in the new code periodSONARQUBE_URL
- URL of your SonarQube instance (default: https://next.sonarqube.com/sonarqube)SONARQUBE_TOKEN
- Authentication token for SonarQube API accessSONARQUBE_ORGANIZATION
- (Optional) Organization key for SonarQube Cloudgit clone https://github.com/sapientpants/sonarqube-mcp-server.git
cd sonarqube-mcp-server
pnpm install
pnpm run build
{
"mcpServers": {
"sonarqube": {
"command": "node",
"args": [
"/path/to/sonarqube-mcp-server/dist/index.js"
],
"env": {
"SONARQUBE_TOKEN": "your-sonarqube-token"
}
}
}
}
pnpm run build
- Build the TypeScript codepnpm run start
- Start the serverpnpm run dev
- Start the server in development modepnpm run test
- Run testspnpm run lint
- Run ESLintpnpm run format
- Format code with PrettierMIT