Sourcegraph MCP Server

Official MCP endpoint of your Sourcegraph instance: code search, navigation and Deep Search across all repositories for AI assistants.

Description

The Sourcegraph MCP Server makes the code search of your Sourcegraph instance usable for AI assistants. Sourcegraph is a platform that teams use to search and understand large codebases across many repositories. MCP, the Model Context Protocol, is an open standard through which an assistant such as Claude Code or Cursor calls external tools. The server is not a separate program to install: according to the documentation, the instance itself provides an MCP endpoint under the path /.api/mcp, for example at https://sourcegraph.example.com/.api/mcp. Instead of pasting individual files into the chat, the assistant runs the search across all connected repositories and reads only what it needs.

What can the Sourcegraph MCP Server do?

The documentation describes several groups of tools. For files and repositories there are read_file, list_files, list_repos and list_refs. For searching, keyword_search, nls_search for questions in natural language, and a tool called evaluator are available. Code navigation includes go_to_definition and find_references, that is, jumping to the definition of a symbol and listing where it is used. For version history there are commit_search, diff_search, compare_revisions and get_contributor_repos. In addition there are code_finder and the Deep Search tools deepsearch and deepsearch_read. Which of them are available depends on the endpoint you choose.

Three endpoints for different purposes

The endpoint /.api/mcp provides the core tools for search, repositories and history and can read existing Deep Search conversations, but cannot start new ones. /.api/mcp/all contains the full tool set. /.api/mcp/deepsearch is limited to the Deep Search tools. If you only want to give an assistant the research part, you can register the narrowest endpoint on purpose.

Sign-in and permissions

According to the documentation, sign-in works through OAuth 2.0 with dynamic client registration or with pre-registered clients; alternatively you can use Sourcegraph access tokens. Users need the MCP#ACCESS permission, which the built-in User role grants by default. MCP access does not override repository permissions: through the assistant, each person sees only the repositories they may also see in Sourcegraph. Administrators can switch off individual tools with the setting mcp.tools.disabled, and mcp.enabled controls the endpoint as a whole; when it is off, /.api/mcp answers with 404.

Setup in Claude Code and other clients

According to the documentation, Claude Code and the Amp CLI use dynamic registration and are registered automatically with the scope mcp; for Claude Code you choose the HTTP transport. With OpenAI Codex an invalid_scope error can occur, in which case the entry scopes = ["mcp"] in the config.toml file helps. For Cursor, VS Code and other clients the page points to a separate page on client integrations.

Limits in everyday use

Files larger than 128 KB return only the first 200 lines, and list_files returns at most 1000 entries. The code_finder tool is counted against the quota of your contract and returns an error once it is used up; on /.api/mcp, nls_search then serves as a fallback.

Costs

According to the documentation and the pricing page, the server is supported on the Enterprise plan. The pricing page lists only this one plan, with a minimum annual contract and prices through sales; it does not list a free plan. Current terms are available directly from Sourcegraph.

Who is the Sourcegraph MCP Server for?

It is worthwhile for teams that already run a Sourcegraph Enterprise instance and maintain many repositories: an assistant can then ask where a function is used, when a change was introduced, or how a service is built, without anyone collecting code by hand. If you only work on a single repository, your editor's built-in tools are usually enough. Start with the narrow endpoint and widen it only when needed.

Requirements

A Sourcegraph instance on the Enterprise plan, the MCP feature enabled (mcp.enabled), the MCP#ACCESS permission, and an MCP client with HTTP transport, for example Claude Code.

Installation instructions

With the Sourcegraph MCP Server, an AI assistant uses the code search of your Sourcegraph instance. This guide leads from checking the prerequisites to the first search.

Step 1: Prerequisites

According to the documentation, the server is supported on the Enterprise plan. MCP access is on by default (mcp.enabled); if /.api/mcp answers with 404, an administrator has switched it off. Your account needs the MCP#ACCESS permission, which the User role includes. For OAuth, dynamic client registration must be active or an administrator must pre-register clients.

Choose the right endpoint

/.api/mcp offers search, repositories and history. /.api/mcp/all additionally contains all other tools, including starting new Deep Search conversations. /.api/mcp/deepsearch provides only Deep Search. Start with /.api/mcp.

Step 2: Connect it to Claude Code

The command is claude mcp add --transport http sourcegraph https://sourcegraph.example.com/.api/mcp, replacing the address with that of your instance. On first use the OAuth sign-in opens. Then check with /mcp that the tools appear. With OpenAI Codex, the entry scopes = ["mcp"] in config.toml helps against the invalid_scope error.

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

First search and limits

Ask the assistant, for example, where a function is used or when a configuration was changed. Note that files over 128 KB return only the first 200 lines, list_files returns at most 1000 entries, and code_finder counts against the quota of your contract.

Narrow down access

The assistant sees only repositories your account may see in Sourcegraph. Administrators can switch off individual tools with mcp.tools.disabled. Keep in mind that source code that is read enters the context of the model provider.

claude mcp add --transport http sourcegraph https://sourcegraph.example.com/.api/mcp

Authentication

OAuth 2.0 with dynamic client registration or pre-registered clients; alternatively Sourcegraph access tokens.

Required access permissions

Read access to code, history and search with the rights of the signed-in user; only repositories that user may see in Sourcegraph are visible. The MCP#ACCESS permission is required.

Transmitted or stored data

Files read and search results enter the AI client context and therefore reach the model provider. Requests go to your own Sourcegraph instance.

Security risks

Confidential source code in the context of an external model, overly broad user rights, access tokens in configuration files, and prompt injection via comments or file contents in the searched code.

License and costs

License
Not recorded yet.
Cost
paid

According to the documentation and the pricing page, the server is supported on the Enterprise plan; the pricing page gives terms only through sales and lists no free plan.

Alternatives

Not recorded yet.

At a glance

Provider
Sourcegraph
Status
Official server
Deployment
Remote
Current version
Not recorded yet.
Last reviewed
25.10.2026

Repository and documentation

Categories

Supported clients