Skip to content

About

Official Sourcegraph MCP-compatible server (for older versions that do not support the official MCP)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

sourcegraph-mcp

MCP server for self-hosted Sourcegraph instances (v5.x+) that don't expose the native /.api/mcp endpoint.

Translates Model Context Protocol tool calls into Sourcegraph GraphQL API requests, giving AI agents (Claude Code, Cursor, etc.) full access to code search and navigation.

Tools

Tool Description
keyword_search Code search with filters (repo:, file:, lang:, type:)
nls_search Natural language search (keyword fallback on v5.0.x)
find_references Find all usages of a symbol via regex
go_to_definition Jump to symbol definition
read_file Read file contents from a repository
list_files List files/directories in a repository path
list_repos List indexed repositories
commit_search Search commits by message, author, date
diff_search Search code changes (diffs) over time
compare_revisions Compare two revisions showing file diffs
deepsearch Comprehensive codebase investigation
deepsearch_read Extract insights from search results
get_contributor_repos Find repositories a user contributed to

Quick start

Prerequisites

  • Docker
  • Sourcegraph access token (Settings > Access tokens)

Build

git clone https://github.com/codeproger/sourcegraph-mcp.git
cd sourcegraph-mcp
docker build -t sourcegraph-mcp .

Configure Claude Code

Add to ~/.mcp.json:

{
  "mcpServers": {
    "sourcegraph": {
      "command": "docker",
      "args": [
        "run", "--rm", "-i",
        "-e", "SOURCEGRAPH_URL=https://sourcegraph.example.com",
        "-e", "SOURCEGRAPH_TOKEN=sgp_YOUR_TOKEN",
        "sourcegraph-mcp"
      ]
    }
  }
}

Run without Docker

go build -o sourcegraph-mcp ./cmd/sourcegraph-mcp
SOURCEGRAPH_URL=https://sourcegraph.example.com SOURCEGRAPH_TOKEN=sgp_... ./sourcegraph-mcp

Environment variables

Variable Required Description
SOURCEGRAPH_URL Yes Sourcegraph instance URL
SOURCEGRAPH_TOKEN Yes Access token

Limitations

  • nls_search and deepsearch fall back to keyword search on Sourcegraph v5.0.x (no Cody/semantic search)
  • find_references and go_to_definition use regex patterns, not SCIP precise code intelligence

License

MIT

About

Official Sourcegraph MCP-compatible server (for older versions that do not support the official MCP)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages