code-search-mcp

jasonhawkharris/code-search-mcp

3.1

If you are the rightful owner of code-search-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

This is an MCP server implementation for Sourcegraph's code search capabilities, enabling language models to perform code search queries against Sourcegraph instances.

Tools
1
Resources
0
Prompts
0

Sourcegraph Code Search MCP Server

This is an MCP (Model Context Protocol) server implementation for Sourcegraph's code search capabilities. It allows language models to perform code search queries against Sourcegraph instances.

Features

  • Search code across any Sourcegraph instance (public or private)
  • Support for literal, regexp, and structural search patterns
  • Configurable search limits and parameters
  • Authentication support for private Sourcegraph instances

Installation

# Clone the repository
git clone https://github.com/yourusername/code-search-mcp.git
cd code-search-mcp

# Install dependencies
npm install

# Build the project
npm run build

Usage

Running the Server

# Start the server
npm start

Or directly use the node executable:

node build/index.js

Using as MCP Tool

This MCP server exposes a search_code tool with the following parameters:

  • query (string, required): The search query to execute
  • sourcegraphUrl (string, optional): The Sourcegraph instance URL (defaults to https://sourcegraph.com)
  • token (string, optional): Authentication token for private Sourcegraph instances
  • limit (number, optional): Max number of results to return (defaults to 10)
  • patternType (string, optional): Search pattern type (literal, regexp, or structural, defaults to literal)

Example Usage with Claude.ai

In Claude, you can use this MCP server by first adding it to your configuration:

# Add the MCP server (stdio transport)
claude mcp add sourcegraph-search -- path/to/code-search-mcp

# Or if you've installed it globally with npm
claude mcp add sourcegraph-search -- code-search-mcp

Then you can use Claude Code as normal and it will have access to the Sourcegraph search functionality:

claude code

Then you can ask Claude to use the code search tool:

Search for "context.WithTimeout" in the Go standard library

Development

# Run the development server (builds and starts)
npm run dev

License

ISC