# Client Integrations

<p className="subtitle">
	Set up the Sourcegraph MCP server with your preferred AI coding tool or IDE.
</p>

<TierCallout>
	Supported on [Enterprise](/pricing/plans/enterprise) plans.
</TierCallout>

## Supported Clients

- [Claude Code](#claude-code)
- [Codex](#codex)
- [Cursor](#cursor)
- [GitHub Copilot](#github-copilot)
- [OpenCode](#opencode)
- [Amp](#amp)
- [Google Antigravity](#google-antigravity)
- [Google Gemini Code Assist](#google-gemini-code-assist)
- [Devin Desktop](#devin-desktop)

In all examples, replace `sourcegraph.example.com` with your Sourcegraph instance URL. For Claude Code, Cursor, GitHub Copilot, OpenCode, and Amp access-token authentication, set `SOURCEGRAPH_ACCESS_TOKEN` in the client's environment. In other access-token examples, replace `YOUR_ACCESS_TOKEN` with a [Sourcegraph access token](/cli/how-tos/creating-an-access-token).

### Claude Code

The [Sourcegraph plugin](https://claude.com/plugins/sourcegraph) in Anthropic's official marketplace adds the Sourcegraph MCP server and a `searching-sourcegraph` skill with search and code navigation workflows to Claude Code. It connects to the `/.api/mcp/all` endpoint with a Sourcegraph access token. Set these in your environment:

```bash
export SOURCEGRAPH_ENDPOINT="https://sourcegraph.example.com"
export SOURCEGRAPH_ACCESS_TOKEN="YOUR_ACCESS_TOKEN"
```

Then install the plugin and restart Claude Code:

```bash
claude plugin install sourcegraph@claude-plugins-official
```

To sign in with OAuth instead of an access token, or to add only the MCP server, add the Sourcegraph MCP server to [Claude Code](https://code.claude.com/docs/en/mcp) for all your projects:

```bash
claude mcp add --transport http --scope user sourcegraph https://sourcegraph.example.com/.api/mcp
```

Then run `claude mcp login sourcegraph`, or run `/mcp` in Claude Code, and follow the browser authentication flow. Without `--scope user`, Claude Code adds the server only for the current project.

To share an access-token configuration with a project, set `SOURCEGRAPH_ACCESS_TOKEN` in your environment and add the following to `.mcp.json` in the project root:

```json
{
	"mcpServers": {
		"sourcegraph": {
			"type": "http",
			"url": "https://sourcegraph.example.com/.api/mcp",
			"headers": {
				"Authorization": "token ${SOURCEGRAPH_ACCESS_TOKEN}"
			}
		}
	}
}
```

You can also add an access-token configuration for the current project with the CLI:

```bash
claude mcp add --transport http sourcegraph https://sourcegraph.example.com/.api/mcp \
  --header "Authorization: token $SOURCEGRAPH_ACCESS_TOKEN"
```

Locally scoped servers take precedence over project-scoped servers with the same name.

### Codex

Add the Sourcegraph MCP server to [Codex](https://learn.chatgpt.com/docs/extend/mcp) by adding the following to `~/.codex/config.toml`, or to `.codex/config.toml` for a trusted project. The Codex CLI, IDE extension, and ChatGPT desktop app share this configuration.

```toml
[mcp_servers.sourcegraph]
url = "https://sourcegraph.example.com/.api/mcp"
scopes = ["mcp"]
```

Then authenticate with `codex mcp login sourcegraph`.

<Callout type="note">
	`scopes = ["mcp"]` is required. Without it, Codex's OAuth login fails with
	an `invalid_scope` error because Sourcegraph's MCP endpoints require the
	`mcp` scope. See [Troubleshooting: `invalid_scope` error during
	OAuth](/api/mcp#invalid_scope-error-during-oauth) for details.
</Callout>

### Cursor

The [Sourcegraph plugin](https://cursor.com/marketplace/sourcegraph) in the Cursor Marketplace adds the Sourcegraph MCP server, a `searching-sourcegraph` skill, and search commands to Cursor. After you install it from the marketplace or Cursor's **Customize** page, select **Configure** on the plugin and set `SOURCEGRAPH_ENDPOINT` to your instance URL, such as `https://sourcegraph.example.com`, without a trailing slash. The variable defaults to Sourcegraph's demo instance. Then follow the OAuth prompt.

To add only the MCP server, add the following to `~/.cursor/mcp.json`, or to `.cursor/mcp.json` for a project:

```json
{
	"mcpServers": {
		"sourcegraph": {
			"url": "https://sourcegraph.example.com/.api/mcp"
		}
	}
}
```

Enable the server from Cursor's **Customize** page and follow the OAuth prompt. See [Cursor's MCP documentation](https://cursor.com/docs/mcp) for more information.

To authenticate with a Sourcegraph access token instead, set `SOURCEGRAPH_ACCESS_TOKEN` in Cursor's environment and add an authorization header:

```json
{
	"mcpServers": {
		"sourcegraph": {
			"url": "https://sourcegraph.example.com/.api/mcp",
			"headers": {
				"Authorization": "token ${env:SOURCEGRAPH_ACCESS_TOKEN}"
			}
		}
	}
}
```

<span id="copilot"> </span>

<span id="vs-code"> </span>

### GitHub Copilot

[GitHub Copilot CLI](https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/add-mcp-servers) and Copilot in VS Code read the same MCP configuration file, `~/.copilot/mcp-config.json`. Add the Sourcegraph MCP server with the Copilot CLI:

```bash
copilot mcp add --transport http sourcegraph https://sourcegraph.example.com/.api/mcp
```

Or add the following to `~/.copilot/mcp-config.json`:

```json
{
	"mcpServers": {
		"sourcegraph": {
			"type": "http",
			"url": "https://sourcegraph.example.com/.api/mcp",
			"tools": ["*"]
		}
	}
}
```

To authenticate, run `/mcp auth sourcegraph` in Copilot CLI, or select **Authenticate** on the server in VS Code. In VS Code, you can also run **MCP: Add Server** and choose **Copilot Global** to write the same file. See [VS Code's MCP documentation](https://code.visualstudio.com/docs/agent-customization/mcp-servers) for more information.

To authenticate with a Sourcegraph access token instead, set `SOURCEGRAPH_ACCESS_TOKEN` in Copilot's environment and add an authorization header:

```json
{
	"mcpServers": {
		"sourcegraph": {
			"type": "http",
			"url": "https://sourcegraph.example.com/.api/mcp",
			"tools": ["*"],
			"headers": {
				"Authorization": "token ${SOURCEGRAPH_ACCESS_TOKEN}"
			}
		}
	}
}
```

### OpenCode

Add the Sourcegraph MCP server to [OpenCode](https://opencode.ai/docs/mcp-servers/) for all your projects:

```bash
opencode mcp add sourcegraph --global --url https://sourcegraph.example.com/.api/mcp
```

Without `--global`, OpenCode adds the server to the current project's configuration. You can also add the following to `~/.config/opencode/opencode.json`, or to `opencode.json` in a project root:

```json
{
	"$schema": "https://opencode.ai/config.json",
	"mcp": {
		"servers": {
			"sourcegraph": {
				"type": "remote",
				"url": "https://sourcegraph.example.com/.api/mcp"
			}
		}
	}
}
```

Then authenticate with `opencode mcp auth sourcegraph`, or run `/mcps` in OpenCode and select the server.

To authenticate with a Sourcegraph access token instead, disable OAuth and add an authorization header:

```json
{
	"$schema": "https://opencode.ai/config.json",
	"mcp": {
		"servers": {
			"sourcegraph": {
				"type": "remote",
				"url": "https://sourcegraph.example.com/.api/mcp",
				"oauth": false,
				"headers": {
					"Authorization": "token {env:SOURCEGRAPH_ACCESS_TOKEN}"
				}
			}
		}
	}
}
```

### Amp

Add the Sourcegraph MCP server to [Amp](https://ampcode.com/docs/customize/mcp):

```bash
amp mcp add sourcegraph https://sourcegraph.example.com/.api/mcp
```

Amp starts the OAuth flow in your browser when it connects to the server.

To authenticate with a Sourcegraph access token instead, add an authorization header:

```bash
amp mcp add sourcegraph --header "Authorization=token $SOURCEGRAPH_ACCESS_TOKEN" https://sourcegraph.example.com/.api/mcp
```

You can also configure the access-token connection in Amp's settings file, `~/.config/amp/settings.json`:

```json
{
	"amp.mcpServers": {
		"sourcegraph": {
			"url": "https://sourcegraph.example.com/.api/mcp",
			"headers": {
				"Authorization": "token ${SOURCEGRAPH_ACCESS_TOKEN}"
			}
		}
	}
}
```

These commands and settings configure Amp on your computer. Amp threads that run in orbs don't read them. To use Sourcegraph in orbs, add the server in your Amp [MCP server settings](https://ampcode.com/settings/mcp-servers), or with `amp mcp remote --personal add sourcegraph https://sourcegraph.example.com/.api/mcp`. Amp then connects from its own servers, so your Sourcegraph instance must be reachable from Amp's server IP addresses.

<span id="antigravity"> </span>

### Google Antigravity

The [Antigravity](https://antigravity.google/docs/mcp) app, IDE, and CLI read MCP servers from an `mcp_config.json` file. Antigravity CLI uses `~/.gemini/config/mcp_config.json` for all projects and `.agents/mcp_config.json` for a workspace. In the Antigravity app, click **Copy Config File Path** in the MCP servers section to find its file. Add the following:

```json
{
	"mcpServers": {
		"sourcegraph": {
			"serverUrl": "https://sourcegraph.example.com/.api/mcp"
		}
	}
}
```

Then click **Authenticate** next to the server in **Customizations** and complete the browser authentication flow.

To authenticate with a Sourcegraph access token instead, add an authorization header:

```json
{
	"mcpServers": {
		"sourcegraph": {
			"serverUrl": "https://sourcegraph.example.com/.api/mcp",
			"headers": {
				"Authorization": "token YOUR_ACCESS_TOKEN"
			}
		}
	}
}
```

### Google Gemini Code Assist

You can add the Sourcegraph MCP server to Google Gemini Code Assist by configuring the `.gemini/settings.json` file:

1. Open or create the configuration file at `~/.gemini/settings.json` (or the equivalent path on your system).
2. Add the following configuration:

    ```json
    {
    	"mcpServers": {
    		"sourcegraph": {
    			"httpUrl": "https://sourcegraph.example.com/.api/mcp",
    			"headers": {
    				"Authorization": "token YOUR_ACCESS_TOKEN"
    			}
    		}
    	}
    }
    ```

    <Callout type="info">
    	Replace `sourcegraph.example.com` with your Sourcegraph instance URL and
    	`YOUR_ACCESS_TOKEN` with your access token.
    </Callout>

3. Save the configuration file.
4. Restart Gemini Code Assist to apply the new configuration.

<span id="windsurf"> </span>

### Devin Desktop

Devin Desktop, formerly Windsurf, shares its MCP configuration with the [Devin CLI](https://docs.devin.ai/cli/extensibility/mcp/configuration). Add the Sourcegraph MCP server for all your projects:

```bash
devin mcp add -s user sourcegraph https://sourcegraph.example.com/.api/mcp
```

Or add the following to `~/.config/devin/mcp_config.json` (`%APPDATA%\devin\mcp_config.json` on Windows):

```json
{
	"mcpServers": {
		"sourcegraph": {
			"url": "https://sourcegraph.example.com/.api/mcp"
		}
	}
}
```

Then run `devin mcp login sourcegraph`, or click **Authenticate** on the server in Devin Desktop.

To authenticate with a Sourcegraph access token instead, add an authorization header:

```json
{
	"mcpServers": {
		"sourcegraph": {
			"url": "https://sourcegraph.example.com/.api/mcp",
			"headers": {
				"Authorization": "token YOUR_ACCESS_TOKEN"
			}
		}
	}
}
```
