Sourcegraph MCP
Sourcegraph MCP Server

Code context for any AI agent

Sourcegraph MCP gives AI agents precise, cross-repository code intelligence through the open Model Context Protocol, including search, navigation, history, and Deep Search.

Trusted by world-class engineering teams

Guide

Running coding agents in enterprise codebases

Most enterprise agent failures are not model failures. They are systems failures. A practitioner's guide to running coding agents reliably across large codebases.

Download guide
Running coding agents in enterprise codebases
The context problem

Narrow context: Fast, confident, wrong

Same prompt. Two agents. Real queries run against public open-source repos.
Agent
Agent Sourcegraph MCP
keyword_search({ query: "three-way merge" })
keyword_search({ query: "Settings Sync merge conflicts" })
keyword_search({ query: "added removed updated conflicts" })
read_file({ path: "...common/settingsMerge.ts" })
How MCP works

How Sourcegraph MCP retrieves context

Sourcegraph MCP gives agents access to precise, cross-repository code intelligence through a standardized retrieval layer.

Agent

Plans what to ask

An AI coding agent receives your request and decides which Sourcegraph tools to call.

Codex
Claude Code
Amp
Cursor
Sourcegraph MCP

Exposes tools the agent calls

Authenticates requests, lists available tools, and routes each call to the right retrieval primitive.

SearchRead fileGo-to-definitionFind referencesDiffsDeep Search
Retrieval layer

Finds precise context at any scale

Keyword and semantic search, navigation, commit history, diffs, and ownership — across every indexed repository.

settingsMerge.tsclass Authorizer@Deprecatedmain..feat/authblame: processPanelsowners: pkg/
Codebase

The ground truth

Every repository, branch, file, and commit — the actual code the model retrieves from, not a summarized snapshot.

microsoft/vscodeapache/kafkafeat/log4j-patchcomputeMergeResultAclAuthorizer.javasrc/vs/platform/
Retrieval capabilities

Give your agents precise code context

Agents can retrieve:

Search. Semantic search for fuzzy concepts, keyword, and regex search for exact matches across every repository.

Files and repos. List repos, map directory structures, and pull exact file ranges — no guessing paths.

Navigation. Go-to-definition and find-all-references across repositories, powered by precise code indexing (SCIP, an open standard for code intelligence).

History. Search commits and diffs, compare revisions, and recover intent from change history.

Deep Search and ownership. Multi-step investigation across repos, plus contributor and ownership signals.

MCP ecosystem

Compatible with any MCP-aware agent

Sourcegraph MCP works with MCP-compatible agents and development environments, allowing teams to standardize retrieval across tools without locking into a single vendor ecosystem.

Codex
Claude Code
Amp
Cursor

And more

“(Stripe’s) Minions are connected to MCP…this is how they gather context like internal documentation, ticket details, build statuses, code intelligence via Sourcegraph search…”

— Alistair Gray, Stripe

Additional resources

Blog

Why coding agents fail in large codebases

Read now

Comparison

AI coding context tools compared.

See comparison

Ebook

CodeScaleBench: Benchmarking AI coding agents on real-world, large-scale codebases

Download guide

Give your agents the context they need

Improve agent accuracy, reduce rework, and give AI systems access to the full codebase context required to operate safely at enterprise scale.