Sourcegraph MCP Server — Claude Code MCP server
Connects an agent to Sourcegraph code search and navigation. Use it when an MCP client needs repository discovery, symbol lookup, or change inspection.
Open on GitHubWhat Sourcegraph MCP Server does
Sourcegraph MCP Server exposes Sourcegraph code intelligence through MCP. An agent can discover repositories, read files, run keyword or semantic searches, jump to symbol definitions, find references, and inspect code changes.
The server connects to Sourcegraph Cloud or a private deployment through https://{sourcegraph_hostname}/.api/mcp. Sourcegraph handles authentication with browser OAuth or an access token, while the supplied configuration defaults to OAuth. A private deployment requires its own hostname, so the endpoint must be changed before the connection can work.
The registry lists Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, and Gemini CLI as supported clients. Setup is client-specific; the Claude Code commands register HTTP endpoints named mcp and sourcegraph-mcp-server.
What it helps with
- discover a repository by topic or keyword
- search for symbols and their references
- read selected files through an agent
- trace a call to its definition
- inspect code changes across a repository
Example prompts for the agent
- Find repositories that implement OAuth authentication.
- Show the definition of
getUserand every place that calls it. - Review the changes in this repository and identify the affected files.
How to install Sourcegraph MCP Server
1Template address
The server address is a template: replace {…} or […] with your own values
2Platform CLI: remote server
claude mcp add --transport http mcp https://{sourcegraph_hostname}/.api/mcp1Template address
The server address is a template: replace {…} or […] with your own values
2Platform CLI: remote server
codex mcp add sourcegraph-mcp-server --url https://{sourcegraph_hostname}/.api/mcp1Template address
The server address is a template: replace {…} or […] with your own values
2Config file
{
"mcpServers": {
"sourcegraph-mcp-server": {
"url": "https://{sourcegraph_hostname}/.api/mcp"
}
}
}1Template address
The server address is a template: replace {…} or […] with your own values
2Config file
{
"servers": {
"sourcegraph-mcp-server": {
"type": "http",
"url": "https://{sourcegraph_hostname}/.api/mcp"
}
}
}1Template address
The server address is a template: replace {…} or […] with your own values
2Platform CLI: remote server
gemini mcp add -t http sourcegraph-mcp-server https://{sourcegraph_hostname}/.api/mcpStep by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about Sourcegraph MCP Server
How do I install Sourcegraph MCP Server in Claude Code?
Run these commands in order: claude mcp add --transport http mcp https://{sourcegraph_hostname}/.api/mcp, then claude mcp add --transport http sourcegraph-mcp-server https://{sourcegraph_hostname}/.api/mcp.
What does Sourcegraph MCP Server do?
It gives an MCP-compatible agent access to Sourcegraph search and code navigation, including repository discovery, file reads, symbol definitions, references, and change inspection.
What is required to use Sourcegraph MCP Server?
Provide a Sourcegraph Cloud or private-instance hostname. Authentication uses browser OAuth or a Sourcegraph access token, with OAuth as the default configuration.