by erniebrodeur
Provides a Model Context Protocol interface to the system grep utility, enabling pattern searches and grep metadata retrieval via MCP‑compatible clients.
Mcp Grep wraps the local grep
binary and exposes its functionality through MCP resources and tools, allowing LLM‑driven or programmatic searches without invoking the command line directly.
Installation
npx -y @smithery/cli install @erniebrodeur/mcp-grep --client claude
pip install mcp-grep
Running the server
# start the MCP server
mcp-grep-server
# optional interactive debugging UI
mcp-grep-inspector
Client usage (Python example)
from mcp.client import MCPClient
client = MCPClient()
info = client.get_resource("grep://info")
print(info)
result = client.use_tool("grep", {
"pattern": "error",
"paths": ["log.txt"],
"ignore_case": True,
"recursive": False
})
print(result)
Q: Do I need Node.js to run Mcp Grep?
A: No. The core package is a Python library; Node.js is only required if you install via Smithery, which uses npx
for convenience.
Q: Which operating systems are supported?
A: Any OS with a standard grep
binary (Linux, macOS, BSD, Windows via WSL or GNU grep).
Q: How can I limit the number of results?
A: Use the max_count
parameter in the tool call or include “show only the first N matches” in the natural‑language prompt.
Q: Can I customize environment variables for the server?
A: The server inherits the environment of the process that runs mcp-grep-server
. Set variables like PATH
or GREPOPTIONS
before starting the server if needed.
Q: Is there a way to view grep version information?
A: Yes. Call the grep://info
resource to receive JSON with the binary path, version string, and supported flags.
A grep server implementation that exposes grep functionality through the Model Context Protocol (MCP).
To install Grep Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @erniebrodeur/mcp-grep --client claude
pip install mcp-grep
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:
grep://info
- Returns information about the system grep binarygrep
- Searches for patterns in files using the system grep binaryUsing 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)
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-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:
# 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
MIT
Please log in to share your review and rating for this MCP.
Discover more MCP servers with similar functionality and use cases
by zed-industries
Provides real-time collaborative editing powered by Rust, enabling developers to edit code instantly across machines with a responsive, GPU-accelerated UI.
by cline
Provides autonomous coding assistance directly in the IDE, enabling file creation, editing, terminal command execution, browser interactions, and tool extension with user approval at each step.
by continuedev
Provides continuous AI assistance across IDEs, terminals, and CI pipelines, offering agents, chat, inline editing, and autocomplete to accelerate software development.
by github
Enables AI agents, assistants, and chatbots to interact with GitHub via natural‑language commands, providing read‑write access to repositories, issues, pull requests, workflows, security data and team activity.
by block
Automates engineering tasks by installing, executing, editing, and testing code using any large language model, providing end‑to‑end project building, debugging, workflow orchestration, and external API interaction.
by RooCodeInc
An autonomous coding agent that lives inside VS Code, capable of generating, refactoring, debugging code, managing files, running terminal commands, controlling a browser, and adapting its behavior through custom modes and instructions.
by lastmile-ai
A lightweight, composable framework for building AI agents using Model Context Protocol and simple workflow patterns.
by firebase
Provides a command‑line interface to manage, test, and deploy Firebase projects, covering hosting, databases, authentication, cloud functions, extensions, and CI/CD workflows.
by gptme
Empowers large language models to act as personal AI assistants directly inside the terminal, providing capabilities such as code execution, file manipulation, web browsing, vision, and interactive tool usage.