Skip to content

Summary

Sourcegraph's MCP server — cross-repository keyword and semantic code search, go-to-definition, find-references, commit and diff search, and Deep Search, served from your own instance.

Features

  • keyword_search and nls_search across every indexed repository
  • go_to_definition and find_references from precise code intelligence
  • read_file with line numbers, ranges and specific revisions
  • commit_search, diff_search and compare_revisions over history
  • deepsearch: multi-step conversational questions about the codebase
  • evaluator: run Lua scripts to aggregate and compute over results
  • Three endpoint scopes (/.api/mcp, /all, /deepsearch) plus per-tool disabling
  • OAuth 2.0 Dynamic Client Registration with a dedicated mcp scope

Installation

Set up this MCP server in your favorite AI agent — copy a ready-made configuration below.

Any MCP-compatible agent

Most agents (Claude, Cursor, Windsurf, VS Code, and more) read a standard mcpServers configuration.

  1. Open your agent's MCP configuration file.
  2. Merge the snippet below into it.
  3. Restart the agent — the "Sourcegraph" tools will be available.
{
  "mcpServers": {
    "sourcegraph": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "https://sourcegraph.example.com/.api/mcp"
      ]
    }
  }
}

Description

Most coding agents see one repository: the one checked out in front of them. Sourcegraph MCP fixes that by exposing your Sourcegraph instance's index over the Model Context Protocol, so an agent can search, navigate and read across every repository your organisation has indexed — before it writes a line of code that assumes an API it never checked.

Tools. Files and repos: read_file (with line numbers, revisions and ranges), list_files, list_repos. Search: keyword_search for exact matching with filters, nls_search for semantic search with flexible linguistic matching, and evaluator for running Lua scripts over results to aggregate and compute. Navigation: go_to_definition and find_references, backed by precise code intelligence rather than grep heuristics. History: commit_search, diff_search (search the actual code changes, not just messages), compare_revisions and get_contributor_repos. And two higher-level agents: code_finder, a fast search agent for locating relevant code, plus deepsearch and deepsearch_read for multi-step questions about a codebase.

Three endpoints on your instance. /.api/mcp for the core search and repository tools, /.api/mcp/all for the full suite, and /.api/mcp/deepsearch for Deep Search alone — pick the smallest surface that does the job so the agent's tool list stays legible. Server-side, mcp.enabled turns it on and mcp.tools.disabled removes individual tools.

Auth and clients. OAuth 2.0 via Dynamic Client Registration (on by default since the February 2026 GA release) or pre-registered OAuth clients, with Sourcegraph access tokens as the alternative; there is a dedicated mcp OAuth scope. Documented clients are Claude Code, Codex, Cursor, Copilot, OpenCode and Amp. Available on Sourcegraph Cloud and self-hosted 7.0 and later.

Worth knowing before you plan around it: the MCP server is supported on Enterprise plans, and the URL is your own instance host — there is no public multi-tenant endpoint.

Practical tip from the docs: call list_repos first to scope which repositories matter, then constrain later searches to them. It measurably improves both speed and result quality on a large index.

Related MCP Servers

MCP: Headroom

by Headroom Labs

New

Context-compression MCP server that shrinks tool outputs, logs, files and RAG chunks before they reach the model, cutting 60-95% of tokens on JSON payloads.

MCP: Engram

by Gentleman Programming

New

Persistent memory for coding agents as a single Go binary — SQLite and FTS5 behind MCP, an HTTP API, a CLI and a TUI, with no Node, Python or Docker required.

MCP: agent-device

by Callstack

New

Give a coding agent a live feedback loop on real mobile, TV and desktop apps — inspect, tap, type and capture evidence on iOS, Android and HarmonyOS over MCP or a CLI.

New

The official W&B MCP server: query experiment runs, Weave LLM traces, artifacts and registries in natural language, and write findings back as a W&B report.

Browse all MCP servers →