Code Search, Read & PR Analysis
Enables LLMs to search and read files in local and GitHub repositories, analyze pull request diffs, and grep code content with built-in security protections.
README
MCP Server: Code Search, Read & PR Analysis
A Python-based Model Context Protocol (MCP) server that enables LLMs to interact with codebases through search, read, and PR analysis capabilities.
Features
Local Operations:
- š Search: Find files by name (glob) or content (grep) in local repositories
- š Read: Safely read file contents with path traversal protection
GitHub Integration:
- š PR Analysis: Fetch and analyze GitHub Pull Request diffs
- š GitHub Search: Search for files by name in any GitHub repository
- š GitHub Read: Read file contents directly from GitHub repositories
- š¬ Code Grep: Search code content across GitHub repositories
Security & Performance:
- š Security: Automatic filtering of sensitive files (.env, credentials, keys)
- ā” Performance: Uses native tools (ripgrep, git grep) for fast searches
Quick Start
# Install dependencies
uv sync
# Run the server
uv run python -m mcp_server
# Run tests
uv run pytest -v
Installation & Setup
For detailed instructions on running the server and installing it in VS Code, see run.md.
Project Structure
src/mcp_server/
āāā server.py # Main MCP server entrypoint (6 tools)
āāā tools/
ā āāā search.py # Local file search (glob/grep)
ā āāā read.py # Local safe file reading
ā āāā github.py # GitHub integration (PR, search, read, grep)
tests/ # Comprehensive test suite (40 tests)
Available Tools
Local File Operations
1. search_files
Search for files by name pattern or content in local repository.
Parameters:
query(string): Search pattern (file pattern for glob, regex for grep)search_type(string): Either "glob" or "grep"path(string, optional): Root directory to search (defaults to current directory)
2. read_file
Read local file contents with security validation.
Parameters:
file_path(string): Path to the file to read
Security:
- Validates paths to prevent traversal attacks
- Blocks sensitive files (.env, credentials, keys)
GitHub Operations
3. get_pr_diff
Fetch GitHub Pull Request diffs.
Parameters:
repo(string): Repository in format "owner/repo"pr_number(integer): Pull request number
4. search_github_files
Search for files by name in a GitHub repository.
Parameters:
repo(string): Repository in format "owner/repo"query(string): Filename or path pattern to search forpath(string, optional): Path prefix to search within (e.g., "src/")
5. read_github_file
Read file contents directly from a GitHub repository.
Parameters:
repo(string): Repository in format "owner/repo"file_path(string): Path to the file in the repositorybranch(string, optional): Branch name (defaults to "main")
6. grep_github_repo
Search for code content in a GitHub repository (grep-like).
Parameters:
repo(string): Repository in format "owner/repo"query(string): Code content to search forpath(string, optional): Path prefix to search within
Note: GitHub operations require GITHUB_TOKEN environment variable for private repos and to avoid rate limits.
Development
# Install in development mode
uv pip install -e .
# Run tests with coverage
uv run pytest -v
# Lint code
uv run ruff check .
# Format code
uv run ruff format .
Configuration
See run.md for VS Code and Claude Desktop configuration examples.
Security
- All file operations validate paths to prevent directory traversal
- Sensitive files are automatically filtered from search results
- GitHub tokens should be stored securely (use environment variables)
- Server operates in stateless mode
Requirements
- Python 3.12+
- uv package manager
- Optional: ripgrep (for faster grep searches)
- Optional: GitHub token (for GitHub operations)
Documentation
- run.md - Detailed setup and installation guide
- doc.md - Original project specifications
- CLAUDE.md - Claude Code specific guidance
License
See LICENSE file for details.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
E2B
Using MCP to run code via e2b.