# Zed

[Zed](https://zed.dev/) is a next-generation code editor built for performance and collaboration. Use this MCP server setup when you want Sonar tools available within a Zed AI workflow.

The SonarQube MCP Server is available as a [Zed extension](https://zed.dev/extensions/mcp-server-sonarqube). If you need a custom configuration, a separate repository for Zed is available at <https://github.com/SonarSource/sonarqube-mcp-server-zed>.

If you prefer using a centrally managed MCP server, see [MCP server in SonarQube Cloud](#mcp-server-in-sonarqube-cloud).

## Use the configuration generator

Use the official [SonarQube MCP Server configuration generator](https://mcp.sonarqube.com/config-generator.html) to get a configuration code snippet for your setup:

1. Identify the target MCP Client.
2. Find your [#common-variables](/agent-centric-development-cycle/developer-tools/mcp-server/reference/environment-variables.md#common-variables).
3. Choose a [hosting method](/agent-centric-development-cycle/developer-tools/mcp-server/setup/environment-considerations.md#hosting-method).
4. Enter the information into the configuration generator.
5. Paste the generated configuration into your configuration file.

## Manual setup

### Environment variables

The following [common variables](/agent-centric-development-cycle/developer-tools/mcp-server/reference/environment-variables.md#common-variables) are required. Note that `SONARQUBE_TOKEN` applies to stdio transport only. For HTTP, HTTPS, or the embedded SonarQube Cloud MCP server, use the `Authorization: Bearer <YourSonarQubeUserToken>` header instead.

* `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.

> **Important:** Your SonarQube token is a sensitive credential. Use environment variables to pass tokens rather than hardcoding them in configuration files. Never commit tokens to version control.

### Transport options

The Zed extension for the SonarQube MCP Server uses [Stdio](/agent-centric-development-cycle/developer-tools/mcp-server/setup/self-hosted.md#local-server-stdio) transport. It's also the transport mode used in your [Agentic Analysis](/agent-centric-development-cycle/features/agentic-analysis.md) and [Context Augmentation](/agent-centric-development-cycle/features/context-augmentation.md) workflows.

> **Note:** The Zed extension supports Stdio transport only. For HTTPS or HTTP transport, use the [custom configuration repository](https://github.com/SonarSource/sonarqube-mcp-server-zed).

#### Stdio

Navigate to the **Extensions** view in Zed and search for `SonarQube MCP Server`. When installing the extension, you'll be prompted to enter the necessary environment variables:

> **Warning:** *User tokens* are required when setting up connected mode or an MCP Server between SonarQube Server and SonarQube for IDE. Note that binding won't function properly if *project tokens*, *global tokens*, or *scoped organization tokens* are used during the setup process.

**Zed with SonarQube Cloud**

```json
{
  "sonarqube_token": "<YourSonarQubeUserToken>",
  "sonarqube_org": "<YourOrganizationName>",
  //"sonarqube_url": "https://sonarqube.us",
  "docker_path": "<YourDockerPath>"
}
```

> **Note:** SONARQUBE\_URL should be defined as `https://sonarqube.us` each 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](/agent-centric-development-cycle/developer-tools/mcp-server/setup/environment-considerations.md#connecting-to-sonarqube-cloud-in-the-us-region) section for details.

**Zed with SonarQube Server**

```json
{
  "sonarqube_token": "<YourSonarQubeUserToken>",
  "sonarqube_url": "<YourSonarQubeServerURL>",
  "docker_path": "<YourDockerPath>"
}
```

The `docker_path` is the path to a container runtime executable. Examples:

* Linux/macOS: `/usr/bin/docker` or `/usr/local/bin/docker`
* Windows: `C:\Program Files\Docker\Docker\resources\bin\docker.exe`

## Agentic analysis and context augmentation

When using Agentic Analysis and Context Augmentation services, your `SONARQUBE_TOKEN` will allow your local MCP server configured for [Stdio](/agent-centric-development-cycle/developer-tools/mcp-server/setup/self-hosted.md#local-server-stdio) mode to authenticate to the SonarQube Cloud API. See [Agentic Analysis](/agent-centric-development-cycle/features/agentic-analysis.md) and [Context Augmentation](/agent-centric-development-cycle/features/context-augmentation.md) 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](https://docs.sonarsource.com/sonarqube-cloud/ai-capabilities/sonarqube-mcp-server#mcp-server-in-sonarqube-cloud) page.

***

## Use Sonar tools from Zed

Once connected, Zed can call SonarQube MCP tools on your behalf. See the [tools](/agent-centric-development-cycle/developer-tools/mcp-server/reference/tools.md) page for the full list of available tools.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sonarsource.com/agent-centric-development-cycle/developer-tools/mcp-server/setup/quickstart-guides/zed.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
