Read-only MCP server for self-hosted SonarQube Community Build 26.4+: lets AI agents (Claude Code, Cursor, Copilot) read issues, security hotspots, rules and code snippets to fix findings locally
接入配置
选择客户端,复制配置,再按项目文档补齐环境变量。
claude mcp add sonar --env SONAR_URL='<SONAR_URL>' --env SONAR_TOKEN='<SONAR_TOKEN>' -- docker run -i --rm -e SONAR_URL -e SONAR_TOKEN ghcr.io/igorolv/sonar-mcp-server:0.1.0~/.codex/config.toml
[mcp_servers.sonar]
command = "docker"
args = ["run", "-i", "--rm", "-e", "SONAR_URL", "-e", "SONAR_TOKEN", "ghcr.io/igorolv/sonar-mcp-server:0.1.0"]
env = { SONAR_URL = "<SONAR_URL>", SONAR_TOKEN = "<SONAR_TOKEN>" }
# codex mcp add sonar --env SONAR_URL='<SONAR_URL>' --env SONAR_TOKEN='<SONAR_TOKEN>' -- docker run -i --rm -e SONAR_URL -e SONAR_TOKEN ghcr.io/igorolv/sonar-mcp-server:0.1.0~/.cursor/mcp.json
{
"mcpServers": {
"sonar": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"SONAR_URL",
"-e",
"SONAR_TOKEN",
"ghcr.io/igorolv/sonar-mcp-server:0.1.0"
],
"env": {
"SONAR_URL": "<SONAR_URL>",
"SONAR_TOKEN": "<SONAR_TOKEN>"
}
}
}
}.vscode/mcp.json
{
"servers": {
"sonar": {
"type": "stdio",
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"SONAR_URL",
"-e",
"SONAR_TOKEN",
"ghcr.io/igorolv/sonar-mcp-server:0.1.0"
],
"env": {
"SONAR_URL": "<SONAR_URL>",
"SONAR_TOKEN": "<SONAR_TOKEN>"
}
}
}
}~/.gemini/settings.json
{
"mcpServers": {
"sonar": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"SONAR_URL",
"-e",
"SONAR_TOKEN",
"ghcr.io/igorolv/sonar-mcp-server:0.1.0"
],
"env": {
"SONAR_URL": "<SONAR_URL>",
"SONAR_TOKEN": "<SONAR_TOKEN>"
}
}
}
}claude_desktop_config.json
{
"mcpServers": {
"sonar": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"SONAR_URL",
"-e",
"SONAR_TOKEN",
"ghcr.io/igorolv/sonar-mcp-server:0.1.0"
],
"env": {
"SONAR_URL": "<SONAR_URL>",
"SONAR_TOKEN": "<SONAR_TOKEN>"
}
}
}
}.trae/mcp.json
{
"mcpServers": {
"sonar": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"SONAR_URL",
"-e",
"SONAR_TOKEN",
"ghcr.io/igorolv/sonar-mcp-server:0.1.0"
],
"env": {
"SONAR_URL": "<SONAR_URL>",
"SONAR_TOKEN": "<SONAR_TOKEN>"
}
}
}
}需要的环境变量
SONAR_URLSONAR_TOKEN
把占位值换成你自己的密钥;不要把密钥提交到代码仓库。