# 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

- [Amp](#amp)
- [Claude Code](#claude-code)
- [Google Gemini Code Assist](#google-gemini-code-assist)
- [VS Code](#vs-code)
    - [Cursor](#cursor)
    - [Antigravity](#antigravity)
    - [Windsurf](#windsurf)
- [OpenCode](#opencode)

### Amp

You can add the Sourcegraph MCP server to [Amp](https://ampcode.com) in two ways:

#### Option 1: VSCode settings.json

1. Open VSCode's `settings.json` file.
2. Add the following configuration:

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

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

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

#### Option 2: Amp CLI

Run the following command in your terminal:

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

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

### Claude Code

You can add the Sourcegraph MCP server to [Claude Code](https://claude.ai/code) in two ways:

#### Option 1: Project-scoped server (via .mcp.json file)

1. Create a `.mcp.json` file in your project root if it doesn't exist.
2. Add the following configuration:

    ```json
    {
    	"mcpServers": {
    		"sourcegraph": {
    			"type": "http",
    			"url": "https://your-sourcegraph-instance.com/.api/mcp",
    			"headers": {
    				"Authorization": "token YOUR_ACCESS_TOKEN"
    			}
    		}
    	}
    }
    ```

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

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

#### Option 2: Locally-scoped server (via CLI command)

You can also add the Sourcegraph MCP server as a locally-scoped server, which is only available to you in the current project:

1. Run the following command in your terminal:

    ```bash
    claude mcp add --transport http sourcegraph https://your-sourcegraph-instance.com/.api/mcp \
      --header "Authorization: token YOUR_ACCESS_TOKEN"
    ```

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

Locally-scoped servers take precedence over project-scoped servers with the same name and are stored in your project-specific user settings.

### 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://your-sourcegraph-instance.com/.api/mcp",
    			"headers": {
    				"Authorization": "token YOUR_ACCESS_TOKEN"
    			}
    		}
    	}
    }
    ```

    <Callout type="info">
    	Replace `your-sourcegraph-instance.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.

### VS Code

You can add the Sourcegraph MCP server to VS Code in one of two ways:

#### Option 1: `code` CLI

1. Run the following command to add the MCP server to the global configuration

```bash
code --add-mcp "{ \"name\": \"sourcegraph\", \"type\": \"remote\", \"url\": \"https://your-sourcegraph-instance.com/.api/mcp\" }"
```

2. Launch or restart VS Code to apply the new configuration.

#### Option 2: VSCode `mcp.json`

1. Create `.vscode/mcp.json` in your project.
2. Add the following configuration:

    ```json
    {
    	"servers": {
    		"sourcegraph": {
    			"type": "http",
    			"url": "https://your-sourcegraph-instance.com/.api/mcp"
    		}
    	},
    	"inputs": []
    }
    ```

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

#### Cursor

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

    ```json
    {
    	"mcpServers": {
    		"sourcegraph": {
    			"url": "https://your-sourcegraph-instance.com/.api/mcp",
    			"type": "http",
    			"headers": {
    				"Authorization": "token YOUR_ACCESS_TOKEN"
    			}
    		}
    	}
    }
    ```

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

3. Save the configuration file.
4. Restart Cursor to apply the new configuration.

#### Antigravity

1. Create ⁠`.vscode/mcp.json` (Antigravity uses `.vscode` for configs) in your project.
2. Add the following:

    ```json
    {
    	"servers": {
    		"sourcegraph": {
    			"url": "https://your-sourcegraph-instance.com/.api/mcp",
    			"type": "http",
    			"headers": {
    				"Authorization": "token YOUR_ACCESS_TOKEN"
    			}
    		}
    	},
    	"inputs": []
    }
    ```

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

#### Windsurf

1. Create ⁠`~/.codeium/windsurf/mcp_config.json`.
2. Add the following:

    ```json
    {
    	"mcpServers": {
    		"sourcegraph": {
    			"serverUrl": "https://your-sourcegraph-instance.com/.api/mcp",
    			"headers": {
    				"Authorization": "token YOUR_ACCESS_TOKEN",
    				"Content-Type": "application/json"
    			}
    		}
    	}
    }
    ```

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

3. Save the configuration file.

### OpenCode

You can add the Sourcegraph MCP server to OpenCode by configuring it in your MCP settings file:

1. Open or create the MCP configuration file at `~/.config/opencode/opencode.jsonc` (or the equivalent path on your system).
2. Add the following configuration:

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

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

3. Save the configuration file.
4. Restart OpenCode to apply the changes.
