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

  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" } } } }

    Replace your-sourcegraph-instance.com with your Sourcegraph instance URL and YOUR_ACCESS_TOKEN with your access token.

  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

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)

  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" } } } }

    Replace your-sourcegraph-instance.com with your Sourcegraph instance URL and YOUR_ACCESS_TOKEN with your access token.

  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"

    Replace your-sourcegraph-instance.com with your Sourcegraph instance URL and YOUR_ACCESS_TOKEN with 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:

  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" } } } }

    Replace your-sourcegraph-instance.com with your Sourcegraph instance URL and YOUR_ACCESS_TOKEN with your access token.

  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\" }"
  1. 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" } } } }

    Replace your-sourcegraph-instance.com with your Sourcegraph instance URL and YOUR_ACCESS_TOKEN with your access token.

  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": [] }

    Replace your-sourcegraph-instance.com with your Sourcegraph instance URL and YOUR_ACCESS_TOKEN with your access token.

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" } } } }

    Replace your-sourcegraph-instance.com with your Sourcegraph instance URL and YOUR_ACCESS_TOKEN with your access token.

  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" }

    Replace your-sourcegraph-instance.com with your Sourcegraph instance URL and YOUR_ACCESS_TOKEN with your access token.

  3. Save the configuration file.

  4. Restart OpenCode to apply the changes.

Previous
MCP Server