SonarLint MCP Server
Provides real-time code analysis for JavaScript, TypeScript, and Python projects, detecting bugs, code smells, and security vulnerabilities using SonarLint's standalone backend.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@SonarLint MCP Server Analyze this TypeScript file for code smells: src/component.ts"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
SonarLint MCP Server
A Model Context Protocol (MCP) server that brings enterprise-grade code analysis to Claude Desktop and other MCP clients using SonarLint's standalone SLOOP backend.
Features
π Real-time Code Analysis - Detect bugs, code smells, and security vulnerabilities
π Fast & Standalone - No IDE or SonarQube server required
π¦ Multiple Languages - JavaScript, TypeScript, Python (265+ JS rules)
πΎ Session Storage - Results stored in memory for multi-turn conversations
π§ Quick Fixes - Automated suggestions for common issues
π― Batch Analysis - Analyze multiple files efficiently
Related MCP server: CodeHealth MCP
Quick Start
Prerequisites
Node.js 22 or higher
Claude Desktop (or any MCP client)
Installation
No installation required! Use npx to run directly:
npx @nielspeter/sonarlint-mcp-serverThe SLOOP backend (~70MB) downloads automatically on first run.
From Source (for development):
git clone https://github.com/nielspeter/sonarlint-mcp-server.git
cd sonarlint-mcp-server
npm install # Auto-downloads SLOOP backend (~70MB)
npm run buildConfigure with Claude Code
Use the Claude CLI to add the MCP server:
claude mcp add --transport stdio sonarlint -- npx -y @nielspeter/sonarlint-mcp-serverThis automatically updates your Claude Code configuration. No restart needed!
Configure with Claude Desktop
Add to your claude_desktop_config.json:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"sonarlint": {
"command": "npx",
"args": ["-y", "@nielspeter/sonarlint-mcp-server"]
}
}
}Restart Claude Desktop to apply changes.
Rule Configuration
Customize SonarLint rules per project by creating a sonarlint.json in your project root:
{
"rules": {
"typescript:S3776": {
"level": "on",
"parameters": {
"threshold": "20"
}
},
"javascript:S1481": {
"level": "off"
}
}
}level:"on"(default) or"off"to enable/disable a ruleparameters: Override rule thresholds and settings (see configurable rules)Fallback: If no
sonarlint.jsonis found,.sonarlint/settings.jsonis checked (IDE convention)
Copy sonarlint.example.json from this repo as a starting point. Use list_rules to discover available rules and their configurable parameters.
Usage
Once configured, Claude can analyze your code:
Analyze my JavaScript file for code quality issues: /path/to/file.jsCheck these files for bugs: src/app.ts, src/utils.tsAnalyze this code snippet:
function process(data) {
var result = data; // Issues with 'var'
return result;
}Available Tools
Tool | Description |
| Check a file for code quality issues |
| Check multiple files in one call |
| Check a code snippet (no file on disk needed) |
| Automatically fix one specific issue |
| Automatically fix all fixable issues in a file |
| List all active code quality rules |
| Check server status and diagnostics |
Example Analysis Output
{
file: "/path/to/file.js",
language: "javascript",
issues: [
{
line: 4,
column: 2,
severity: "MAJOR",
rule: "javascript:S3504",
message: "Unexpected var, use let or const instead.",
quickFix: {
message: "Replace with 'const'",
edits: [...]
}
}
],
summary: {
total: 5,
critical: 0,
major: 3,
minor: 2
}
}Supported Languages
Language | Extensions | Rules |
JavaScript |
| 265 |
TypeScript |
| 265 |
Python |
| ~100 |
Architecture
Claude Desktop
β MCP Protocol (stdio)
SonarLint MCP Server (this project)
β JSON-RPC
SLOOP Backend (SonarLint Local Operations)
β Plugin API
Language Analyzers (JS/TS, Python)The server uses SonarLint's standalone SLOOP backend with:
Version: 10.32.0.82302 (WebStorm-compatible)
Bundled JRE: Java 17
Bi-directional RPC: Client request handlers implemented
Session Storage: Results stored in memory for multi-turn conversations
SLOOP Integration: Scope Lifecycle
SLOOP requires a specific initialization sequence. Getting this wrong causes analysis to hang:
Pre-register files β Store file DTOs in
scopeFilesmap before creating the scope. SLOOP callslistFilessynchronously during scope creation, so files must already be available.Create scope β Send
addConfigurationScopenotification to SLOOP.Wait for readiness β SLOOP sends
didChangeAnalysisReadinesswhen the scope is ready. Analysis requests before this point will fail silently.Analyse β Call
analyzeFilesAndTrackwith the files.
Key design decisions:
No directory scanning in
listFilesβ Only return the specific files requested for analysis. Scanning the project root returned 500+ files on real projects and caused multi-minute hangs.getBaseDirreturns project root β Detected viapackage.json,.git, etc. SLOOP uses this for.gitignorematching and file exclusion patterns.ideRelativePathrelative to project root β SLOOP'sWildcardPattern.matchrequires this; null values cause NPEs.
Development
# Install dependencies (auto-downloads backend)
npm install
# Build
npm run build
# Run tests
npm test
# Watch mode (auto-rebuild)
npm run dev
# Inspect with MCP Inspector
npm run inspectTesting
# Run test suite
npm test
# Run with UI
npm run test:ui
# Run with coverage
npm run test:coverageTests validate:
SLOOP bridge functionality
File and content analysis
JavaScript and Python plugin detection
Quick fix support
Error handling
Documentation
SETUP.md - Detailed installation guide
TROUBLESHOOTING.md - Common issues and solutions
docs/configurable-rules.md - All 84 configurable rules with parameters and defaults
docs/SLOOP_RPC_PROTOCOL.md - Complete RPC protocol documentation
docs/TESTING.md - Testing guide
Technical Highlights
This project demonstrates several key technical achievements:
Standalone SLOOP - First documented standalone use of SonarLint's SLOOP backend
Bi-directional RPC - Complete client request handler implementation
MCP Integration - Full Model Context Protocol implementation with resources
Session Management - Results storage for multi-turn conversations
Production Ready - Comprehensive testing, error handling, and monitoring
Critical Implementation Details
For anyone using SLOOP programmatically:
listFilesmust returnClientFileDtowith file content (not just URIs)isUserDefined: trueis mandatory (SLOOP filters out false values)bundlePathshould be parent directory (SLOOP appends/package/bin/server.cjs)Client must implement 4 request handlers (listFiles, getBaseDir, etc.)
backendCapabilitiesrequired for proper initialization
Why This Approach?
Advantages
β No IDE dependency - runs completely standalone
β Full API access - all SLOOP services available
β Better control - configure for specific needs
β More reliable - direct process communication
β CI/CD capable - can run in automated environments
β Faster - no IDE overhead
Comparison to IDE Integration
We initially investigated connecting to IDE servers (WebStorm port 64120) but discovered:
IDE server is only for "Open in IDE" from SonarQube Server/Cloud
Limited API access
IDE must be running
Not suitable for programmatic access
Related Projects
SonarQube MCP Server - Official server for SonarQube Server/Cloud APIs
Complementary approach requiring server setup
This project provides local, standalone analysis
Contributing
Contributions welcome! Areas for improvement:
Additional language support (Java, Go, PHP)
Custom rule development
Performance optimizations
CI/CD integrations
License
MIT License - see LICENSE
Acknowledgments
SonarSource for building SLOOP and SonarLint
Anthropic for the Model Context Protocol
Claude Code for enabling this development
Status: β Production Ready - All phases complete with comprehensive testing
Available Tools
7 toolscheck_codeA
Check code quality of a code snippet or content you have in hand β catches bugs, code smells, security issues, and complexity problems. Use to validate code before writing it to disk, review generated code, or check code you've read into context. No file on disk needed.
Inputs: content (required), language (required), fileName.
check_filesA
Check multiple files for code quality issues in one call β bugs, code smells, security vulnerabilities. Use when reviewing or modifying several files. Supports glob patterns (e.g. 'src/**/*.ts'). When using relative paths or globs, provide basePath so they resolve correctly. Output is compact: only files with issues are shown, clean files get a summary count. For a single file use check_quality.
Inputs: filePaths (required), basePath, groupByFile, minSeverity, +1 more.
check_qualityA
Check a file for code quality issues β bugs, code smells, security vulnerabilities, and complexity problems. Like having SonarLint in your IDE. Use after writing or modifying code to catch issues early. Returns issues with exact line numbers, severity, and available quick fixes. For multiple files use check_files.
Inputs: filePath (required), minSeverity, excludeRules.
fix_all_issuesA
Automatically fix all code quality issues in a file that have available quick fixes. Applies all SonarLint-suggested fixes in one operation. Returns what was fixed and what remains (some issues require manual fixes like reducing complexity).
Inputs: filePath (required).
fix_issueA
Automatically fix one specific code quality issue. Applies the SonarLint-suggested fix for the issue at the given file, line, and rule. The file is modified directly. To fix all issues in a file at once, use fix_all_issues instead.
Inputs: line (required), rule (required), filePath (required).
health_checkA
Check if the code quality analysis backend is running and healthy. Shows installed language plugins, cache stats, and version info. Use to diagnose when analysis isn't working as expected.
Inputs: no named parameters.
list_rulesA
List all active code quality rules with ID, name, and severity. Use to look up what a rule means (e.g., S3776 = Cognitive Complexity), discover what issues can be detected, or see which rules apply to a language. Covers bugs, code smells, security vulnerabilities, and security hotspots.
Inputs: language.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 7 tools
Each tool has a clearly distinct purpose: checking snippets vs single file vs multiple files, fixing all vs single issue, health check, and listing rules. No ambiguity.
All tool names follow a consistent verb_noun pattern (check_code, check_files, check_quality, fix_all_issues, fix_issue, health_check, list_rules) using snake_case.
7 tools is well-scoped for a code quality server, covering analysis, fixing, health, and rule listing without being too few or too many.
Covers core operations: code checking (snippet, single, batch), fixing (all or specific), health monitoring, and rule listing. Minor gaps like per-rule details, but overall complete.
Maintenance
Related MCP Connectors
FixMyPrompt is a remote MCP server for coding agents. It saves the steps your agent worked out as project memories and fetches them in later sessions, scores and rewrites prompts, and checks CLAUDE.md and AGENTS.md files. Works with Claude Code, Codex and Cursor. Free plan available.
AI code review for GitHub PRs with an MCP autofix loop for Claude Code and Cursor
295k+ bug-fix patterns with MCP Hub proxy, PII filtering, and code search
Zero-config MCP security scanner for AI-generated apps. 25K+ vulnerability patterns.
Related MCP Servers
- AlicenseCqualityDmaintenanceEnables AI-powered automated testing, security scanning, code review, and maintenance tasks directly within Claude Code or desktop.1245 PyPI4MIT
- AlicenseAqualityAmaintenanceAI-powered codebase health analysis β detects dead code, circular dependencies, coupling issues, and architectural drift. 6 MCP tools for Claude Desktop, Cursor, Windsurf, and Slack.665 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables LLM-powered code analysis, generation, debugging, and context management through MCP integration with IDEs like Cursor and Claude Desktop.MIT
- AlicenseNot gradedqualityDmaintenanceProvides security scanning tools for Claude Code, enabling real-time vulnerability detection, code analysis, and rule explanations for codebases.MIT