https://github.com/erniebrodeur/mcp-grep
https://github.com/erniebrodeur/mcp-grep
anthropic mcp-server
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/erniebrodeur/mcp-grep
- Owner: erniebrodeur
- License: gpl-3.0
- Created: 2025-03-20T06:52:24.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-04-04T21:37:47.000Z (7 months ago)
- Last Synced: 2025-04-04T22:27:22.343Z (7 months ago)
- Topics: anthropic, mcp-server
- Language: Python
- Homepage:
- Size: 46.9 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- metorial-index - Grep Server - Expose grep functionality to applications, enabling pattern searching in files and retrieval of system grep information. Supports advanced search options and regular expressions for enhanced data processing capabilities. (Developer Tools)
- toolsdk-mcp-registry - ❌ mcp-grep - insensitive matching, context lines, and recursive directory searching. (python) (Search & Data Extraction / How to Submit)
- toolsdk-mcp-registry - ❌ mcp-grep - insensitive matching, context lines, and recursive directory searching. (python) (Command Line / How to Submit)
- awesome-mcp-servers - **mcp-grep** - Python-based MCP server that brings grep functionality to LLMs. Supports common grep features including pattern searching, case-insensitive matching, context lines, and recursive directory searches. `http` `llm` `git` `github` (📦 Other)
README
# MCP-Grep
[](https://smithery.ai/server/@erniebrodeur/mcp-grep)
A grep server implementation that exposes grep functionality through the Model Context Protocol (MCP).
## Installation
### Installing via Smithery
To install Grep Server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@erniebrodeur/mcp-grep):
```bash
npx -y @smithery/cli install @erniebrodeur/mcp-grep --client claude
```
### Manual Installation
```bash
pip install mcp-grep
```
## Usage
MCP-Grep runs as a server that can be used by MCP-compatible clients:
```bash
# Start the MCP-Grep server
mcp-grep-server
# Or use the MCP Inspector for interactive debugging and testing
mcp-grep-inspector
```
The server exposes the following MCP functionality:
- **Resource:** `grep://info` - Returns information about the system grep binary
- **Tool:** `grep` - Searches for patterns in files using the system grep binary
## Features
- Information about the system grep binary (path, version, supported features)
- Search for patterns in files using regular expressions
- Support for common grep options:
- Case-insensitive matching
- Context lines (before and after matches)
- Maximum match count
- Fixed string matching (non-regex)
- Recursive directory searching
- Natural language prompt understanding for easier use with LLMs
- Interactive debugging and testing through MCP Inspector
## Example API Usage
Using the MCP Python client:
```python
from mcp.client import MCPClient
# Connect to the MCP-Grep server
client = MCPClient()
# Get information about the grep binary
grep_info = client.get_resource("grep://info")
print(grep_info)
# Search for a pattern in files
result = client.use_tool("grep", {
"pattern": "search_pattern",
"paths": ["file.txt", "directory/"],
"ignore_case": True,
"recursive": True
})
print(result)
```
## Natural Language Prompts
MCP-Grep understands natural language prompts, making it easier to use with LLMs. Examples:
```
# Basic search
Search for 'error' in log.txt
# Case-insensitive search
Find all instances of 'WARNING' regardless of case in system.log
# With context lines
Search for 'exception' in error.log and show 3 lines before and after each match
# Recursive search
Find all occurrences of 'deprecated' in the src directory and its subdirectories
# Fixed string search (non-regex)
Search for the exact string '.*' in config.js
# Limited results
Show me just the first 5 occurrences of 'TODO' in the project files
# Multiple options
Find 'password' case-insensitively in all .php files, show 2 lines of context, and limit to 10 results
```
## MCP Inspector Integration
MCP-Grep includes an MCP Inspector integration for interactive debugging and testing:
```bash
# Start the MCP Inspector with MCP-Grep
mcp-grep-inspector
```
This opens a web-based UI where you can:
- Explore available resources and tools
- Test grep operations with different parameters
- View formatted results
- Debug issues with your grep queries
## Development
```bash
# Clone the repository
git clone https://github.com/erniebrodeur/mcp-grep.git
cd mcp-grep
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
```
## License
MIT