Skip to content

feat(sonarqube): SonarQube MCP quality gate integration#81

Merged
Enreign merged 3 commits intomainfrom
feat/sonarqube-mcp-integration
Mar 18, 2026
Merged

feat(sonarqube): SonarQube MCP quality gate integration#81
Enreign merged 3 commits intomainfrom
feat/sonarqube-mcp-integration

Conversation

@Enreign
Copy link
Copy Markdown
Collaborator

@Enreign Enreign commented Mar 16, 2026

Description

Integrates SonarQube into Sparks as a 3-phase quality gate loop:

Phase 1 (zero code change): Add the `sonarqube-mcp` Docker container to Sparks' MCP config — agents can call it for quality verification immediately.

Phase 2 (this PR): `src/sonarqube.rs` async client + `scripts/sonarqube_gate.py` CLI poller — mandatory gate before PRs open.

Phase 3 (future): Feed historical data into Cartograph's Dynamics layer as quality signals.

The workflow loop: write code → SonarQube MCP check → fix → repeat until clean → open PR.

Changes

  • `src/sonarqube.rs` — async `SonarClient` with `wait_for_gate()` polling, `GateResult`, `GateStatus`, failed condition reporting
  • `scripts/sonarqube_gate.py` — standalone Python CLI poller (stdlib only, no pip deps)
  • `docs/sonarqube-mcp.md` — complete setup guide for all 3 phases including MCP JSON config snippet
  • `src/config.rs` — `SonarqubeConfig` with server_url, token, project_key, organization, gate_timeout_secs, poll_interval_secs, block_on_failure
  • `config.example.toml` — `[sonarqube]` section

Type of Change

  • New feature

Pre-PR Checklist

  • `cargo check -q` passes
  • `cargo test -q` passes (397 tests)

Enreign and others added 3 commits March 18, 2026 23:06
Phase 1-2 implementation:
- SonarqubeConfig in config.rs with server_url, token, project_key, org, timeouts
- src/sonarqube.rs: async quality gate client with polling and failed condition reporting
- scripts/sonarqube_gate.py: standalone CLI poller for use in CI and pre-PR hooks
- docs/sonarqube-mcp.md: 3-phase integration guide (MCP config -> CI gate -> Cartograph signals)
- config.example.toml: [sonarqube] section with all fields documented

The MCP integration path (Phase 1) requires only adding the sonarqube-mcp Docker
container to Sparks' MCP config -- no code changes needed for basic agent access.
Phase 2 wires the quality gate into the CI pipeline before PR creation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…erry-pick merge

The cherry-pick from feat/memory-dedup-decay auto-merged config.rs and main.rs
in ways that lost the SonarqubeConfig struct, Serialize import, sonarqube field
in Config, and mod sonarqube declaration. This commit restores all of them.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
SonarQube and SonarCloud authenticate via HTTP Basic with the token as
the username and an empty password (base64(token:)).  The previous
bearer_auth call sent Authorization: Bearer <token>, which returns 401
on every request.  The Python poller (sonarqube_gate.py) already used
the correct Basic scheme; this aligns the Rust client with it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Enreign Enreign force-pushed the feat/sonarqube-mcp-integration branch from 1f52ea0 to 99e5e2e Compare March 18, 2026 22:07
@Enreign Enreign merged commit ac3bac2 into main Mar 18, 2026
4 checks passed
@Enreign Enreign deleted the feat/sonarqube-mcp-integration branch March 18, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant