Get the FREE Ultimate OpenClaw Setup Guide →

mcp-grep

simple mcp server to wrap the local instance of grep.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
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:

  1. Install the MCP-Grep package from PyPI: pip install mcp-grep

  2. 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

  3. (Optional) Install and run the MCP Inspector for interactive testing: mcp-grep-inspector

  4. 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

Sponsor this space

Reach thousands of developers