Skip to main content

MCP Grep Server

Project description

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

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_grep-0.2.1.tar.gz (24.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_grep-0.2.1-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file mcp_grep-0.2.1.tar.gz.

File metadata

  • Download URL: mcp_grep-0.2.1.tar.gz
  • Upload date:
  • Size: 24.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mcp_grep-0.2.1.tar.gz
Algorithm Hash digest
SHA256 8353db5d33a85bd95c25b57a79e07affd220ce7596f0cdeb57df820d4e8a245e
MD5 2f98c7990abe292ac370b07a0d8300c0
BLAKE2b-256 02e95a2b0665aa261053b8bc77a528360fd9b862f9d799e881f0727e8089a483

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_grep-0.2.1.tar.gz:

Publisher: python-publish.yml on erniebrodeur/mcp-grep

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcp_grep-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: mcp_grep-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mcp_grep-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aed2c9e19da038ccc9a12cf65c165c530b526fffa776463fdf85478a8b6f7cb5
MD5 7e147487bfd911c2b58c1ae4b4639dcb
BLAKE2b-256 b42e7d3490785dd2e2001c89e1619e1cdae5afdc54d648b44b5f255363bc51e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_grep-0.2.1-py3-none-any.whl:

Publisher: python-publish.yml on erniebrodeur/mcp-grep

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page