npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

sourcegraph-mcp-server

v1.4.2

Published

A Model Context Protocol (MCP) server that connects AI assistants to Sourcegraph code search with natural language capabilities

Readme

Sourcegraph MCP Server

A Model Context Protocol (MCP) server that allows AI assistants to search code repositories using natural language queries through the Sourcegraph API. The server also provides advanced code pattern research capabilities.

Key Features

  • Natural Language Code Search: Search using plain English queries
  • Code Search: Search for code across Sourcegraph repositories
  • Commit Search: Find commits with various filters
  • Diff Search: Find code changes/PRs
  • GitHub-specific Search: Search in specific GitHub repositories
  • Deep Code Research: Analyze code patterns and architecture across repositories

Quick Start

Installation & Usage

# Run directly with npx (simplest way)
npx sourcegraph-mcp-server

# Or install globally
npm install -g sourcegraph-mcp-server
sourcegraph-mcp-server

Configuration

Create a .env file with your Sourcegraph credentials before running:

SOURCEGRAPH_URL=https://your-sourcegraph-instance.com
SOURCEGRAPH_TOKEN=your_api_token

Using with MCP-Capable AI Assistants

Claude Desktop App

  1. In Claude Desktop, go to Settings > MCP Servers
  2. Add MCP Server
    • For STDIO: Process: npx -y sourcegraph-mcp-server
    • For HTTP: URL: http://localhost:3002
  3. Start using tools by typing "/tool" in Claude

MCP Inspector (for testing)

npx @modelcontextprotocol/inspector node dist/stdio-server.js

Available Tools

Basic Search Tools

  • search-code: Search code with Sourcegraph query syntax
  • search-commits: Find commits with filters
  • search-diffs: Find code changes/PRs
  • search-github-repos: Search in specific GitHub repositories

Code Intelligence Tools

  • get-definition: Find the definition of a symbol in code
  • get-references: Find all references to a symbol
  • get-implementations: Find implementations of interfaces or methods
  • get-hover-documentation: Get documentation for a symbol
  • get-document-symbols: List all symbols in a file

Repository Tools

  • get-file-content: Get the content of a file from a repository
  • get-file-blame: Get git blame information for a file

Security Tools

  • lookup-cve: Search for CVEs affecting repositories or packages
  • lookup-package-vulnerability: Check packages for vulnerabilities
  • search-exploits: Find exploit code for known vulnerabilities
  • find-vendor-advisory: Find vendor security advisories

Utility Tools

  • test-connection: Test connection to Sourcegraph API
  • echo: Simple test tool
  • debug: Show available tools

Code Intelligence Features

Sourcegraph MCP Server provides access to advanced code intelligence features:

  • Symbol Navigation: Jump to definitions and find references across repositories
  • Code Documentation: Get hover documentation for functions, classes, and variables
  • Repository Analysis: Examine file content and git blame history
  • Security Analysis: Find vulnerabilities and security advisories

These tools help you understand codebases more efficiently by providing context about code symbols, relationships, and vulnerabilities.

Advanced Search Syntax

Sourcegraph has a powerful search syntax you can use with the search tools:

  • Repository filtering: repo:^github\.com/owner/repo$
  • Language filtering: lang:javascript
  • File path filtering: file:\.js$
  • Content filtering: content:"exact phrase"
  • Boolean operators: term1 AND term2, term1 OR term2, term1 NOT term2
  • Regular expressions: /pattern/
  • Commit search: type:commit message:"fix bug" author:username
  • Diff search: type:diff select:commit.diff.added term

Troubleshooting

If you encounter issues:

  1. Environment Variables: Ensure SOURCEGRAPH_URL and SOURCEGRAPH_TOKEN are correctly set
  2. Connectivity: Verify your Sourcegraph instance is accessible
  3. Tool Errors: Use the debug tool to verify available tools

For detailed troubleshooting help, see the DEBUGGING.md file.

Project Structure

.
├── src/                     - TypeScript source files
│   ├── index.ts             - Main Express server entry point
│   ├── mcp-server.ts        - Model Context Protocol implementation  
│   ├── mcp-server-debug.ts  - Debug version of MCP server
│   ├── mcp-server-connect.ts - Connection testing implementation
│   ├── http-server.ts       - HTTP transport for MCP
│   └── stdio-server.ts      - STDIO transport for MCP
├── scripts/                 - Utility scripts for testing and development
│   ├── debug-server.js      - Debug server utility
│   └── test-search.js       - Test search functionality
├── dist/                    - Compiled JavaScript output
├── docs/                    - Documentation files
└── .env.example             - Example environment configuration

Running Manually (for Development)

# Clone the repository
git clone https://github.com/madhukarkumar/sg-ts-mcp-server.git
cd sg-ts-mcp-server

# Install dependencies
npm install

# Build the project
npm run build

# Start the HTTP MCP server
npm run start:mcp

# Or start the STDIO server
npm run start:stdio

License

MIT