home / mcp / grep mcp server

Grep MCP Server

An MCP Server wrapper around the grep CLI tool

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "247arjun-mcp-grep": {
      "command": "node",
      "args": [
        "/absolute/path/to/mcp-grep/build/index.js"
      ]
    }
  }
}

You have a Model Context Protocol (MCP) server that lets you search text efficiently using grep, with both natural language prompts and direct regex patterns. It supports recursive searches, file-type filtering, context lines, and optional case sensitivity, making it a powerful tool for codebases, logs, and documentation alike.

How to use

You connect to the MCP server from your MCP client or your development setup. Start the server locally and issue search commands through the client’s MCP interface. Use natural language intents to describe what you want to find, or supply direct regex patterns for precise matching. You can request surrounding context, limit results, and filter by file extensions to narrow down results.

How to install

# Prerequisites
- Node.js 12+ ( npm comes with Node )
- Access to a terminal/command prompt

# Method 1: Install globally (recommended for quick start)
npm install -g @247arjun/mcp-grep

# Method 1b: Install locally in your project
npm install @247arjun/mcp-grep

# Method 2: From source
# Clone the repository
git clone https://github.com/247arjun/mcp-grep.git
cd mcp-grep

# Install dependencies
npm install

# Build the project
npm run build

# Optional: Link globally for easy access
npm link
# Method 3: Direct from GitHub
npm install -g git+https://github.com/247arjun/mcp-grep.git

Configuration and running locally

To run and connect to your MCP client, you can start a local stdio server that runs the MCP implementation directly from your machine.

# Local development startup (stdio)
node /absolute/path/to/mcp-grep/build/index.js

Security and safety notes

The server executes commands in a controlled environment, with input validation and non-shell execution to prevent command injection. Always validate file targets and avoid exposing sensitive directories.

Troubleshooting and tips

If the server does not start as expected, ensure Node is installed, rebuild if you modified source, and verify the path to the built index file is correct. If issues persist, check for missing dependencies and ensure your MCP client is configured to connect to the local stdio instance.

Available tools

grep_search_intent

Search using natural language descriptions. Accepts intent, target, case sensitivity, max results, and context options to return relevant matches.

grep_regex

Search using direct regular expressions. Supports file extensions filtering, case sensitivity, whole word matching, and context options.

grep_count

Count matches for a given pattern. Can report per-file counts and filter by file type.

grep_files_with_matches

List files that contain at least one match for the pattern, with optional file extension filtering.

grep_advanced

Execute grep with a custom set of arguments for advanced users.