MCP Grep Server
Project description
MCP-Grep
A grep server implementation that exposes grep functionality through the Model Context Protocol (MCP).
Installation
pip install mcp-grep
Usage
MCP-Grep runs as a server that can be used by MCP-compatible clients:
# 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:
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:
# 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
# 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_grep-0.2.0.tar.gz.
File metadata
- Download URL: mcp_grep-0.2.0.tar.gz
- Upload date:
- Size: 23.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d78e92c35de9fadce02d08764529b3e22bfbf418b552bd01f2bbfeadac310fec
|
|
| MD5 |
78be9211ccf35c56a909c3b9528b8d7a
|
|
| BLAKE2b-256 |
e2785df7240bd7b4edb9d4c78a8cc4c8ef064089d029d82f9bd7c2ee3ef71a84
|
Provenance
The following attestation bundles were made for mcp_grep-0.2.0.tar.gz:
Publisher:
python-publish.yml on erniebrodeur/mcp-grep
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_grep-0.2.0.tar.gz -
Subject digest:
d78e92c35de9fadce02d08764529b3e22bfbf418b552bd01f2bbfeadac310fec - Sigstore transparency entry: 192837685
- Sigstore integration time:
-
Permalink:
erniebrodeur/mcp-grep@11e67565bec21183f7d210c3ca96a3fb156407b5 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/erniebrodeur
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@11e67565bec21183f7d210c3ca96a3fb156407b5 -
Trigger Event:
release
-
Statement type:
File details
Details for the file mcp_grep-0.2.0-py3-none-any.whl.
File metadata
- Download URL: mcp_grep-0.2.0-py3-none-any.whl
- Upload date:
- Size: 23.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1db578e0ab6e84dfc6039d61b67a9d6b6463499a5ef2c2bce58f6cf35eab4959
|
|
| MD5 |
f0664a6f0757c9a6a4e96666f723650c
|
|
| BLAKE2b-256 |
838961d8a9a07dcb587af1388df28fa610bb961c5f72d3e88d3e73f20b857686
|
Provenance
The following attestation bundles were made for mcp_grep-0.2.0-py3-none-any.whl:
Publisher:
python-publish.yml on erniebrodeur/mcp-grep
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_grep-0.2.0-py3-none-any.whl -
Subject digest:
1db578e0ab6e84dfc6039d61b67a9d6b6463499a5ef2c2bce58f6cf35eab4959 - Sigstore transparency entry: 192837687
- Sigstore integration time:
-
Permalink:
erniebrodeur/mcp-grep@11e67565bec21183f7d210c3ca96a3fb156407b5 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/erniebrodeur
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@11e67565bec21183f7d210c3ca96a3fb156407b5 -
Trigger Event:
release
-
Statement type: