An MCP Server wrapper around the grep CLI tool
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.
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.
# 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.gitTo 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.jsThe 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.
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.
Search using natural language descriptions. Accepts intent, target, case sensitivity, max results, and context options to return relevant matches.
Search using direct regular expressions. Supports file extensions filtering, case sensitivity, whole word matching, and context options.
Count matches for a given pattern. Can report per-file counts and filter by file type.
List files that contain at least one match for the pattern, with optional file extension filtering.
Execute grep with a custom set of arguments for advanced users.