About Sourcegraph MCP Server
Sourcegraph MCP Server connects LLMs to Sourcegraph for code search and analysis. Its tools include React prop usage searches and repository file retrieval.
Key features
- 01Search code with Sourcegraph
- 02Find React component prop usage
- 03Retrieve repository file contents
- 04Test connection and return version
Use cases
- 01Find usages of a React component prop
- 02Search repositories with a query and result limit
- 03Read a specific file from a repository
- 04Verify Sourcegraph connectivity
MCP support
Exposes Sourcegraph connection testing, code search, file retrieval, and React prop usage search tools to MCP clients.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMESourcegraph MCP Server
An MCP (Model Context Protocol) server that integrates with Sourcegraph to provide code search and analysis capabilities to LLMs.
Sourcegraph Access Token
You will need to generate an API access token before using any of the server's tools.
- Visit your Sourcegraph instance (e.g., https://sourcegraph.com)
- Click your profile icon in the top right
- Navigate to Settings > Access tokens
- Create a new token with appropriate scopes
- Copy the token and set it as an environment variable
Environment Variables
The server uses two environment variables which can be set on your local environment or in the MCP server configuration.
SRC_ACCESS_TOKEN: Your Sourcegraph access token (see above)SRC_ENDPOINT(optional): Your Sourcegraph instance URL (defaults to https://sourcegraph.com)
Installation
1. Build the server from Typescript
yarn run build
2. Configure MCP Server
There are many MCP Clients available to use, but below are two examples:
Install script
For convenience, there is an optional install script which you can run to automatically set up Cursor with the correct configuration. The script will walk you through setting up your Sourcegraph environment variables, so have your access token ready before starting.
./install_cursor.sh
3. Verify Installation
When you have completed the setup steps, confirm that the server is correctly configured with your MCP Client by prompting it to use the testSourcegraphConnection tool.
Available Tools
The server exposes the following tools to an LLM:
testSourcegraphConnection: Test the connection to Sourcegraph and return version informationsearch: Search code in Sourcegraph with a given query and limiting resultsgetFileContent: Retrieve specific file contents from a repositorysearchReactPropUsage: Searches Sourcegraph for code that uses a specific prop of a specific React component
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.