Code Quality
Issues, security hotspots, rules and quality profiles to triage code findings.
Project Insights
Measures, metric definitions, history, quality-gate status and analyses.
Admin & Operations
Projects, organizations, branches, webhooks, user tokens and SVG badges.
Who is this for?
This connector is used by three different roles. Jump to the section that matches yours; each one is self-contained.Agent builder
You build agents in Agent Creator and want them to use SonarQube. → Agent builder tab.
Platform admin
You run the platform and set up SonarQube once for everyone. → Platform admin setup accordion below.
Workspace builder
You write Builder automations (DSUL) that call SonarQube operations directly. → Workspace builder tab.
Prerequisites
- A SonarQube Server (self-hosted) or a SonarQube Cloud account.
- A User Token (type User token, not an analysis token) generated in My Account > Security > Generate Tokens: one shared token for the workspace, or one per user in per-user mode (see Authentication modes in the Workspace builder tab).
- The API base URL of your instance:
- SonarQube Cloud:
https://sonarcloud.io/api - Self-hosted:
https://<your-sonarqube-host>/api
- SonarQube Cloud:
- For SonarQube Cloud only: the organization key that owns your projects (most search and create operations require it; use
searchOrganizationsto discover the keys visible to your token). - Prisme.ai platform 27.5.7 or later. The SonarQube API must be reachable from the platform’s runtime.
The connector always tries Basic first and falls back to Bearer on a
401, so you never pick a scheme: SonarQube Server before 10.0 only accepts Basic, SonarQube Cloud documents Bearer. Server versions older than 9.9 are not tested.
Platform admin (Governance): one-time platform setup
Platform admin (Governance): one-time platform setup
Goal: SonarQube is a per-workspace connector: each workspace that installs it chooses its authentication mode and owns its credentials (see the Workspace builder tab), so there is no platform-wide credential to provision and no central OAuth client. The only optional platform task is to make a workspace’s SonarQube connector available in the Capabilities catalog.
The simplest path is the Add to catalog button in the connector’s configuration app (Agents tab): it creates the catalog entry with the right MCP endpoint, scope and, in per-user mode, the connect/status/disconnect URLs. Declare the capability by hand only if you cannot use that button.
Declare the capability in AI Governance by hand (optional)
1
Open AI Governance > Capabilities
Create (or edit) the SonarQube capability.
2
Point it at the MCP endpoint
Set the capability’s MCP server URL to the connector’s MCP endpoint, shown in the configuration app (Agents tab). It has the form The
https://<api-host>/v2/workspaces/slug:<workspace>/webhooks/<instance>.mcp. Set its Scope to:agent_id in the scope is what lets the connector identify the calling agent; the agent must also be allowed in the configuration app (Agents tab).3
Per-user mode only: add the connection URLs
In per-user mode, each user connects their own SonarQube token. The capability needs an There is no OAuth flow behind these names:
auth block of type oauth2 with an empty scope list and these three URLs, all on the same instance:connect_url opens a form where the user pastes their own SonarQube token. Encode spaces in the instance name as %20.4
Make it available to agent builders
Once created, the capability appears in the capability picker for agent builders in your organization, who enable it on their agents. Access to the catalog follows your organization’s existing roles.
- Agent builder (Agent Creator)
- Workspace builder (DSUL)
Agent builder
Goal: let an agent you build in Agent Creator read and act on SonarQube code-quality data through MCP tools.Before an agent can call the connector, a Workspace builder must have installed and configured the SonarQube app in a workspace (see the Workspace builder tab). Optionally, a Platform admin may have published a SonarQube capability in AI Governance (see the Platform admin setup accordion above).
1
Install and configure the connector in a workspace
Follow the Workspace builder tab: install SonarQube in a workspace, open its configuration app and set the authentication mode and API base URL.
2
Add the MCP capability to your agent
In the configuration app, open the Agents tab, tick your agent and click Install capability. This adds the MCP tool with the right endpoint and scope (
context_id,agent_id,user_id), plus the per-user connection URLs in per-user mode. Alternatively, pick the SonarQube capability from the catalog if an administrator published it.3
Per-user mode: connect your SonarQube token
On the first use, Agent Creator shows a Connect button on the SonarQube capability. It opens a form where you paste your own SonarQube User token; the connector checks it against SonarQube before storing it in your personal secrets. Every tool call then runs with your SonarQube permissions. Use Disconnect to remove it.
4
Brief the agent in its system prompt
Wiring the capability is not enough: the agent also needs to know the MCP exists and when to reach for it. Add a short paragraph to the agent’s system prompt. Copy-pasteable starter:Refine the trigger keywords (project keys, branch names, rule families) so the agent reliably picks up the right intent in your context.
Legacy AI Knowledge agents (no native MCP picker): add the connector under Advanced > Tools > MCP and paste the MCP endpoint URL shown in the configuration app (Agents tab). Newer Agent Creator agents use the native capability picker described above.
Available Tools
System & Authentication
Organizations
Projects
Components
Issues
Measures & Metrics
Quality Gates
Quality Profiles & Rules
Hotspots
User Tokens
Analyses & Branches
Webhooks
Badges
Output Formats
Every tool accepts anoutputFormat argument that controls the MCP response shape:verbose(default): human-readable text for LLM consumptionstructured: machine-readable JSON instructuredContentboth: both text and structured content
Tool Details
searchIssues
Search and filter issues on a project. Default response includes all issues the token can see; combine filters to scope down.searchOrganizations
Discover the SonarCloud organization keys your token can see; call this first when you do not know theorganization value other tools require.transitionIssue
Move an issue through SonarQube’s workflow.getComponentMeasures
Read one or several metric values for a component (project, file, directory).getProjectQualityGateStatus
Useful as a one-shot pass/fail check for CI gates.createProject
Provision a new project. On SonarCloud,organization is required.Migrating from the previous version
Earlier versions of the SonarQube app used a central MCP endpoint (/workspaces/slug:sonarqube/webhooks/mcp) authenticated with an mcp-api-key header, and stored the token in the instance configuration (token, bound to the workspace secret sonarqubeToken). The current version serves an MCP endpoint per installed instance, keeps its settings in the secrets sonarqubeAuth and sonarqubeAuthorizedAgents, and is configured through its configuration app.
The token is carried over automatically. Agents and capabilities are not: each workspace has one reconfiguration step to run and its agents to re-authorize. Follow this section for every workspace where the app is installed.
What changes, and when
New code takes effect as soon as the platform publishes the new app version: installed instances are not pinned to a version. Their configuration, however, is only migrated when the instance is reconfigured (step 3). In between:
Plan the migration so that steps 3 to 5 follow the upgrade closely: agents lose SonarQube between the upgrade and step 5.
Before you start
- Platform: 27.5.7 or later.
- Inventory, per workspace where SonarQube is installed: the instance name (slug), the agents that use the SonarQube capability, and who can generate a new SonarQube token if needed.
- Access: a workspace editor account on each of these workspaces, and an API access token for that account (step 3 is an API call).
- Decide the mode for each workspace: keep one shared token, or switch to personal tokens (see Authentication modes in the Workspace builder tab).
Step 1 — Deploy the new version
The SonarQube app is part of the workspaces delivered with the platform image (extended group). On startup, the platform imports the bundled workspaces and republishes the SonarQube app, which updates every installed instance.
- Check that the platform’s startup import includes the
extendedgroup (STARTUP_IMPORT_GROUPS). Otherwise, import thesonarqubeworkspace from thereleaserepository manually. - To confirm the new version is live: in any workspace, open the SonarQube instance configuration. The new version shows a single read-only Configuration app field; the old one showed SonarQube API Base URL, API Token, MCP Endpoint and MCP API Key.
Step 2 — Check that DSUL instructions still work (optional)
Run any automation that callsSonarQube.<instruction> in an affected workspace. It should behave as before: until step 3, the connector reads the old token / baseUrl instance settings.
Step 3 — Reconfigure each instance
The instance must receive a configuration change to run its installation routine again. That routine:- creates the secret
sonarqubeAuth, pre-filled with the old token and API base URL; - creates the secret
sonarqubeAuthorizedAgents, empty; - links both to the instance;
- fills in the Configuration app link.
configAppUrl is harmless: the routine fills it in again.
configAppUrl, and auth / authorizedAgents bindings. If configAppUrl is still empty, look in the workspace activity feed for an event whose type ends with sonarqube.onInstall.failed: the routine stops without writing anything when it cannot read the workspace secrets or configuration.
Alternative without the API: uninstall the instance and install it again under the same name. The routine then runs, but it cannot recover the old settings:
sonarqubeAuth is created with an empty token and the SonarQube Cloud URL. Enter both the token and your API base URL again in step 4. The old sonarqubeToken secret is left in place.Step 4 — Check authentication in the configuration app
Open the Configuration app link from step 3, Authentication tab:- Keeping a shared token: the token and API base URL are pre-filled. Click Test connection; it must report success.
- Switching to personal tokens: select Personal token per user, keep the API base URL, Save authentication. The shared token is removed from
sonarqubeAuth. Users connect on their first use (see the Agent builder tab).
Step 5 — Re-authorize agents
In the Agents tab:- Tick each agent from your inventory (or Allow all agents). The list is empty after migration, so every agent is refused until allowed.
- Click Install capability on each agent. It adds the new SonarQube MCP tool.
- Remove the old SonarQube capability from each agent: the MCP tool whose server URL ends with
/workspaces/slug:sonarqube/webhooks/mcp. Install capability only replaces a tool namedsonarqubeor pointing at the new endpoint, so an old capability under another name stays and keeps failing. - If an administrator had published SonarQube in the Capabilities catalog, publish it again with Add to catalog / Update catalog entry (or update the entry by hand, see Platform admin setup) so that it points at the new endpoint.
Step 6 — Rotate the shared SonarQube token
The previous version wrote the token in clear in the activity events of the centralsonarqube workspace each time an agent used it (runtime.automations.executed, accessToken argument). The current version masks it.
- After migration, generate a new SonarQube token for every workspace that kept a shared token, paste it in the configuration app, then revoke the old one in SonarQube.
- If you switched to personal tokens, revoke the old shared token in SonarQube.
- Treat the stored events of the
sonarqubeworkspace as containing credentials (retention, access rights, purge).
Step 7 — Clean up (optional)
These leftovers are no longer read and are harmless:Verification checklist
- Each instance configuration has a non-empty
configAppUrl. - Test connection succeeds (shared mode), or a user connects with Connect my token and Test connection succeeds (per-user mode).
- An allowed agent answers a SonarQube question; its tool call goes to
/webhooks/<instance>.mcp. - No agent still has the old capability (
/workspaces/slug:sonarqube/webhooks/mcp). - Old shared tokens are revoked in SonarQube.
Security
The answers that hold for every connector (agent access, shared knowledge bases, credentials, models, egress) are on Connector security. This section lists what is specific to SonarQube.
The connector exposes tools that generate and revoke user tokens, delete projects and branches, change project visibility and manage webhooks. A token with administrative permissions lets every allowed agent use them; with Browse only, SonarQube refuses them.
Error Handling
Common Issues
“SonarQube is not configured for this workspace”: Shared-token mode with no token. Open the configuration app (Authentication tab), paste a User token generated in SonarQube > My Account > Security > Generate Tokens, then save. “SonarQube is not connected for this user”: Per-user mode and the user has not connected a token yet, or it was removed after SonarQube rejected it. Click Connect on the SonarQube capability in Agent Creator (or Connect my token in the configuration app). “SonarQube rejected your personal token (revoked or expired), so it was removed”: The user’s token was revoked or has expired in SonarQube. Generate a new one and connect again. “SonarQube rejected the token” when connecting: The token is wrong, revoked, or belongs to another SonarQube instance. Check the API base URL configured by the administrator, and use a token of type User token. “SonarQube could not be reached or answered an error” when connecting: The platform cannot reach the API base URL (network, proxy, TLS) or SonarQube answered an error. The token was not stored. Check the URL (it must end with/api) and that the platform’s runtime can reach it.
“This agent is not authorized to use this connector”: Allow the agent in the configuration app (Agents tab), or use Install capability, which does it for you.
“This SonarQube capability was installed for a previous version of the connector”: The agent still uses the central endpoint of the previous version. See Migrating from the previous version, steps 3 to 5.
“organization parameter is missing”: On SonarCloud, most search and create operations require the organization key. Pass it explicitly in the tool arguments or as a default in your DSUL automation; call searchOrganizations to discover the keys your token can see.
searchProjects returns nothing on a public org: searchProjects is admin-scoped (it only lists projects in organizations you administer). To browse projects in any organization, including public ones you are not a member of, use searchPublicProjects.
Badge tools return non-SVG content: getProjectMeasureBadge and getProjectQualityGateBadge return raw SVG. The MCP transport currently surfaces them as JSON-encoded strings; consume them in App mode (DSUL) to write the SVG straight to a file or HTTP response.
External Resources
SonarQube Web API
Official SonarQube Web API reference
SonarCloud Web API
SonarCloud-flavored Web API reference
SonarSource Documentation
Product documentation, metrics catalog, rule descriptions
Tool Agents
Learn how Agent Creator agents consume MCP tools in Prisme.ai.