Connect SonarQube to Claude Code

Read code-quality issues, quality gates, measures and security hotspots from SonarQube Cloud or SonarQube Server, and triage them. Add Toolspoke to Claude Code once and it can use 16 SonarQube actions. Your SonarQube credential stays in Toolspoke, and you choose which actions Claude Code may call.

Set it up in Claude Code

Three steps, the first one once for every toolkit you will ever add.

  1. Add Toolspoke to Claude Code

    Run it in your project, then /mcp to sign in

    claude mcp add --transport http toolspoke https://toolspoke.com/mcp

    The sign-in opens in your browser, and Toolspoke asks you to approve it.

  2. Install SonarQube and connect it

    Add SonarQube to a project in your Toolspoke workspace.

    User token. You provide it once, when you install the connector. Toolspoke encrypts it at rest and decrypts it only for the length of a single call, and the gateway attaches it to the outbound request itself, so it is never part of the arguments an agent sends.

    User token
    SonarQube Cloud: avatar → My Account → Security → Generate Tokens. SonarQube Server: avatar → My Account → Security → Generate Tokens, type User Token. A project or global analysis token cannot read issues, so use a User token. It sees exactly what your account sees.
  3. Choose what Claude Code may do

    All 16 actions start on. Switch off any of the 4 actions that change something in SonarQube, and Claude Code gets a refusal if it tries.

What you can ask Claude Code for

A few of the SonarQube actions that only read, so they are safe to try first.

  • List the projects the token's user has marked as favourite
  • Search the projects this account can browse, by name or key
  • Read one project, directory or file by its component key, with its ancestors
  • List a project's past analyses with their dates, versions and events (quality gate changes, new versions)

What Claude Code can do in SonarQube

12 actions read and 4 write.

Reads

  • List favorites

    List the projects the token's user has marked as favourite. Takes no required arguments and works the same on SonarQube Cloud and Server, so it is what an install tests itself with, it fails for an invalid token and for an analysis token, which cannot read anything else here either.

  • Search projects

    Search the projects this account can browse, by name or key. This is where project keys come from, every other read takes one. On SonarQube Cloud the organization key is required.

  • Get component

    Read one project, directory or file by its component key, with its ancestors. Use it to resolve a key from an issue into a readable path and project.

  • Get quality gate status

    Read whether a project, branch or pull request passes its quality gate, with each condition, its threshold and the actual value. This is the answer to "is this mergeable".

  • Search issues

    Search issues across one or more projects, filtered by status, severity, software quality, tag, assignee or creation date. Returns each issue's key, rule, message, file and line, the issue key is what transition_issue, assign_issue and add_issue_comment take.

  • Get measures

    Read metric values for a project or file, coverage, bugs, vulnerabilities, code smells, duplicated lines, lines of code and so on. Name the metrics wanted; common keys are coverage, ncloc, bugs, vulnerabilities, code_smells, duplicated_lines_density, security_hotspots and sqale_index.

  • Search hotspots

    List a project's security hotspots, code that needs a human to decide whether it is a vulnerability, filtered by review status. Returns the hotspot keys get_hotspot and review_hotspot take.

  • Get hotspot

    Read one security hotspot with its rule, the risk it describes, its location, and the review comments people have left on it.

  • List analyses

    List a project's past analyses with their dates, versions and events (quality gate changes, new versions). Use it to find when a project's state changed.

  • List branches

    List a project's branches with each one's quality gate status and the date of its last analysis.

  • List pull requests

    List a project's analysed pull requests with each one's quality gate status.

  • Get rule

    Read one rule, what it checks, why it matters and how to fix it. The rule key comes from an issue or hotspot, e.g. typescript:S1854. On SonarQube Cloud the organization key is required.

Writes

  • Transition issue

    Change an issue's status: confirm, accept, falsepositive, resolve, reopen and so on. A write rather than destructive, because every transition can be reversed with reopen. Accepting or marking false positive does change whether a quality gate passes, so do it only when asked.

  • Assign issue

    Assign an issue to a user by login, or unassign it by leaving assignee out.

  • Add issue comment

    Add a comment to an issue. Visible to everyone who can browse the project.

  • Review hotspot

    Record a review of a security hotspot, mark it REVIEWED with a resolution (FIXED, SAFE or ACKNOWLEDGED), or put it back to TO_REVIEW. Reversible, so a write; it needs the Administer Security Hotspots permission on the project.

SonarQube in Claude Code: questions

Does Claude Code see my SonarQube credential?

No. The credential is stored encrypted in Toolspoke, and the gateway adds it to each call. Claude Code only ever talks to Toolspoke, and the dashboard shows the last four characters of the credential and nothing more.

Can I stop Claude Code from changing things in SonarQube?

Yes. Each of the 16 actions can be switched off for a project. Turn off the 4 that change something and Claude Code can only read.

Will 16 actions crowd Claude Code's context?

No. Toolspoke shows Claude Code five bridge tools, plus a guide where a toolkit has one, and Claude Code searches for the SonarQube action it needs when it needs it. Adding more toolkits does not add more tools to its list.

Can I add it once for every project?

Yes. Add --scope user to the command and Claude Code keeps Toolspoke in every project on this machine. Without it, the server is added to the project you ran the command in.

What does it cost?

Tool calls are free on every plan, and a SonarQube call does not run in a sandbox, so it bills nothing.

Try SonarQube in Claude Code

Free to start, and tool calls cost nothing on any plan.