# SonarQube (MCP Server)

> Bring SonarQube code quality and security findings into AI coding agents

- Type: MCP server
- Publisher: SonarSource (official)
- Categories: Security, Development
- Website: https://github.com/SonarSource/sonarqube-mcp-server
- Docs: https://docs.sonarsource.com/sonarqube-mcp-server/
- Source: https://github.com/SonarSource/sonarqube-mcp-server
- Transport: stdio
- Launch command: docker run --init --pull=always -i --rm -e SONARQUBE_TOKEN -e SONARQUBE_ORG sonarsource/sonarqube-mcp
- Sign-in: api-key
- Environment variables: SONARQUBE_TOKEN, SONARQUBE_ORG
- GitHub stars: 665
- Listed: 2025-04-30

## About

SonarSource's official SonarQube MCP server connects agents to SonarQube Cloud or SonarQube Server so they can check issues, quality gates and metrics, and analyze code snippets. It runs locally as a Docker container (stdio, with an optional HTTP mode) and authenticates with a SonarQube token plus your organization key or server URL. Toolsets and a read-only mode can limit what is exposed.

## Install

1. **Add the server to Codex**

   Codex CLI:

   ```bash
   codex mcp add sonarqube --env SONARQUBE_TOKEN=YOUR_SONARQUBE_TOKEN --env SONARQUBE_ORG=YOUR_SONARQUBE_ORG -- docker run --init --pull=always -i --rm -e SONARQUBE_TOKEN -e SONARQUBE_ORG sonarsource/sonarqube-mcp
   ```

   config.toml:

   ```toml
   [mcp_servers.sonarqube]
   command = "docker"
   args = ["run", "--init", "--pull=always", "-i", "--rm", "-e", "SONARQUBE_TOKEN", "-e", "SONARQUBE_ORG", "sonarsource/sonarqube-mcp"]
   
   [mcp_servers.sonarqube.env]
   SONARQUBE_TOKEN = "YOUR_SONARQUBE_TOKEN"
   SONARQUBE_ORG = "YOUR_SONARQUBE_ORG"
   ```

   Agents SDK:

   ```python
   from agents import Agent, Runner
   from agents.mcp import MCPServerStdio
   
   async with MCPServerStdio(
       name="SonarQube",
       params={"command": "docker", "args": ["run", "--init", "--pull=always", "-i", "--rm", "-e", "SONARQUBE_TOKEN", "-e", "SONARQUBE_ORG", "sonarsource/sonarqube-mcp"]},
   ) as server:
       agent = Agent(name="Assistant", mcp_servers=[server])
       result = await Runner.run(agent, "Does my project pass its quality gate?")
       print(result.final_output)
   ```

## Tools

- `analyze_code_snippet`
- `run_advanced_code_analysis`

## Example prompts

- "Does my project pass its quality gate?"
- "List the critical security issues in the backend project"
- "Analyze this function for bugs and code smells"
- "What's the test coverage trend on main?"

## Also available as

- plugin: [SonarQube](https://chatgptplugins.directory/plugins/sonarqube.md)

## Related

- [Chrome DevTools MCP](https://chatgptplugins.directory/mcp/chrome-devtools.md): Let coding agents control and debug a live Chrome browser
- [Playwright MCP](https://chatgptplugins.directory/mcp/playwright.md): Browser automation for agents via Playwright accessibility snapshots
- [GitHub](https://chatgptplugins.directory/mcp/github.md): Manage repos, issues, pull requests and Actions from your AI agent
- [Context7](https://chatgptplugins.directory/mcp/context7.md): Pull up-to-date, version-specific library docs into your coding agent
- [Supabase](https://chatgptplugins.directory/mcp/supabase.md): Manage Supabase databases, migrations, edge functions and logs
- [Stripe](https://chatgptplugins.directory/mcp/stripe.md): Query and act on your Stripe account and search Stripe docs from any agent

---
Source: https://chatgptplugins.directory/mcp/sonarqube · Index: https://chatgptplugins.directory/llms.txt · Independent and community-run. Not affiliated with or endorsed by OpenAI. ChatGPT is a trademark of OpenAI.
