home / mcp / sonarqube mcp server
A Model Context Protocol (MCP) server for interacting with SonarQube APIs, providing tools for authentication, project management, and metrics retrieval.
Configuration
View docs{
"mcpServers": {
"akashlomas-sonarqubemcp": {
"command": "npx",
"args": [
"-y",
"@lomas/[email protected]",
"sonarqubemcp"
],
"env": {
"SONARQUBE_URL": "<url>",
"SONARQUBE_TOKEN": "<token>"
}
}
}
}You run a SonarQube MCP Server to access SonarQube data through a standardized MCP interface. This lets you authenticate, list projects, view project details, and retrieve metrics from SonarQube in a consistent way for your tools and editors.
To use this MCP server, you start it in your development environment and connect with an MCP client. You will provide your SonarQube instance URL and a token for authentication, then you can list projects, view details, and fetch metrics through the MCP endpoints.
Prepare your environment and ensure your client can reach your SonarQube instance. Set the following environment variables before starting the MCP server to enable authentication and remote access: SONARQUBE_URL and SONARQUBE_TOKEN.
Prerequisites: Node.js >= v20.0.0 and a MCP-capable client.
Install the MCP server globally or run it directly with the package manager.
npm install -g @lomas/sonarqubemcp
# or
npx @lomas/sonarqubemcp@latestUse your MCP client to point at the local or remote MCP server. The following example shows configuring a client to execute the MCP with npx for local use and passing SonarQube credentials via environment variables.
{
"mcpServers": {
"SonarQube MCP": {
"command": "npx",
"args": [
"-y",
"@lomas/[email protected]",
"sonarqubemcp"
],
"env": {
"SONARQUBE_URL": "<url>",
"SONARQUBE_TOKEN": "<token>"
}
}
}
}In Cursor, you can add a global MCP server. Use the recommended configuration to run the MCP server via npx.
{
"mcpServers": {
"SonarQube MCP": {
"command": "npx",
"args": [
"-y",
"@lomas/[email protected]",
"sonarqubemcp"
],
"env": {
"SONARQUBE_URL": "<url>",
"SONARQUBE_TOKEN": "<token>"
}
}
}
}You can also configure Windsurf or VS Code to start the MCP server using the same npx command. Add the following config to your respective MCP configuration file.
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp"]
}
}
}Always protect your SonarQube token. Do not commit tokens to source control. Use environment variable management or secret stores to inject SONARQUBE_URL and SONARQUBE_TOKEN at runtime.
Error: Connection refused — Ensure the SonarQube server is running and the URL in SONARQUBE_URL is correct.
Error: Invalid token — Regenerate your SonarQube token and verify it has the required permissions.
Validate SonarQube token and establish authentication for subsequent MCP calls.
Retrieve a list of all SonarQube projects accessible with the provided token.
Fetch detailed information for a specific project by its key.
Obtain metrics for a given project and requested metrics set.