Search code across millions of public GitHub repositories using the grep.app API.
A Model Context Protocol (MCP) server that provides GitHub code search capabilities through the grep.app API. This server enables AI assistants to search through millions of GitHub repositories for specific code patterns, functions, and implementations.
mcp
- Model Context Protocol frameworkstarlette
- Web framework for SSE transportuvicorn
- ASGI serveraiohttp
- Async HTTP client for API requests# Install directly from PyPI
uv add grep-mcp
# Or install from source
git clone https://github.com/galperetz/grep-mcp.git
cd grep-mcp
uv sync
pip install grep-mcp
Add to your MCP client configuration:
{
"mcpServers": {
"grep-mcp": {
"command": "uvx",
"args": ["grep-mcp"]
}
}
}
# Run with stdio transport (default)
python -m grep_mcp
# Run with SSE transport
python -m grep_mcp --transport sse --host 0.0.0.0 --port 8080
--transport
: Choose between stdio
(default) or sse
--host
: Host to bind to for SSE mode (default: 0.0.0.0
)--port
: Port to listen on for SSE mode (default: 8080
)grep_query
Search GitHub repositories for specific code patterns.
Parameters:
query
(required): The search query stringlanguage
(optional): Programming language filter (e.g., "Python", "JavaScript")repo
(optional): Repository filter in format "owner/repo" (e.g., "fastapi/fastapi")path
(optional): Path filter for specific directories (e.g., "src/")Examples:
# Basic search
grep_query("async def main")
# Search Python files only
grep_query("FastAPI", language="Python")
# Search specific repository
grep_query("class Config", repo="fastapi/fastapi")
# Search in specific directory
grep_query("import", path="src/")
# Combined filters
grep_query("async def", language="Python", repo="fastapi/fastapi")
The tool returns structured JSON with:
{
"query": "your search query",
"summary": {
"total_results": 12345,
"results_shown": 10,
"repositories_found": 4,
"top_languages": [
{ "language": "Python", "count": 8500 },
{ "language": "JavaScript", "count": 2000 }
],
"top_repositories": [{ "repository": "owner/repo", "count": 150 }]
},
"results_by_repository": [
{
"repository": "owner/repo",
"matches_count": 89,
"files": [
{
"file_path": "src/main.py",
"branch": "main",
"total_matches": 5,
"line_numbers": [10, 25, 30],
"language": "python",
"code_snippet": "```python\nasync def main():\n app = FastAPI()\n return app\n```"
}
]
}
]
}
The server handles various error conditions gracefully:
Run the test suite:
# Using uv
uv run pytest
# Using pytest directly
pytest tests/
Test coverage includes:
git checkout -b feature/amazing-feature
uv run pytest
uv run black . && uv run isort .
git commit -m 'Add amazing feature'
git push origin feature/amazing-feature
This project is licensed under the MIT License - see the LICENSE file for details.
Made with โค๏ธ for the AI development community
A Model Context Protocol (MCP) server for the Open Library API that enables AI assistants to search for book and author information.
Enable Similarity-Distance-Magnitude statistical verification for your search, software, and data science workflows
Search for academic papers, authors, and citations using the Semantic Scholar API.
A web search server that integrates with the Exa API to perform basic and advanced searches.
Interact with the Haloscan SEO API for search engine optimization tasks.
Performs WHOIS lookups to retrieve domain registration details, including owner, registrar, and expiration dates.
Fetch, convert, and search AWS documentation pages, with recommendations for related content.
Performs web searches using the Gemini Web Search Tool via the local gemini-cli.
MCP server that performs whois lookup against domain, IP, ASN and TLD.
Search and book from over 2 million hotels with shopping and booking capabilities.