mcp-grep
simple mcp server to wrap the local instance of grep.
claude mcp add --transport stdio erniebrodeur-mcp-grep python -m mcp_grep.server \ --env MCP_GREP_CONFIG="path/to/config.yaml (optional)"
How to use
MCP-Grep exposes a grep capability via the Model Context Protocol (MCP). It provides a Resource you can query to learn about the system's grep binary, and a Tool that performs pattern matching across files using the underlying grep utility. This makes it easy to integrate grep-based searches into MCP-enabled clients or LLM workflows. You can connect to the server with an MCP client, retrieve grep information, and then run searches with flexible options such as case-insensitive matching, recursive directory traversal, context lines, fixed-string mode, and result limits. The server also supports natural language prompts, so you can issue queries like “Search for errors in log.txt and show 2 lines of context” and get structured results suitable for downstream processing. The MCP Inspector provides an interactive UI for exploring available resources and testing grep queries in real time.
How to install
Prerequisites:
- Python 3.8+ (or a compatible Python runtime)
- Access to install Python packages (pip)
- Optionally, a virtual environment manager (venv/conda)
Installation steps:
-
Install the MCP-Grep package from PyPI: pip install mcp-grep
-
Run the MCP-Grep server (example): mcp-grep-server
If you installed via a Python package that exposes a module, you can also start via: python -m mcp_grep.server
-
(Optional) Install and run the MCP Inspector for interactive testing: mcp-grep-inspector
-
Verify the server is running by querying its MCP endpoints with an MCP client. Ensure any required environment variables (see Troubleshooting) are set before starting the server.
Additional notes
Tips and notes:
- The server exposes a grep://info resource that returns details about the system grep binary (path, version, features).
- Common grep options supported include case-insensitive matching, context lines, maximum number of matches, fixed-string mode, and recursive directory search.
- If you need to customize behavior, you can point the server to a specific configuration file via MCP_GREP_CONFIG (path or URL as appropriate for your deployment).
- When running behind containers or orchestration, ensure the container has access to the filesystem paths you want to search.
- If you encounter permission issues, verify that the user running the MCP-Grep server has read access to the target files.
- For development, use the MCP Inspector to interactively test resources and tools before integrating into larger workflows.
Related MCP Servers
mcp-neo4j
Neo4j Labs Model Context Protocol servers
Gitingest
mcp server for gitingest
zotero
Model Context Protocol (MCP) server for the Zotero API, in Python
sympy
A MCP server for symbolic manipulation of mathematical expressions
mcp-oi-wiki
🌟 Wiki of OI / ICPC for LLMs. (面向大模型的某大型游戏线上攻略,内含炫酷算术魔法)
CogniLayer
Persistent memory for Claude Code & Codex CLI — save ~100K tokens/session. 13 MCP tools, hybrid search, TUI dashboard, crash recovery. Your AI finally remembers.