sonar-mcp
SonarQube MCP Server
A Model Context Protocol (MCP) server for interacting with SonarQube code quality platform.
Features
21 SonarQube tools organized into 7 categories, accessible via dispatch pattern
6 MCP Prompts for code review, security audits, and quality reports
7 MCP Resources for browseable URI-based access to SonarQube data
Multi-instance support for managing multiple SonarQube servers
HTTP transport modes - stdio, SSE, and streamable-http
Installation
# Using pip
pip install sonar-mcp
# Using uv (recommended)
uv pip install sonar-mcpQuick Start
1. Configure for Claude Code
Add to your Claude Code MCP settings:
{
"mcpServers": {
"sonar-mcp": {
"command": "sonar-mcp",
"env": {
"SONAR_TOKEN": "your-sonarqube-token",
"SONAR_URL": "https://sonarqube.example.com"
}
}
}
}2. Use the Tools
The server uses a dispatch pattern (similar to GitLab MCP) with just 3 meta-tools:
# Discover available tools by category
sonar_list_categories()
sonar_list_categories(category="issue") # Filter to specific category
# Get parameter schema for a tool
sonar_get_tool_schema(tool_name="sonar_list_issues")
# Execute any tool by name
sonar_execute_tool(tool_name="sonar_list_projects")
sonar_execute_tool(tool_name="sonar_list_issues", arguments={"project": "my-project"})Running the Server
Stdio Mode (Default)
For Claude Code and other MCP clients that use stdio transport:
sonar-mcp
# or
python -m sonar_mcpStreamable HTTP Mode
For web-based clients or remote access:
# Start server on default port 8000
sonar-mcp --transport streamable-http
# Custom host and port
sonar-mcp --transport streamable-http --host 0.0.0.0 --port 3000
# Using environment variables
SONAR_MCP_TRANSPORT=streamable-http SONAR_MCP_PORT=3000 sonar-mcpSSE Mode (Server-Sent Events)
For clients that support SSE transport:
sonar-mcp --transport sse --port 8000Command Line Options
Option | Description | Default |
| Transport protocol: |
|
| Host address for HTTP transports |
|
| Port for HTTP transports |
|
| Show version and exit | - |
Environment Variables
Variable | Description | Required |
| SonarQube API token | Yes |
| SonarQube server URL | Yes |
| Default transport mode | No |
| Default host for HTTP | No |
| Default port for HTTP | No |
Available Tools
Dispatch Meta-Tools (3 tools, always available)
These 3 tools provide access to all SonarQube functionality:
Tool | Description |
| Discover available tools by category |
| Get parameter schema for a specific tool |
| Execute any tool by name with arguments |
Category: instance (4 tools)
Instance management for SonarQube server connections:
sonar_list_instances- List all configured instancessonar_manage_instance- Create, update, delete instancessonar_select_instance- Set the active instancesonar_test_connection- Test instance connectivity
Category: project (3 tools)
Project operations:
sonar_list_projects- List all accessible projectssonar_get_project- Get project details and metricssonar_detect_project- Auto-detect project from current directory
Category: issue (5 tools)
Issue management:
sonar_list_issues- List issues with filtering (severity, type, status)sonar_get_issue- Get detailed issue informationsonar_transition_issue- Change issue status (resolve, falsepositive, etc.)sonar_add_comment- Add a comment to an issuesonar_bulk_transition- Bulk transition multiple issues
Category: quality (2 tools)
Quality gate operations:
sonar_get_quality_gate- Get quality gate status (OK/ERROR)sonar_check_goals- Validate against quality goals
Category: metrics (3 tools)
Metrics retrieval:
sonar_get_metrics- Get project metricssonar_get_coverage- Get coverage percentagesonar_get_file_coverage- Get file-level coverage details
Category: rules (1 tool)
Rule information:
sonar_get_rule- Get rule details and remediation guidance
Category: task (3 tools)
Async task management:
sonar_get_task- Get task statussonar_list_tasks- List background taskssonar_cancel_task- Cancel a running task
MCP Resources
Browseable URI-based access to SonarQube data:
URI Pattern | Description |
| List all projects |
| Get project details |
| Get project issues |
| Get issues by severity |
| Get project metrics |
| Get quality gate status |
MCP Prompts
Reusable prompt templates for code quality workflows:
Prompt | Description |
| Review code issues and suggest fixes |
| Generate fix recommendations for issues |
| Generate quality report for a project |
| Check project against quality goals |
| Perform security vulnerability audit |
| Generate fixes for security vulnerabilities |
Development
Setup
# Clone the repository
git clone https://github.com/wadew/sonar-mcp.git
cd sonar-mcp
# Create virtual environment
uv venv
source .venv/bin/activate
# Install dependencies
uv pip install -e ".[dev]"Testing
# Run all tests with coverage
pytest tests/ -v --cov=src/sonar_mcp --cov-report=term-missing
# Run with coverage enforcement (80% minimum)
pytest tests/ -v --cov=src/sonar_mcp --cov-fail-under=80Linting
# Check linting
ruff check src/ tests/
# Format code
ruff format src/ tests/
# Type checking
mypy src/License
MIT License - see LICENSE for details.
Contributing
Follow TDD (Test-Driven Development) - write tests first
Maintain 80% coverage on ALL modules
Ensure all linting and type checks pass
Use conventional commits
See CONTRIBUTING.md for detailed guidelines.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/wadew/sonar-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server