MCP integration for SonarCloud/SonarQube
npm install mcp-sonar~/.cursor/mcp.json.
json
{
"mcpServers": {
"mcp-sonar": {
"command": "npx",
"args": ["mcp-sonar@latest"],
"env": {
"SONAR_TOKEN": "your_sonar_token_here",
"SONAR_PROJECT": "your_project_key",
"SONAR_ORGANIZATION": "your_organization"
}
}
}
}
`
Option 2: global install and direct binary:
`bash
npm install -g mcp-sonar
`
`json
{
"mcpServers": {
"mcp-sonar": {
"command": "mcp-sonar",
"env": {
"SONAR_TOKEN": "your_sonar_token_here",
"SONAR_PROJECT": "your_project_key",
"SONAR_ORGANIZATION": "your_organization"
}
}
}
}
`
Restart Cursor after editing mcp.json.
$3
- Go to https://sonarcloud.io
- My Account -> Security -> Generate Tokens
- Create a token with Analyze permissions
Environment variables
- SONAR_TOKEN: required
- SONAR_BASE: optional, default https://sonarcloud.io
- SONAR_PROJECT: optional default project
- SONAR_ORGANIZATION: optional default organization
Tools
$3
Parse a SonarCloud PR issues URL and fetch issues. This is the primary tool for most use cases.
Usage:
`
Use mcp-sonar and retrieve issues from https://sonarcloud.io/project/issues?id=your_project&pullRequest=123&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true
`
$3
Search PR issues using explicit parameters. Use only when URL parsing is not possible.
Parameters:
- pullRequest (required): Pull request number
- componentKeys (optional): Project key; defaults to SONAR_PROJECT
- organization (optional): Org key; defaults to SONAR_ORGANIZATION
- statuses (optional): Statuses filter (e.g., "OPEN,CONFIRMED" or ["OPEN","CONFIRMED"])
- sinceLeakPeriod (optional): Defaults to true when not provided
Development
`bash
git clone https://github.com/lom200/mcp-sonar.git
cd mcp-sonar
npm install
npm run build
node dist/index.js
``