# 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 the [#mcp-server-in-sonarqube-cloud](#mcp-server-in-sonarqube-cloud "mention") article below.

## Set up MCP for Zed

### Environment variables

The following [#common-variables](https://docs.sonarsource.com/sonarqube-mcp-server/build-and-configure/environment-variables#common-variables "mention") 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.

{% hint style="danger" %}
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.
{% endhint %}

### Transport options

The Zed extension for the SonarQube MCP Server uses [#stdio](https://docs.sonarsource.com/sonarqube-mcp-server/build-and-configure/configure#stdio "mention") transport. It is also the transport used by [Agentic Analysis and Context Augmentation](#agentic-analysis-and-context-augmentation).

#### Stdio

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

{% hint style="warning" %}
*User tokens* are required when setting up connected mode or an MCP Server between SonarQube (Server, Cloud) and SonarQube for IDE. Note that the binding will not function properly if *project tokens*, *global tokens*, or *scoped organization tokens* are used during the setup process.
{% endhint %}

**Zed with SonarQube Cloud**

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

{% hint style="success" %}
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 US instance. See the [#common-variables](https://docs.sonarsource.com/sonarqube-mcp-server/build-and-configure/environment-variables#common-variables "mention") article which explains when to use these variables.
{% endhint %}

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

To build the extension, run `cargo build`.

## Agentic Analysis and Context Augmentation

When using SonarQube Cloud's Agentic Analysis and Context Augmentation services, your `SONARQUBE_TOKEN` will allow your local MCP server configured for [#stdio](https://docs.sonarsource.com/sonarqube-mcp-server/build-and-configure/configure#stdio "mention") mode to authenticate to the SonarQube Cloud API. See the SonarQube Cloud pages [Agentic Analysis](https://app.gitbook.com/s/B4UT2GNiZKjtxFtcFAL7/analyzing-source-code/agentic-analysis "mention") and [Context Augmentation](https://app.gitbook.com/s/B4UT2GNiZKjtxFtcFAL7/analyzing-source-code/context-augmentation "mention") to get the correct configuration details.

## MCP Server in SonarQube Cloud

Use the embedded SonarQube Cloud 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 #MCP Server in SonarQube Cloud](https://app.gitbook.com/s/B4UT2GNiZKjtxFtcFAL7/ai-capabilities/sonarqube-mcp-server#mcp-server-in-sonarqube-cloud "mention") page.

## Use Sonar tools from Zed

Once connected, Zed can call SonarQube MCP tools on your behalf. See the [tools](https://docs.sonarsource.com/sonarqube-mcp-server/using/tools "mention") page for the full list of available tools.

{% hint style="info" %}
Concrete workflow examples for this IDE will be added after engineering review.
{% endhint %}
