MCP server for SonarQube code quality platform
Project description
SonarQube MCP Server
A Model Context Protocol (MCP) server for interacting with SonarQube code quality platform.
Features
- 18 MCP Tools for comprehensive SonarQube management
- Multi-instance support for managing multiple SonarQube servers
- Issue management - list, transition, comment, bulk operations
- Quality gates - check status, validate against goals
- Metrics - coverage, ratings, file-level analysis
- Project detection - auto-detect from git remote
Installation
# Using uv (recommended)
uv pip install sonar-mcp
# Using pip
pip install sonar-mcp
Configuration
Configure the MCP server in your Claude Code settings:
{
"mcpServers": {
"sonar-mcp": {
"command": "python",
"args": ["-m", "sonar_mcp"],
"env": {
"SONAR_TOKEN": "your-sonarqube-token",
"SONAR_URL": "https://sonarqube.example.com"
}
}
}
}
Environment Variables
| Variable | Description | Required |
|---|---|---|
SONAR_TOKEN |
SonarQube API token | Yes |
SONAR_URL |
SonarQube server URL | Yes |
Available Tools
Instance Management
sonar_manage_instance- Create, update, delete, or test instancessonar_list_instances- List all configured instancessonar_select_instance- Set the active instance
Project Operations
sonar_list_projects- List all accessible projectssonar_get_project- Get project details and metricssonar_detect_project- Auto-detect project from current directory
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
Quality Gates
sonar_get_quality_gate- Get quality gate status (OK/ERROR)sonar_check_goals- Validate against quality goals
Metrics
sonar_get_metrics- Get project metricssonar_get_coverage- Get coverage percentagesonar_get_file_coverage- Get file-level coverage details
Rules
sonar_get_rule- Get rule details and remediation guidance
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 specific test file
pytest tests/unit/test_client.py -v
# Run with coverage enforcement (80% minimum)
pytest tests/ -v --cov=src/sonar_mcp --cov-fail-under=80
Linting
# Check linting
ruff check src/ tests/
# Auto-fix issues
ruff check src/ tests/ --fix
# Format code
ruff format src/ tests/
# Type checking
mypy src/
Quality Gates
Before committing, ensure all quality gates pass:
# All-in-one check
ruff check src/ tests/ && \
ruff format --check src/ tests/ && \
mypy src/ && \
pytest tests/ -v --cov=src/sonar_mcp --cov-fail-under=80
Architecture
src/sonar_mcp/
├── __init__.py # Package initialization
├── __main__.py # Entry point
├── server.py # MCP server core
├── instance_manager.py # Multi-instance management
├── types.py # Type definitions
├── auth/ # Token management
├── client/ # SonarQube API client
├── config/ # Configuration models
├── models/ # Data models (Issue, Metric, Project)
├── tools/ # MCP tools (18 total)
└── utils/ # Utilities (logging)
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sonar_mcp-1.0.0.tar.gz.
File metadata
- Download URL: sonar_mcp-1.0.0.tar.gz
- Upload date:
- Size: 53.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d74efb45a0474ba34a50c789712a4bb6aa1f75b4c64cda6f3abb19259dc3325d
|
|
| MD5 |
2c8dfabdf7a4cfc442c572db028c2c35
|
|
| BLAKE2b-256 |
deed13cb57ec1d48a8b618695a1b1bf5b29ee68d5381e90cbf49c942a2d99be6
|
File details
Details for the file sonar_mcp-1.0.0-py3-none-any.whl.
File metadata
- Download URL: sonar_mcp-1.0.0-py3-none-any.whl
- Upload date:
- Size: 59.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c45182b428b5a6b827802bec0ee9c09d82513f5a428249b4c9532043b836f9e
|
|
| MD5 |
2d0e1163227ef1f850df075b22fac1d4
|
|
| BLAKE2b-256 |
1f595ff898d644f994c7461dc3cdd32336ed52d5f95a8688f9a7db453171777c
|