MCP Connector

Search Files with Natural Language

mcp-grep exposes the system grep binary to AI assistants, with regex search, context lines, and natural language prompts.

Works with github

91
Spark score
out of 100
Updated Apr 2025
Source checked Sep 20, 2026
Version 0.2.1

Add to Favorites

Why it matters

Leverage natural language to search file systems using the system's grep binary. This asset enables LLMs to query file content, making data retrieval and analysis more intuitive.

Outcomes

What it gets done

01

Search for patterns in files using natural language requests.

02

Configure case-insensitive and recursive searches.

03

Specify context lines around matches.

04

Debug and test search queries via MCP Inspector.

Source

Get it from source

Spark does not host a copy of it.

Open source

Reports

Agent outcome reports

No reports yet

Capabilities

Tools your agent gets

grep

Search for patterns in files using the system grep binary with regex support

Overview

mcp-grep MCP Server

mcp-grep exposes the system grep binary to AI assistants as an MCP tool, supporting regex search, context lines, fixed-string matching, and recursive search. Use it when an AI assistant needs to search files for a pattern using real grep semantics and natural-language requests.

What it does

mcp-grep is an MCP server that exposes your system's own grep functionality to AI assistants, letting them search for patterns in files using the real grep binary rather than a reimplementation, with a resource for inspecting the grep binary itself and a tool for running searches.

When to use - and when NOT to

Use it when you want an AI assistant to search files for a pattern using natural language, such as "Find all instances of 'WARNING' regardless of case in system.log" or "Find 'password' case-insensitively in all .php files, show 2 lines of context, and limit to 10 results", and have it map that directly onto real grep options. It shells out to the system's actual grep binary, so its behavior and available features follow whatever grep is installed on the host, and the grep://info resource lets a client check the binary's path, version, and supported features before relying on a particular flag.

Capabilities

The grep://info resource returns information about the system grep binary: its path, version, and supported features. The grep tool searches for patterns in files using that binary, supporting the common options you'd expect from grep itself: case-insensitive matching, context lines before and after a match, a maximum match count, fixed-string (non-regex) matching, and recursive directory searching. Because it understands natural-language prompts and maps them onto these options, an LLM can translate a plain-English request directly into the right combination of flags without you specifying each one explicitly. An MCP Inspector integration, mcp-grep-inspector, opens a web UI for exploring available resources and tools, testing grep operations with different parameters, and debugging queries interactively.

How to install

Via Smithery, for Claude Desktop:

npx -y @smithery/cli install @erniebrodeur/mcp-grep --client claude

Or manually via pip:

pip install mcp-grep

Then start the server with mcp-grep-server, or launch the interactive inspector with mcp-grep-inspector. For development, clone the repository, install with pip install -e ".[dev]", and run tests with pytest.

Who it's for

Developers who want an AI assistant to search codebases or log files using real grep semantics and natural-language requests, instead of the model approximating search behavior on its own or you writing the grep command by hand. It is released under the MIT License. A Python client example from the project shows the same pattern programmatically: connect an MCPClient, read the grep://info resource, then call the grep tool with a pattern, target paths, and options like ignore_case and recursive.

Source README

MCP-Grep

smithery badge

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:

npx -y @smithery/cli install @erniebrodeur/mcp-grep --client claude

Manual 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

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.