MCP Server does not connect to SonarQube

I am trying to run a sonarQube MCP server locally (on windows) that should connect to our SonarQube server (version 2025.1.1.104738, I am not the admin, just a user).
Building works fine, but the authentication fails with:

Exception in thread "main" org.sonarsource.sonarqube.mcp.serverapi.exception.UnauthorizedException: SonarQube answered with Not authorized. Please check server credentials.
        at org.sonarsource.sonarqube.mcp.serverapi.ServerApiHelper.handleError(ServerApiHelper.java:99)
        at org.sonarsource.sonarqube.mcp.serverapi.ServerApiHelper.get(ServerApiHelper.java:51)
        at org.sonarsource.sonarqube.mcp.serverapi.plugins.PluginsApi.getInstalled(PluginsApi.java:36)
        at org.sonarsource.sonarqube.mcp.plugins.PluginsSynchronizer.synchronizeAnalyzers(PluginsSynchronizer.java:48)
        at org.sonarsource.sonarqube.mcp.SonarQubeMcpServer.start(SonarQubeMcpServer.java:120)
        at org.sonarsource.sonarqube.mcp.SonarQubeMcpServer.main(SonarQubeMcpServer.java:73)

I can access do successfully things like:
curl -u %SONARQUBE_TOKEN%: %SONARQUBE_ORG%/api/plugins/installed, so the token seems to be fine.
I tried it with a user token and a project analysis token.
Is there an error on my side?
What can I do to debug the problem?
Is there something the server administrator has to do to enable access for me or for the MCP server?
Thanks for your time!

Hey there.

Can you share how you’ve configured your MCP server?

Right now I have been starting the jar file directly with the environment variables STORAGE_PATH, SONARQUBE_TOKEN, SONARQUBE_URL set.
I also tried it from within visual studio code with this setup

 "mcp.servers": {
    "sonarqube": {
      "command": "java",
      "args": [
        "-jar",
        "f:/Projects/sonarqube-mcp-server/build/libs/sonarqube-mcp-server-0.0.2-SNAPSHOT.jar"
      ],
      "env": {
        "STORAGE_PATH": "F:\\Projects\\sonarqube-mcp-server\\storage",
        "SONARQUBE_TOKEN": "MY_TOKEN",
        "SONARQUBE_URL": "SONAR_URL"
      }
    }
  }

(I put in actual tokens, I just do not want to post them)
Anything else I need to do or check?

Hello @chr, can you please try using the latest version 0.0.3?

Also, the token has to be a USER token, this is important.

Is there something the server administrator has to do to enable access for me or for the MCP server?

There should be nothing to do on SonarQube Server side.

I have built the latest version from git and made sure that it is a user token. Same result as above.
One more thing: The server has about a dozen projects, my user token has only access rights to one project. Is that an issue? I did not see a project key parameter.

I’m surprised that this doesn’t work, especially if the curl command does.

One more thing: The server has about a dozen projects, my user token has only access rights to one project. Is that an issue? I did not see a project key parameter.

The synchronization on which the issue is happening does not require any project key, we are downloading plugins to run our analyzer and it’s global to your SonarQube Server instance.

I can access do successfully things like:
curl -u %SONARQUBE_TOKEN%: %SONARQUBE_ORG%/api/plugins/installed, so the token seems to be fine.

Just for confirmation, are you effectively querying your SonarQube Server and not SonarQube Cloud? I’m asking because you mentioned SONARQUBE_ORG.

Ideally, you could also try our Docker image and see if you reproduce the issue, this is usually the best way to use our MCP server.