sonarlint-mcp
Supports optional connected mode with SonarQube Cloud, using an organization and project key (with optional EU/US region) to apply cloud quality profiles to local scans.
Supports optional connected mode with a SonarQube Server, binding a project to an organization's quality profile and project key so local scans use the server-defined rule configuration.
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 scan src/ for SonarLint issues and show me the results"
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
Run SonarQube for IDE (formerly SonarLint) static analysis locally on any file, folder, or project, exposed as a Model Context Protocol (MCP) server.
sonarlint-mcp bundles the official SonarQube for IDE language server, the exact engine that powers the VS Code extension, and serves its results as structured, deterministic JSON over MCP. No SonarQube server required. Analysis runs entirely on your machine.
Why
The real engine, not a reimplementation. Scans are executed by the unmodified
sonarlint-lslanguage server and the same analyzer JARs SonarSource ships in the VS Code extension. Results match what the IDE extension shows.Local and offline. All analysis happens on your machine. SonarQube Server / SonarQube Cloud is only needed if you opt into connected mode to sync rule profiles.
Warm, persistent engine. The language server is spawned once per session and kept alive, mirroring VS Code's behavior. The first scan pays JVM warmup; every scan after that is fast.
Structured output. Compact JSON with rule key, severity, message, and exact line/column ranges: no markdown noise, no screenshots for a model to interpret.
Workspace-sandboxed by default. Paths are resolved against the client's workspace root and scans cannot read outside it. See Security.
16+ languages. Everything the VS Code extension ships with: JS/TS, Python, Java, C/C++, C#, Go, PHP, and more. See Language support.
Related MCP server: sonar-mcp
Requirements
Node.js 20 or newer
Java 17 or newer (tested with Java 21), on
PATHAny MCP client: VS Code (Copilot agent mode), Claude Code, Claude Desktop, Cursor, Windsurf, OpenCode, Codex, or any other client that supports local stdio servers
Install
Requires Node.js 20+ and Java 17+ on PATH. The first install downloads the SonarQube for IDE engine and all analyzers (~180 MB, one time); after that everything runs locally.
Run with npx (recommended):
npx -y sonarlint-mcp@latestOr install globally:
npm install -g sonarlint-mcpEither way, npm fetches the engine and analyzers automatically during install (a postinstall hook). You normally don't start the server yourself; your MCP client launches it from its configuration. See Getting started.
Build from source instead:
git clone https://github.com/t3rr11/sonarlint-mcp
cd sonarlint-mcp
npm install # also fetches the engine and analyzers
npm run buildGetting started
Most MCP clients use a standard stdio configuration with npx:
{
"mcpServers": {
"sonarlint": {
"command": "npx",
"args": ["-y", "sonarlint-mcp@latest"]
}
}
}On Windows, some clients need npx wrapped with cmd /c:
{
"mcpServers": {
"sonarlint": {
"command": "cmd",
"args": ["/c", "npx", "-y", "sonarlint-mcp@latest"]
}
}
}Follow the MCP install guide, or install via the CLI:
code --add-mcp '{"name":"sonarlint","command":"npx","args":["-y","sonarlint-mcp@latest"]}'claude mcp add sonarlint -- npx -y sonarlint-mcp@latestFollow the MCP install guide and use the standard config above.
Go to Cursor Settings → MCP → Add new MCP Server. Use command type with the command npx and the arguments -y sonarlint-mcp@latest.
opencode mcp add sonarlint --global -- npx -y sonarlint-mcp@latestOr in opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"servers": {
"sonarlint": {
"type": "local",
"command": ["npx", "-y", "sonarlint-mcp@latest"]
}
}
}
}The server uses the OpenCode workspace directory as its workspace root, so scans are project-scoped automatically.
If you built from source, point your client at the compiled server instead of npx:
{
"mcpServers": {
"sonarlint": {
"command": "node",
"args": ["/absolute/path/to/sonarlint-mcp/dist/index.js"]
}
}
}Tools
Tool | Description |
| Analyze a single file and return its issues. Parameters: |
| Analyze every analyzable file under a folder. Skips |
| Analyze the whole workspace, equivalent to a folder scan from the root. Parameters: |
| List the analysis rules currently active for the workspace (standalone or connected mode). |
| Get details for one rule: severity, type, description. Parameters: |
| Report engine state: whether the language server is running, the workspace root, and the cached analyzer version. |
Scan results are grouped by file with an issue summary by severity, plus a timedOut flag when the scan deadline (SONARLINT_SCAN_TIMEOUT_MS, default 180 s) was hit:
{
"file": "src/index.ts",
"totalIssues": 1,
"issues": [
{
"rule": "typescript:S3923",
"severity": "MAJOR",
"message": "Remove this pointless conditional.",
"line": 12, "column": 3, "endLine": 12, "endColumn": 14,
"url": "https://sonarsource.github.io/rspec/#/rspec/S3923"
}
]
}The typical agent workflow is: edit a file → sonarlint_scan_file → fix the reported issues → re-scan until clean. Use sonarlint_scan_project after larger refactors.
Configuration
Environment variables:
Variable | Default | Description |
|
| Location of the extracted language server and analyzer cache |
|
| Overall scan deadline in milliseconds |
| - | Path to a |
| - | Any value enables verbose LSP logging to stderr |
| - | Any value lifts the workspace-root confinement (see Security) |
Connected mode (optional)
By default the server runs in standalone mode: SonarQube for IDE's recommended rule set for each language. To use your organization's quality profile instead, bind to SonarQube Server or SonarQube Cloud.
Via environment variables:
Binding | Variables |
SonarQube Server (self-hosted) |
|
SonarQube Cloud |
|
Or via a workspace file, .sonarlint/connectedMode.json (the format the SonarQube for IDE VS Code extension uses):
{
"devopsBinding": { "connectionId": "my-conn", "projectKey": "org_my-project" },
"serverUrl": "https://sonarqube.mycompany.com"
}Authentication tokens are read from the SONAR_TOKEN environment variable and are never written to disk.
Language support
All analyzers shipped with the SonarQube for IDE VS Code extension are included:
Language | Notes |
JavaScript / TypeScript | Syntax- and symbol-based in standalone mode (no type checker), identical to the VS Code extension standalone. Uses the bundled |
Java | Includes symbolic execution analysis |
Python, Go, PHP | - |
C / C++ | Requires a compilation database ( |
C# | Analyzed via the bundled OmniSharp bridge |
HTML, CSS, JSON, XML | - |
Docker, Kubernetes, Terraform, CloudFormation, Azure Resource Manager | - |
Text, Secrets | Detects weak credentials and secrets in any file type |
Security
Paths passed to any tool are resolved against the MCP client's workspace root, and scans are confined to it: a scan cannot read arbitrary files elsewhere on the machine (such as credentials). sonarlint_get_rule and sonarlint_list_rules are read-only lookups.
sonarlint-mcp is a convenience boundary, not a security sandbox: set SONARLINT_ALLOW_ANY_PATH=1 to lift confinement, and rely on your MCP client's own permissions for true access control. The bundled language server and analyzers are official SonarSource artifacts, extracted from the sonarlint-vscode distribution; the install step fetches them from SonarSource's GitHub releases.
Known limitations
JS/TS standalone analysis is syntax- and symbol-based, without a type checker; the same behavior as the VS Code extension in standalone mode. Connected mode does not change this.
C/C++ requires a compilation database; there is no auto-discovery.
Security hotspots are published by the language server on a separate channel (
sonarlint/publishSecurityHotspots) and are not yet included in scan results.The first scan of a session includes JVM + analyzer warmup (~5-15 s). Subsequent scans in the same session are fast, as long as the MCP client keeps the server process alive.
Development
npm install # also fetches the engine and analyzers (postinstall)
npm run build # compile to dist/
npm run smoke # engine-level: scans test-fixtures, prints JSON
node scripts/mcp-smoke.mjs # full MCP protocol round-trip (spawns the server)To update the bundled engine and analyzers, run npm run setup -- --force: it fetches the latest sonarlint-vscode release and refreshes the cache manifest (sonarlint/manifest.json).
Release pipeline
GitHub Actions handle testing and publishing:
Tests (
tests.yml) runs on every pull request: installs dependencies (restoring the engine cache when available), builds, and runs both smoke tests.Create Release (
create-release.yml) is triggered manually from the Actions tab with a version tag (e.g.v1.0.0) and optional notes. It creates the tag and a draft GitHub release, then dispatches publishing.Publish (
publish.yml) runs on release dispatch, manual dispatch, or a manually pushedv*tag: it builds and publishes to npm, syncingpackage.jsonto the tag version.
Publishing authenticates with the NPM_TOKEN repository secret (a granular npm access token scoped to this package).
To publish a release by hand instead, run npm publish (the files whitelist keeps the ~180 MB engine cache out of the package; npm pack --dry-run shows what will ship).
Available Tools
6 toolssonarlint_get_ruleSonarLint: rule detailsA
Get details (severity, type, description) for a SonarLint rule key, e.g. 'typescript:S3923'.
Inputs: ruleKey (required).
sonarlint_list_rulesSonarLint: list rulesA
List the SonarLint rules currently active for the workspace.
Inputs: no named parameters.
sonarlint_scan_fileSonarLint: scan fileA
Run a local SonarLint (SonarQube for IDE engine) analysis on a single file and return code-quality, bug and security issues as JSON. Use after editing a file.
Inputs: path (required).
sonarlint_scan_folderSonarLint: scan folderB
Run a local SonarLint analysis on every analyzable file under a folder (skips node_modules, build dirs, .git, etc.). Returns issues grouped by file.
Inputs: folder, maxFiles.
sonarlint_scan_projectSonarLint: scan projectA
Run a local SonarLint analysis over the entire current workspace/project (equivalent to a full folder scan from the workspace root).
Inputs: maxFiles.
sonarlint_statusSonarLint: statusA
Report the state of the SonarLint engine: whether it is running, the workspace root, and the cached analyzer version.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Most tools have clearly distinct purposes: scanning a file, scanning a folder, scanning the project, listing rules, getting a rule, and checking status. The main overlap is between sonarlint_scan_folder and sonarlint_scan_project, since a project scan is essentially a folder scan from the workspace root; the descriptions clarify this, but an agent may still hesitate between them.
All tools share the sonarlint_ prefix and mostly follow a verb_noun pattern: scan_folder, scan_project, scan_file, get_rule, list_rules. The only minor deviation is sonarlint_status, which uses a noun-only form rather than a verb, but it is still readable and consistent with the overall prefix.
Six tools is well-scoped for a SonarLint analysis server. Each tool covers a distinct operation needed for scanning code and inspecting rules/status, with no obvious filler.
The surface covers the core lifecycle: scan individual files, folders, and the whole project, plus inspect active rules, get rule details, and check engine status. Minor gaps exist around configuring rule activation/exclusions or retrieving richer issue metadata/fixes, but agents can work around these for basic analysis workflows.
Maintenance
Related MCP Connectors
Scan any public GitHub MCP-server repo for security issues. 37 MCP-specific L1 rules, 8 languages.
Static MCP server scan: injection, secrets, tool poisoning. Report + SARIF + CI.
Scan AI agent skills, MCP server packages and MCP configs before you install them. Static analysis.
The official Svelte MCP server providing docs and autofixing tools for Svelte development
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceExposes Language Server Protocol (LSP) tools such as diagnostics, goto definition, find references, symbols, and rename as a stdio MCP server.8MIT
- AlicenseAqualityDmaintenanceA Model Context Protocol (MCP) server for interacting with SonarQube code quality platform.333 PyPI1MIT
- AlicenseNot gradedqualityAmaintenanceProvides comprehensive code quality analysis and automated fixing, available as a CLI and MCP server (currently in early beta with MCP part untested).1MIT
- FlicenseNot gradedqualityDmaintenanceEnables access to SonarQube code quality analysis through MCP, including issue searching, metrics retrieval, and quality gate status.-