by sapientpants
Enables AI assistants to retrieve SonarQube code quality metrics, issues, security hotspots, and analysis results through the Model Context Protocol.
Provides AI assistants with programmatic access to SonarQube (or SonarCloud) data, including metrics, issues, quality gates, security hotspots, source code views, and system health, all via the Model Context Protocol.
SONARQUBE_URL and SONARQUBE_TOKEN; add SONARQUBE_ORGANIZATION for SonarCloud.mcpServers.sonarqube.projects, sonarqube.issues, sonarqube.quality_gate_status, etc., to retrieve or manage data.Q: Can I use this with SonarCloud?
A: Yes. Set SONARQUBE_URL to https://sonarcloud.io and provide SONARQUBE_ORGANIZATION along with a token.
Q: What permissions does the token need?
A: The token must have at least Execute Analysis and Browse permissions for the projects you query. Admin permissions are required for tools like projects that list all projects.
Q: How do I filter issues by multiple criteria?
A: Use the issues tool and combine parameters such as severities, statuses, tags, component_keys, branch, pull_request, etc.
Q: Is there a way to run the server as a web service?
A: Yes. Set MCP_TRANSPORT_TYPE=http and optionally configure MCP_HTTP_PORT, CORS, and DNS rebinding protection.
Q: Where can I see detailed error messages?
A: Enable file logging with LOG_FILE and set LOG_LEVEL=DEBUG. Logs are written to the specified file, keeping stdio clean for MCP communication.
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:
For detailed information about MCP protocol version support and SDK compatibility, see COMPATIBILITY.md.
For SonarCloud:
For SonarQube:
{
"mcpServers": {
"sonarqube": {
"command": "npx",
"args": ["-y", "sonarqube-mcp-server@latest"],
"env": {
"SONARQUBE_URL": "https://sonarcloud.io",
"SONARQUBE_TOKEN": "your-token-here",
"SONARQUBE_ORGANIZATION": "your-org (for SonarCloud)"
}
}
}
}
Alternative authentication methods:
Using Basic Authentication:
{
"mcpServers": {
"sonarqube": {
"command": "npx",
"args": ["-y", "sonarqube-mcp-server@latest"],
"env": {
"SONARQUBE_URL": "https://your-sonarqube.com",
"SONARQUBE_USERNAME": "your-username",
"SONARQUBE_PASSWORD": "your-password"
}
}
}
}
Using System Passcode:
{
"mcpServers": {
"sonarqube": {
"command": "npx",
"args": ["-y", "sonarqube-mcp-server@latest"],
"env": {
"SONARQUBE_URL": "https://your-sonarqube.com",
"SONARQUBE_PASSCODE": "your-system-passcode"
}
}
}
}
Ask Claude to analyze your SonarQube projects:
"List all my SonarQube projects"
"Show me critical issues in project xyz"
"What's the code coverage for project xyz?"
"Check the quality gate status for project xyz"
"Retrieve security hotspots in project xyz and create a plan to address them"
"Retrieve the issues for pr 123 in project xyz and create a plan to address them"
The simplest way to use the SonarQube MCP Server is through npx:
{
"mcpServers": {
"sonarqube": {
"command": "npx",
"args": ["-y", "sonarqube-mcp-server@latest"],
"env": {
"SONARQUBE_URL": "https://sonarqube.example.com",
"SONARQUBE_TOKEN": "your-sonarqube-token",
"SONARQUBE_ORGANIZATION": "your-organization-key"
}
}
}
}
Docker provides the most reliable deployment method by packaging all dependencies and ensuring consistent behavior across different environments.
Enterprise Deployment: For production deployments with Kubernetes, Helm charts, and cloud-specific configurations, see our comprehensive Deployment Guide.
For stdio transport (Claude Desktop):
{
"mcpServers": {
"sonarqube": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"SONARQUBE_URL",
"-e",
"SONARQUBE_TOKEN",
"-e",
"SONARQUBE_ORGANIZATION",
"sapientpants/sonarqube-mcp-server:latest"
],
"env": {
"SONARQUBE_URL": "https://sonarqube.example.com",
"SONARQUBE_TOKEN": "your-sonarqube-token",
"SONARQUBE_ORGANIZATION": "your-organization-key"
}
}
}
}
Official images are available on Docker Hub: sapientpants/sonarqube-mcp-server
Available tags:
latest - Latest stable release1.6.0 - Specific version (recommended for production)1.6 - Latest patch version of 1.6.x1 - Latest minor version of 1.x.xPull the image:
docker pull sapientpants/sonarqube-mcp-server:latest
With logging enabled:
{
"mcpServers": {
"sonarqube": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-v",
"/tmp/sonarqube-logs:/logs",
"-e",
"SONARQUBE_URL",
"-e",
"SONARQUBE_TOKEN",
"-e",
"SONARQUBE_ORGANIZATION",
"-e",
"LOG_FILE=/logs/sonarqube-mcp.log",
"-e",
"LOG_LEVEL=INFO",
"sapientpants/sonarqube-mcp-server:latest"
],
"env": {
"SONARQUBE_URL": "https://sonarqube.example.com",
"SONARQUBE_TOKEN": "your-sonarqube-token",
"SONARQUBE_ORGANIZATION": "your-organization-key"
}
}
}
}
Using Docker Compose:
version: '3.8'
services:
sonarqube-mcp:
image: sapientpants/sonarqube-mcp-server:latest
environment:
- SONARQUBE_URL=https://sonarqube.example.com
- SONARQUBE_TOKEN=${SONARQUBE_TOKEN}
- SONARQUBE_ORGANIZATION=${SONARQUBE_ORGANIZATION}
- LOG_FILE=/logs/sonarqube-mcp.log
- LOG_LEVEL=INFO
volumes:
- ./logs:/logs
stdin_open: true
tty: true
If you need to customize the server, you can build your own image:
# Clone the repository
git clone https://github.com/sapientpants/sonarqube-mcp-server.git
cd sonarqube-mcp-server
# Build the Docker image
docker build -t my-sonarqube-mcp-server .
# Run your custom image
docker run -i --rm \
-e SONARQUBE_URL="https://sonarqube.example.com" \
-e SONARQUBE_TOKEN="your-token" \
my-sonarqube-mcp-server
Version Pinning: Always use specific version tags in production:
sapientpants/sonarqube-mcp-server:1.6.0
Resource Limits: Set appropriate resource limits:
docker run -i --rm \
--memory="256m" \
--cpus="0.5" \
sapientpants/sonarqube-mcp-server:1.6.0
Security: Run as non-root user (default in our image):
docker run -i --rm \
--user node \
sapientpants/sonarqube-mcp-server:1.6.0
Health Checks: The container includes a health check that verifies the Node.js process is running
For development or customization:
{
"mcpServers": {
"sonarqube": {
"command": "node",
"args": ["/path/to/sonarqube-mcp-server/dist/index.js"],
"env": {
"SONARQUBE_URL": "https://sonarqube.example.com",
"SONARQUBE_TOKEN": "your-sonarqube-token",
"SONARQUBE_ORGANIZATION": "your-organization-key"
}
}
}
}
| Variable | Description | Required | Default |
|---|---|---|---|
| Token Authentication | |||
SONARQUBE_TOKEN |
Authentication token for SonarQube API access | ✅ Yes* | - |
| Basic Authentication | |||
SONARQUBE_USERNAME |
Username for Basic authentication | ✅ Yes* | - |
SONARQUBE_PASSWORD |
Password for Basic authentication | ✅ Yes* | - |
| System Passcode | |||
SONARQUBE_PASSCODE |
System passcode for SonarQube authentication | ✅ Yes* | - |
*One authentication method is required. Token authentication takes priority if multiple methods are configured.
| Variable | Description | Required | Default |
|---|---|---|---|
SONARQUBE_URL |
URL of your SonarQube instance | ❌ No | https://sonarcloud.io |
SONARQUBE_ORGANIZATION |
Organization key (required for SonarCloud) | ❌ No** | - |
LOG_FILE |
Path to write log files (e.g., /tmp/sonarqube-mcp.log) |
❌ No | - |
LOG_LEVEL |
Minimum log level (DEBUG, INFO, WARN, ERROR) | ❌ No | DEBUG |
**Required when using SonarCloud
By default, the server uses stdio transport for communication with Claude Desktop. For programmatic access or running as a web service, HTTP transport is available:
| Variable | Description | Required | Default |
|---|---|---|---|
MCP_TRANSPORT_TYPE |
Transport type (stdio or http) |
❌ No | stdio |
MCP_HTTP_PORT |
Port for HTTP server | ❌ No | 3000 |
MCP_HTTP_SESSION_TIMEOUT |
Session timeout in milliseconds | ❌ No | 1800000 |
MCP_HTTP_ALLOWED_HOSTS |
Comma-separated list of allowed hosts | ❌ No | localhost |
MCP_HTTP_ALLOWED_ORIGINS |
Comma-separated list of allowed CORS origins | ❌ No | * |
MCP_HTTP_ENABLE_DNS_REBINDING_PROTECTION |
Enable DNS rebinding protection | ❌ No | false |
The server supports three authentication methods, with important differences between SonarQube versions:
SonarQube 10.0+ (Bearer Token)
{
"env": {
"SONARQUBE_TOKEN": "your-token-here"
}
}
SonarQube < 10.0 (Token as Username)
SONARQUBE_USERNAME with the token value:
{
"env": {
"SONARQUBE_USERNAME": "your-token-here"
}
}
{
"env": {
"SONARQUBE_USERNAME": "your-username",
"SONARQUBE_PASSWORD": "your-password"
}
}
{
"env": {
"SONARQUBE_PASSCODE": "your-system-passcode"
}
}
Note: Token authentication takes priority if multiple authentication methods are configured. The server will automatically use the appropriate authentication strategy based on your SonarQube version.
For SonarCloud:
SONARQUBE_URL to https://sonarcloud.ioSONARQUBE_ORGANIZATION is requiredFor SonarQube Server:
SONARQUBE_URL to your instance URLSONARQUBE_ORGANIZATION is typically not neededThe server supports HTTP transport for programmatic access and web service deployments. This enables integration with custom clients and web applications.
Start the server with HTTP transport:
# Using environment variables
MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3000 npx sonarqube-mcp-server
# With Docker
docker run -i --rm \
-p 3000:3000 \
-e MCP_TRANSPORT_TYPE=http \
-e MCP_HTTP_PORT=3000 \
-e SONARQUBE_URL=https://sonarcloud.io \
-e SONARQUBE_TOKEN=your-token \
sapientpants/sonarqube-mcp-server:latest
When running in HTTP mode, the server exposes the following endpoints:
GET /health - Health check endpointPOST /session - Create a new sessionDELETE /session/:sessionId - Close a sessionPOST /mcp - Execute MCP requestsGET /events/:sessionId - Server-sent events for notificationsSee examples/http-client.ts for a complete TypeScript client example.
Basic usage with curl:
# Health check
curl http://localhost:3000/health
# Create session
SESSION_ID=$(curl -X POST http://localhost:3000/session | jq -r .sessionId)
# Execute MCP request
curl -X POST http://localhost:3000/mcp \
-H "Content-Type: application/json" \
-d "{
\"sessionId\": \"$SESSION_ID\",
\"method\": \"tools/list\",
\"params\": {}
}"
# Close session
curl -X DELETE http://localhost:3000/session/$SESSION_ID
When running in HTTP mode:
Enable DNS rebinding protection for public deployments:
MCP_HTTP_ENABLE_DNS_REBINDING_PROTECTION=true
Configure CORS for browser-based clients:
MCP_HTTP_ALLOWED_ORIGINS=https://yourapp.com,https://anotherapp.com
Set session timeouts appropriately:
MCP_HTTP_SESSION_TIMEOUT=900000 # 15 minutes
Use HTTPS in production (configure through a reverse proxy like nginx)
The server supports interactive user input through MCP's elicitation capability. This feature is opt-in and requires compatible MCP clients.
Environment Variables:
SONARQUBE_MCP_ELICITATION: Set to true to enable elicitationSONARQUBE_MCP_BULK_THRESHOLD: Number of items before confirmation (default: 5)SONARQUBE_MCP_REQUIRE_COMMENTS: Set to true to require comments for resolutionsSONARQUBE_MCP_INTERACTIVE_SEARCH: Set to true for interactive disambiguationExample Configuration:
{
"mcpServers": {
"sonarqube": {
"command": "npx",
"args": ["-y", "sonarqube-mcp-server@latest"],
"env": {
"SONARQUBE_URL": "https://sonarcloud.io",
"SONARQUBE_TOKEN": "your-token",
"SONARQUBE_MCP_ELICITATION": "true",
"SONARQUBE_MCP_BULK_THRESHOLD": "10",
"SONARQUBE_MCP_REQUIRE_COMMENTS": "true"
}
}
}
}
Features When Enabled:
Note: This feature requires MCP clients that support elicitation. Not all clients may support this capability.
The server supports file-based logging for debugging and monitoring. Since MCP servers use stdout for protocol communication, logs are written to a file instead of stdout/stderr to avoid interference.
Enable Logging:
{
"mcpServers": {
"sonarqube": {
"command": "npx",
"args": ["-y", "sonarqube-mcp-server@latest"],
"env": {
"SONARQUBE_URL": "https://sonarcloud.io",
"SONARQUBE_TOKEN": "your-token-here",
"SONARQUBE_ORGANIZATION": "your-org",
"LOG_FILE": "/tmp/sonarqube-mcp.log",
"LOG_LEVEL": "INFO"
}
}
}
}
Log Levels:
DEBUG: Detailed information for debuggingINFO: General information about server operationWARN: Warning events that might lead to issuesERROR: Error events (server continues running)Example Log Output:
2024-01-15T10:30:45.123Z INFO [index] Starting SonarQube MCP server
2024-01-15T10:30:45.234Z INFO [index] Environment variables validated successfully
2024-01-15T10:30:45.345Z INFO [index] SonarQube client created successfully
2024-01-15T10:30:45.456Z INFO [index] SonarQube MCP server started successfully
2024-01-15T10:30:50.123Z DEBUG [index] Handling SonarQube projects request
2024-01-15T10:30:50.567Z INFO [index] Successfully retrieved projects {"count": 5}
Different SonarQube tools require different permission levels:
Tools requiring Admin permissions:
projects - Lists all SonarQube projects with metadata (visibility, lastAnalysisDate, revision)Tools accessible to all users:
components - Search and navigate projects, directories, and files (requires 'Browse' permission on at least one project)For Administrators:
Use the projects tool to get full project metadata including visibility, last analysis date, and revision info.
For All Users:
Use the components tool with project qualifier:
components with qualifiers: ['TRK']components with query: 'mobile', qualifiers: ['TRK']The components tool provides a more accessible alternative for non-admin users to discover projects they have access to.
projectsList all SonarQube projects with pagination support.
Parameters:
page (optional): Page number for results paginationpage_size (optional): Number of items per pagemetricsGet available metrics from SonarQube.
Parameters:
page (optional): Page number for results paginationpage_size (optional): Number of items per pagemeasures_componentGet measures for a specific component.
Parameters:
component (required): Component keymetric_keys (required): Array of metric keysadditional_fields (optional): Additional fields to returnbranch (optional): Branch namepull_request (optional): Pull request keyperiod (optional): Period indexmeasures_componentsGet measures for multiple components.
Parameters:
component_keys (required): Array of component keysmetric_keys (required): Array of metric keysmeasures_componentpage (optional): Page numberpage_size (optional): Items per pagemeasures_historyGet measures history for a component.
Parameters:
component (required): Component keymetrics (required): Array of metric keysfrom (optional): Start date (YYYY-MM-DD)to (optional): End date (YYYY-MM-DD)branch (optional): Branch namepull_request (optional): Pull request keypage (optional): Page numberpage_size (optional): Items per pageissuesSearch and filter SonarQube issues by severity, status, assignee, tag, file path, and more. Critical for dashboards, targeted clean-up sprints, security audits, and regression testing. Supports faceted search for aggregations.
Component/File Path Filters:
project_key (optional): Single project key (backward compatible)projects (optional): Array of project keys for multi-project analysiscomponent_keys (optional): Array of component keys (file paths, directories, or modules) - use this to filter issues by specific files or folderscomponents (optional): Alias for component_keyson_component_only (optional): Boolean to return only issues on specified components, not sub-componentsBranch/PR Support:
branch (optional): Branch name for branch analysispull_request (optional): Pull request ID for PR analysisIssue Filters:
issues (optional): Array of specific issue keys to retrieveseverity (optional): Single severity (deprecated, use severities)severities (optional): Array of severities (INFO, MINOR, MAJOR, CRITICAL, BLOCKER)statuses (optional): Array of statuses (OPEN, CONFIRMED, REOPENED, RESOLVED, CLOSED)resolutions (optional): Array of resolutions (FALSE-POSITIVE, WONTFIX, FIXED, REMOVED)resolved (optional): Boolean filter for resolved/unresolvedtypes (optional): Array of types (CODE_SMELL, BUG, VULNERABILITY, SECURITY_HOTSPOT)Clean Code Taxonomy (SonarQube 10.x+):
clean_code_attribute_categories (optional): Array (ADAPTABLE, CONSISTENT, INTENTIONAL, RESPONSIBLE)impact_severities (optional): Array (HIGH, MEDIUM, LOW)impact_software_qualities (optional): Array (MAINTAINABILITY, RELIABILITY, SECURITY)issue_statuses (optional): Array of new issue status valuesRules and Tags:
rules (optional): Array of rule keystags (optional): Array of issue tags - essential for security audits, regression testing, and categorized analysisDate Filters:
created_after (optional): Issues created after date (YYYY-MM-DD)created_before (optional): Issues created before date (YYYY-MM-DD)created_at (optional): Issues created on date (YYYY-MM-DD)created_in_last (optional): Issues created in last period (e.g., "30d", "1m")Assignment:
assigned (optional): Boolean filter for assigned/unassignedassignees (optional): Array of assignee logins - critical for targeted clean-up sprints and workload analysisauthor (optional): Single author loginauthors (optional): Array of author loginsSecurity Standards:
cwe (optional): Array of CWE identifiersowasp_top10 (optional): Array of OWASP Top 10 categoriesowasp_top10_v2021 (optional): Array of OWASP Top 10 2021 categoriessans_top25 (optional): Array of SANS Top 25 categoriessonarsource_security (optional): Array of SonarSource security categoriessonarsource_security_category (optional): Additional security categoriesOther Filters:
languages (optional): Array of programming languagesfacets (optional): Array of facets to aggregatefacet_mode (optional): Facet aggregation mode ('effort' or 'count')since_leak_period (optional): Boolean for leak period filter (deprecated)in_new_code_period (optional): Boolean for new code period filterSorting:
s (optional): Sort field (e.g., 'SEVERITY', 'CREATION_DATE', 'UPDATE_DATE')asc (optional): Boolean for ascending sort direction (default: false)Response Control:
additional_fields (optional): Array of additional fields to includepage (optional): Page number for paginationpage_size (optional): Number of items per pageFaceted Search (Dashboard Support):
facets (optional): Array of facets to compute for aggregations. Available facets: severities, statuses, resolutions, rules, tags, types, authors, assignees, languages, etc.facet_mode (optional): Mode for facet computation: 'count' (number of issues) or 'effort' (remediation effort)Example Use Cases:
{
"project_key": "my-project",
"facets": ["severities", "assignees", "tags"],
"facet_mode": "count"
}
{
"project_key": "my-project",
"component_keys": ["src/auth/", "src/security/"],
"tags": ["security", "vulnerability"],
"severities": ["CRITICAL", "BLOCKER"],
"statuses": ["OPEN", "REOPENED"]
}
{
"project_key": "my-project",
"assignees": ["john.doe@example.com", "jane.smith@example.com"],
"statuses": ["OPEN", "CONFIRMED"],
"facets": ["severities", "types"],
"facet_mode": "effort"
}
{
"project_key": "my-project",
"component_keys": ["src/main/java/com/example/PaymentService.java"],
"on_component_only": true
}
componentsSearch and navigate SonarQube components (projects, directories, files). Supports text search, filtering by type/language, and tree navigation.
Search Parameters:
query (optional): Text search queryqualifiers (optional): Array of component types (TRK, DIR, FIL, UTS, BRC, APP, VW, SVW, LIB)language (optional): Programming language filterTree Navigation Parameters:
component (optional): Component key for tree navigationstrategy (optional): Tree traversal strategy ('all', 'children', 'leaves')Common Parameters:
asc (optional): Sort ascending/descendingps (optional): Page size (default: 100, max: 500)p (optional): Page numberbranch (optional): Branch namepullRequest (optional): Pull request IDComponent Qualifiers:
TRK: ProjectDIR: DirectoryFIL: FileUTS: Unit TestBRC: BranchAPP: ApplicationVW: ViewSVW: Sub-viewLIB: LibraryExample Use Cases:
{
"query": "UserService",
"qualifiers": ["FIL"]
}
{
"component": "my-project",
"qualifiers": ["UTS"]
}
{
"component": "my-project:src/main",
"strategy": "children",
"qualifiers": ["DIR", "FIL"]
}
{
"language": "java",
"qualifiers": ["FIL"],
"query": "Controller"
}
{
"qualifiers": ["TRK"]
}
hotspotsSearch for security hotspots with specialized filters for security review workflows.
Parameters:
project_key (optional): Project key to filter hotspotsbranch (optional): Branch name for branch analysispull_request (optional): Pull request ID for PR analysisstatus (optional): Hotspot status (TO_REVIEW, REVIEWED)resolution (optional): Hotspot resolution (FIXED, SAFE)files (optional): Array of file paths to filterassigned_to_me (optional): Boolean to show only assigned hotspotssince_leak_period (optional): Boolean for leak period filterin_new_code_period (optional): Boolean for new code period filterpage (optional): Page number for paginationpage_size (optional): Number of items per pagehotspotGet detailed information about a specific security hotspot including security context.
Parameters:
hotspot_key (required): The unique key of the hotspotReturns:
update_hotspot_statusUpdate the status of a security hotspot (requires appropriate permissions).
Parameters:
hotspot_key (required): The unique key of the hotspotstatus (required): New status (TO_REVIEW, REVIEWED)resolution (optional): Resolution when status is REVIEWED (FIXED, SAFE)comment (optional): Comment explaining the status changequality_gatesList available quality gates.
No parameters required.
quality_gateGet quality gate conditions.
Parameters:
id (required): Quality gate IDquality_gate_statusGet project quality gate status.
Parameters:
project_key (required): Project keybranch (optional): Branch namepull_request (optional): Pull request keysource_codeView source code with issues highlighted.
Parameters:
key (required): File keyfrom (optional): Start lineto (optional): End linebranch (optional): Branch namepull_request (optional): Pull request keyscm_blameGet SCM blame information for source code.
Parameters:
source_codesystem_healthGet the health status of the SonarQube instance.
No parameters required.
system_statusGet the status of the SonarQube instance.
No parameters required.
system_pingPing the SonarQube instance to check if it is up.
No parameters required.
markIssueFalsePositiveMark an issue as false positive.
Parameters:
issue_key (required): The key of the issue to markcomment (optional): Comment explaining why it's a false positivemarkIssueWontFixMark an issue as won't fix.
Parameters:
issue_key (required): The key of the issue to markcomment (optional): Comment explaining why it won't be fixedmarkIssuesFalsePositiveMark multiple issues as false positive in bulk.
Parameters:
issue_keys (required): Array of issue keys to markcomment (optional): Comment applying to all issuesmarkIssuesWontFixMark multiple issues as won't fix in bulk.
Parameters:
issue_keys (required): Array of issue keys to markcomment (optional): Comment applying to all issuesaddCommentToIssueAdd a comment to a SonarQube issue.
Parameters:
issue_key (required): The key of the issue to comment ontext (required): The comment text (supports markdown formatting)assignIssueAssign a SonarQube issue to a user or unassign it.
Parameters:
issueKey (required): The key of the issue to assignassignee (optional): Username of the assignee. Leave empty to unassign the issueExample usage:
{
"issueKey": "PROJECT-123",
"assignee": "john.doe"
}
"List all my SonarQube projects"
"Show me the code coverage for project xyz"
"What metrics are available for analysis?"
"Show me all critical bugs in project abc"
"Find security vulnerabilities in the main branch"
"List all code smells created in the last week"
"Show unresolved issues assigned to john.doe"
"Analyze issues in the feature/new-login branch"
"Compare issues between main and develop branches"
"Find issues across multiple projects: proj1, proj2, proj3"
"Show me issues sorted by severity in descending order"
"Find all issues with clean code impact on reliability"
"Find all files containing 'UserService' in their name"
"List all test files in my project"
"Show me the directory structure of src/main"
"Find all Java controller files"
"List all projects in SonarQube"
"Navigate to the authentication module"
"Search for TypeScript files in the frontend directory"
"Show me all directories under src/components"
"Assign issue PROJECT-123 to john.doe"
"Unassign issue PROJECT-456"
"Mark issue ABC-789 as false positive with comment: 'Test code only'"
"Add comment to issue XYZ-111: 'Fixed in commit abc123'"
"Bulk mark issues DEF-222, DEF-223 as won't fix"
"Check the quality gate status for my main project"
"Show me the code coverage history for the last month"
"What are the quality gate conditions?"
"Compare metrics between develop and main branches"
"Find all security hotspots that need review in project xyz"
"Show me hotspots in the authentication module"
"Get details for hotspot HSP-12345"
"List all hotspots assigned to me"
"Mark hotspot HSP-12345 as safe with explanation"
"Find hotspots in the new code period"
"Show security hotspots in pull request #42"
"Show me the source code for file xyz with issues highlighted"
"Get blame information for the problematic file"
"View issues in the authentication module"
"Check if SonarQube is running"
"What's the health status of the SonarQube instance?"
"Show me the system status"
The SonarQube MCP Server follows a modular architecture:
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Claude Desktop │────▶│ MCP Server │────▶│ SonarQube API │
│ (MCP Client) │◀────│ (index.ts) │◀────│ │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
▼
┌──────────────────┐
│ SonarQube │
│ Client │
│ (sonarqube.ts) │
└──────────────────┘
│
▼
┌──────────────────┐
│ API Module │
│ (api.ts) │
└──────────────────┘
index.ts): Main entry point that initializes the MCP server and registers all available toolssonarqube.ts): Handles business logic and parameter transformationapi.ts): Manages HTTP requests to the SonarQube APIgit clone https://github.com/sapientpants/sonarqube-mcp-server.git
cd sonarqube-mcp-server
pnpm install
pnpm build
# Install dependencies
pnpm install
# Build the project
pnpm build
# Run in development mode with auto-reload
pnpm dev
# Run tests
pnpm test
# Run tests with coverage
pnpm test:coverage
# Lint the code
pnpm lint
# Fix linting issues
pnpm lint:fix
# Check types
pnpm check-types
# Format code
pnpm format
# Run all validations
pnpm validate
# Inspect MCP schema
pnpm inspect
The project uses Jest for testing with:
nockRun specific test files:
NODE_ENV=test NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest src/__tests__/file-name.test.ts
The project maintains high code quality through:
SONARQUBE_ORGANIZATION to your configurationSONARQUBE_URL and network connectivityLOG_FILE and check the log file for detailed error messagesQ: Can I use this with both SonarQube and SonarCloud?
A: Yes! Set the appropriate SONARQUBE_URL and include SONARQUBE_ORGANIZATION for SonarCloud.
Q: What permissions does my token need? A: The token needs "Execute Analysis" permission and access to the projects you want to analyze.
Q: How do I filter issues by multiple criteria?
A: The issues tool supports extensive filtering. You can combine multiple parameters like severity, type, status, and date ranges.
Q: Can I analyze pull requests?
A: Yes! Many tools support branch and pull_request parameters for branch and PR analysis.
Error: "Authentication failed"
Error: "No SonarQube authentication configured"
SONARQUBE_TOKEN for token-based authentication (recommended)SONARQUBE_USERNAME and SONARQUBE_PASSWORD for basic authenticationSONARQUBE_PASSCODE for system passcode authenticationError: "Access denied"
Error: "Resource not found"
Error: "Connection refused"
Error: "Network error" or timeout errors
Error: "Rate limit exceeded"
Error: "Invalid SONARQUBE_URL"
https://sonarcloud.iohttps://sonarqube.example.comsonarcloud.io (missing protocol)https://sonarqube.example.com/ (trailing slash)Enable Debug Logging:
export LOG_LEVEL=DEBUG
Check Environment Variables:
echo $SONARQUBE_URL
echo $SONARQUBE_TOKEN
echo $SONARQUBE_ORGANIZATION
Test Connection:
Use the ping tool to verify connectivity:
# In your MCP client
sonarqube.ping
Verify Permissions:
Use the projects tool to list accessible projects:
# In your MCP client
sonarqube.projects
The server automatically retries failed requests for transient errors:
Retry delays: 1s → 2s → 4s (capped at 10s)
If you continue to experience issues:
We welcome contributions! Please see our Contributing Guidelines for details.
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by the SonarQube MCP Server community
Please log in to share your review and rating for this MCP.
{
"mcpServers": {
"sonarqube": {
"command": "npx",
"args": [
"-y",
"sonarqube-mcp-server"
],
"env": {
"SONARQUBE_URL": "<YOUR_SONARQUBE_URL>",
"SONARQUBE_TOKEN": "<YOUR_SONARQUBE_TOKEN>",
"SONARQUBE_ORGANIZATION": "<YOUR_ORGANIZATION_IF_USING_SONARCLOUD>"
}
}
}
}claude mcp add sonarqube npx -y sonarqube-mcp-serverExplore related MCPs that share similar capabilities and solve comparable challenges
by zed-industries
A high‑performance, multiplayer code editor designed for speed and collaboration.
by modelcontextprotocol
Model Context Protocol Servers
by modelcontextprotocol
A Model Context Protocol server for Git repository interaction and automation.
by modelcontextprotocol
A Model Context Protocol server that provides time and timezone conversion capabilities.
by cline
An autonomous coding assistant that can create and edit files, execute terminal commands, and interact with a browser directly from your IDE, operating step‑by‑step with explicit user permission.
by continuedev
Enables faster shipping of code by integrating continuous AI agents across IDEs, terminals, and CI pipelines, offering chat, edit, autocomplete, and customizable agent workflows.
by upstash
Provides up-to-date, version‑specific library documentation and code examples directly inside LLM prompts, eliminating outdated information and hallucinated APIs.
by github
Connects AI tools directly to GitHub, enabling natural‑language interactions for repository browsing, issue and pull‑request management, CI/CD monitoring, code‑security analysis, and team collaboration.
by daytonaio
Provides a secure, elastic infrastructure that creates isolated sandboxes for running AI‑generated code with sub‑90 ms startup, unlimited persistence, and OCI/Docker compatibility.