GitHub Copilot cloud agent
Set up the SonarQube MCP Server with the GitHub Copilot cloud agent and start using Sonar tools in your CI/CD environment.
The GitHub Copilot cloud agent is an autonomous AI agent that operates inside your GitHub repository and CI/CD environment. Use this MCP server setup when you want Sonar tools available to the cloud agent during pull request workflows and automated tasks.
If you prefer using a centrally managed MCP server, see MCP server in SonarQube Cloud.
Use the configuration generator
Use the official SonarQube MCP Server configuration generator to get a configuration code snippet for your setup:
Identify the target MCP Client.
Find your #common-variables.
Choose a hosting method.
Enter the information into the configuration generator.
Paste the generated configuration into your configuration file.
Manual setup
Environment variables
The cloud agent uses GitHub repository secrets to supply environment variables to the MCP server. Only secrets with names prefixed with COPILOT_MCP_ are available to your MCP configuration. To add secrets to your Copilot environment, follow the GitHub documentation on Setting up a Copilot environment for Copilot cloud agent.
The following common variables are required, stored as COPILOT_MCP_-prefixed secrets:
SONARQUBE_TOKEN: Your SonarQube user token (stdio transport).SONARQUBE_ORG: Your SonarQube Cloud organization key. Required for SonarQube Cloud only.SONARQUBE_URL: Your SonarQube Server or Community Build URL. Also required for SonarQube Cloud in the US region (https://sonarqube.us). Not needed for SonarQube Cloud in the EU region.
Transport options
The SonarQube MCP Server supports three transport modes. Use Stdio for local development and most use cases, HTTPS for production and team deployments, and HTTP only on trusted internal networks.
Stdio (recommended)
Use Stdio when the cloud agent needs to spin up its own MCP server process within the CI/CD environment. It's also the transport mode used in your Agentic Analysis and Context Augmentation workflows.
In your GitHub repository, navigate to Settings > Code, planning, and automation > Copilot > Cloud agent and add the following configuration in the MCP configuration section:
Warning: User tokens are required when setting up connected mode or an MCP Server between SonarQube Server and SonarQube for IDE. Binding won't function properly if project tokens, global tokens, or scoped organization tokens are used during the setup process.
Note: This code sample configures the MCP server using Stdio transport, where
SONARQUBE_TOKENis passed as an environment variable.For HTTPS, HTTP, or the MCP server in SonarQube Cloud, the
SONARQUBE_TOKENheader is deprecated. Pass the token using the"Authorization": "Bearer <YourSonarQubeUserToken>"header instead.
GitHub Copilot cloud agent with SonarQube Cloud
Note: SONARQUBE_URL should be defined as
https://sonarqube.useach time you use a SonarQube Cloud configuration (SONARQUBE_TOKEN+SONARQUBE_ORG) and want to connect to a US-region instance. See the Connecting to SonarQube Cloud in the US region section for details.
GitHub Copilot cloud agent with SonarQube Server
HTTPS
Use HTTPS when connecting the cloud agent to a shared MCP server deployed for a team. This requires an HTTPS transport server to be running and accessible.
In your GitHub repository, navigate to Settings > Code, planning, and automation > Copilot > Cloud agent and add the following configuration in the MCP configuration section:
HTTP
Important: The HTTP transport mode is not recommended. Use Stdio for local development or HTTPS for multi-user production deployments.
Use HTTP only on a trusted internal network or for local testing. This requires an HTTP transport server to be running.
In your GitHub repository, navigate to Settings > Code, planning, and automation > Copilot > Cloud agent and add the following configuration in the MCP configuration section:
Agentic analysis and context augmentation
When using Agentic Analysis and Context Augmentation services, your SONARQUBE_TOKEN lets your local MCP server configured for Stdio mode authenticate to the SonarQube Cloud API. See Agentic Analysis and Context Augmentation for more information.
MCP Server in SonarQube Cloud
Use the SonarQube Cloud-hosted MCP server to avoid running and maintaining your own MCP infrastructure while always using the current server version. The embedded server exposes a smaller, fixed subset of tools; for the available toolsets and configuration details, check SonarQube Cloud's MCP Server in SonarQube Cloud page.
Use Sonar tools from the cloud agent
Once connected, the GitHub Copilot cloud agent can call SonarQube MCP tools during its automated workflows. See the tools page for the full list of available tools.
Last updated
Was this helpful?

