Client Integrations
Set up the Sourcegraph MCP server with your preferred AI coding tool or IDE.
Supported on Enterprise plans.
Supported Clients
Amp
You can add the Sourcegraph MCP server to Amp in two ways:
Option 1: VSCode settings.json
-
Open VSCode's
settings.jsonfile. -
Add the following configuration:
JSON{ "amp.mcpServers": { "sourcegraph": { "url": "https://your-sourcegraph-instance.com/.api/mcp", "headers": { "Authorization": "token YOUR_ACCESS_TOKEN" } } } }Replace
your-sourcegraph-instance.comwith your Sourcegraph instance URL andYOUR_ACCESS_TOKENwith your access token. -
Save the configuration file.
-
Restart VS Code to apply the new configuration.
Option 2: Amp CLI
Run the following command in your terminal:
BASHamp mcp add sourcegraph --header "Authorization=token YOUR_ACCESS_TOKEN" https://sourcegraph.sourcegraph.com/.api/mcp
Replace sourcegraph.sourcegraph.com with your Sourcegraph instance URL and
set YOUR_ACCESS_TOKEN environment variable to your access token.
Claude Code
You can add the Sourcegraph MCP server to Claude Code in two ways:
Option 1: Project-scoped server (via .mcp.json file)
-
Create a
.mcp.jsonfile in your project root if it doesn't exist. -
Add the following configuration:
JSON{ "mcpServers": { "sourcegraph": { "type": "http", "url": "https://your-sourcegraph-instance.com/.api/mcp", "headers": { "Authorization": "token YOUR_ACCESS_TOKEN" } } } }Replace
your-sourcegraph-instance.comwith your Sourcegraph instance URL andYOUR_ACCESS_TOKENwith your access token. -
Save the configuration file.
-
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:
-
Run the following command in your terminal:
BASHclaude mcp add --transport http sourcegraph https://your-sourcegraph-instance.com/.api/mcp \ --header "Authorization: token YOUR_ACCESS_TOKEN"Replace
your-sourcegraph-instance.comwith your Sourcegraph instance URL andYOUR_ACCESS_TOKENwith your access token.
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:
-
Open or create the configuration file at
~/.gemini/settings.json(or the equivalent path on your system). -
Add the following configuration:
JSON{ "mcpServers": { "sourcegraph": { "httpUrl": "https://your-sourcegraph-instance.com/.api/mcp", "headers": { "Authorization": "token YOUR_ACCESS_TOKEN" } } } }Replace
your-sourcegraph-instance.comwith your Sourcegraph instance URL andYOUR_ACCESS_TOKENwith your access token. -
Save the configuration file.
-
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
- Run the following command to add the MCP server to the global configuration
BASHcode --add-mcp "{ \"name\": \"sourcegraph\", \"type\": \"remote\", \"url\": \"https://your-sourcegraph-instance.com/.api/mcp\" }"
- Launch or restart VS Code to apply the new configuration.
Option 2: VSCode mcp.json
-
Create
.vscode/mcp.jsonin your project. -
Add the following configuration:
JSON{ "servers": { "sourcegraph": { "type": "http", "url": "https://your-sourcegraph-instance.com/.api/mcp" } }, "inputs": [] } -
Save the configuration file.
-
Restart VS Code to apply the new configuration.
Cursor
-
Open or create the MCP configuration file at
~/.cursor/mcp.json(or the equivalent path on your system). -
Add the following:
JSON{ "mcpServers": { "sourcegraph": { "url": "https://your-sourcegraph-instance.com/.api/mcp", "type": "http", "headers": { "Authorization": "token YOUR_ACCESS_TOKEN" } } } }Replace
your-sourcegraph-instance.comwith your Sourcegraph instance URL andYOUR_ACCESS_TOKENwith your access token. -
Save the configuration file.
-
Restart Cursor to apply the new configuration.
Antigravity
-
Create
.vscode/mcp.json(Antigravity uses.vscodefor configs) in your project. -
Add the following:
JSON{ "servers": { "sourcegraph": { "url": "https://your-sourcegraph-instance.com/.api/mcp", "type": "http", "headers": { "Authorization": "token YOUR_ACCESS_TOKEN" } } }, "inputs": [] }Replace
your-sourcegraph-instance.comwith your Sourcegraph instance URL andYOUR_ACCESS_TOKENwith your access token.
Windsurf
-
Create
~/.codeium/windsurf/mcp_config.json. -
Add the following:
JSON{ "mcpServers": { "sourcegraph": { "serverUrl": "https://your-sourcegraph-instance.com/.api/mcp", "headers": { "Authorization": "token YOUR_ACCESS_TOKEN", "Content-Type": "application/json" } } } }Replace
your-sourcegraph-instance.comwith your Sourcegraph instance URL andYOUR_ACCESS_TOKENwith your access token. -
Save the configuration file.
OpenCode
You can add the Sourcegraph MCP server to OpenCode by configuring it in your MCP settings file:
-
Open or create the MCP configuration file at
~/.config/opencode/opencode.jsonc(or the equivalent path on your system). -
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" }Replace
your-sourcegraph-instance.comwith your Sourcegraph instance URL andYOUR_ACCESS_TOKENwith your access token. -
Save the configuration file.
-
Restart OpenCode to apply the changes.