- Explore MCP Servers
- sourcegraph-mcp-ts
Sourcegraph Mcp Ts
What is Sourcegraph Mcp Ts
sourcegraph-mcp-ts is a Model Context Protocol (MCP) server that enables AI assistants to perform natural language searches on code repositories using the Sourcegraph API.
Use cases
Use cases include searching for specific code files, finding commits by authors, tracking changes over time, and searching within specific repositories.
How to use
To use sourcegraph-mcp-ts, connect to the MCP server at http://localhost:3002 and utilize the ‘natural-search’ tool with your query. You can also test using the debug server or access the API directly with a POST request.
Key features
Key features include natural language code search, code and commit search, diff search, GitHub-specific search, and LLM-powered query translation using OpenAI or Anthropic.
Where to use
sourcegraph-mcp-ts can be used in software development environments, code review processes, and any application where code repository searching is required.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Sourcegraph Mcp Ts
sourcegraph-mcp-ts is a Model Context Protocol (MCP) server that enables AI assistants to perform natural language searches on code repositories using the Sourcegraph API.
Use cases
Use cases include searching for specific code files, finding commits by authors, tracking changes over time, and searching within specific repositories.
How to use
To use sourcegraph-mcp-ts, connect to the MCP server at http://localhost:3002 and utilize the ‘natural-search’ tool with your query. You can also test using the debug server or access the API directly with a POST request.
Key features
Key features include natural language code search, code and commit search, diff search, GitHub-specific search, and LLM-powered query translation using OpenAI or Anthropic.
Where to use
sourcegraph-mcp-ts can be used in software development environments, code review processes, and any application where code repository searching is required.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
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
Amp
- In the Amp extension, click the Settings icon and find the MCP Servers section
- Add MCP Server
- For stdio:
- Command:
npx - Arguments:
-y sourcegraph-mcp-server
- Command:
- For http:
- URL:
http://localhost:3002
- URL:
- Environment Variables:
SOURCEGRAPH_URLandSOURCEGRAPH_TOKEN
- For stdio:
MCP Inspector (for testing)
npx @modelcontextprotocol/inspector node dist/stdio-server.js
Available Tools
Basic Search Tools
search-code: Search code with Sourcegraph query syntaxsearch-commits: Find commits with filterssearch-diffs: Find code changes/PRssearch-github-repos: Search in specific GitHub repositories
Code Intelligence Tools
get-definition: Find the definition of a symbol in codeget-references: Find all references to a symbolget-implementations: Find implementations of interfaces or methodsget-hover-documentation: Get documentation for a symbolget-document-symbols: List all symbols in a file
Repository Tools
get-file-content: Get the content of a file from a repositoryget-file-blame: Get git blame information for a file
Security Tools
lookup-cve: Search for CVEs affecting repositories or packageslookup-package-vulnerability: Check packages for vulnerabilitiessearch-exploits: Find exploit code for known vulnerabilitiesfind-vendor-advisory: Find vendor security advisories
Utility Tools
test-connection: Test connection to Sourcegraph APIecho: Simple test tooldebug: 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:
- Environment Variables: Ensure SOURCEGRAPH_URL and SOURCEGRAPH_TOKEN are correctly set
- Connectivity: Verify your Sourcegraph instance is accessible
- Tool Errors: Use the
debugtool 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
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.










