Provides package management functionality for installing dependencies and building the MCP server project
Enables type-safe development with TypeScript configuration and compilation support
Implements input validation using Zod schemas to ensure secure command execution
Grep MCP Server
A Model Context Protocol (MCP) server that provides powerful text search capabilities using the grep
command-line utility. This server allows you to search for patterns in files and directories using both natural language descriptions and direct regex patterns.
Features
🧠 Natural Language Search
- Describe what you're looking for in plain English
- Automatic conversion to appropriate regex patterns
- Built-in patterns for common searches (emails, URLs, phone numbers, etc.)
🔍 Advanced Search Capabilities
- Direct regex pattern matching
- Recursive directory searching
- File extension filtering
- Case-sensitive/insensitive search
- Whole word matching
- Context line display
- Match counting
- File listing with matches
🛡️ Security First
- Safe command execution using
child_process.spawn
- Input validation with Zod schemas
- No shell injection vulnerabilities
- Path validation and sanitization
Installation
Available Tools
1. grep_search_intent
Search using natural language descriptions.
Parameters:
intent
(string): Plain English description (e.g., "email addresses", "TODO comments")target
(string): File or directory path to searchcase_sensitive
(boolean, optional): Case-sensitive search (default: false)max_results
(number, optional): Limit number of resultsshow_context
(boolean, optional): Show surrounding lines (default: false)context_lines
(number, optional): Number of context lines (default: 2)
Example:
2. grep_regex
Search using direct regex patterns.
Parameters:
pattern
(string): Regular expression patterntarget
(string): File or directory path to searchcase_sensitive
(boolean, optional): Case-sensitive searchwhole_words
(boolean, optional): Match whole words onlyinvert_match
(boolean, optional): Show non-matching linesmax_results
(number, optional): Limit resultsshow_context
(boolean, optional): Show context linescontext_lines
(number, optional): Context line countfile_extensions
(array, optional): Filter by file extensions
Example:
3. grep_count
Count matches for a pattern.
Parameters:
pattern
(string): Pattern to counttarget
(string): Search targetcase_sensitive
(boolean, optional): Case sensitivitywhole_words
(boolean, optional): Whole word matchingby_file
(boolean, optional): Show count per filefile_extensions
(array, optional): File extension filter
4. grep_files_with_matches
List files containing the pattern.
Parameters:
pattern
(string): Search patterntarget
(string): Directory to searchcase_sensitive
(boolean, optional): Case sensitivitywhole_words
(boolean, optional): Whole word matchingfile_extensions
(array, optional): File extensions to includeexclude_patterns
(array, optional): File patterns to exclude
5. grep_advanced
Execute grep with custom arguments (advanced users).
Parameters:
args
(array): Array of grep arguments (excluding 'grep' itself)
Built-in Natural Language Patterns
The server recognizes these natural language intents:
Communication
- "email", "email address", "emails" → Email address pattern
- "url", "urls", "website", "link", "links" → URL pattern
- "phone", "phone number", "phone numbers" → Phone number pattern
Network
- "ip", "ip address", "ip addresses" → IPv4 address pattern
Data Types
- "number", "numbers", "integer", "integers" → Numeric patterns
- "date", "dates" → Date patterns
Code Patterns
- "function", "functions" → Function declarations
- "class", "classes" → Class definitions
- "import", "imports" → Import statements
- "export", "exports" → Export statements
- "comment", "comments" → Comment lines
- "todo", "todos" → TODO/FIXME/HACK comments
Error Patterns
- "error", "errors" → Error messages
- "warning", "warnings" → Warning messages
Usage Examples
Search for email addresses in a project
Find all TODO comments
Search for function definitions with regex
Count occurrences of a word
List files containing import statements
Development
Build and Run
Project Structure
MCP Integration
This server implements the Model Context Protocol and can be used with any MCP-compatible client.
Server Configuration
Add to your MCP client configuration:
Security Notes
- Uses
spawn
withshell: false
to prevent command injection - Validates all file paths before execution
- Blocks potentially dangerous grep flags in advanced mode
- Input validation with Zod schemas
- No access to system files outside specified targets
This server cannot be installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
Provides powerful text search capabilities using the grep command-line utility, allowing users to search files and directories using both natural language descriptions and regex patterns.
Related MCP Servers
- AsecurityAlicenseAqualityEnables text extraction from web pages and PDFs, and execution of predefined commands, enhancing content processing and automation capabilities.Last updated -3TypeScriptMIT License
- AsecurityAlicenseAqualityProvides ripgrep search capabilities to MCP clients like Claude, allowing high-performance text searches across files on your system.Last updated -529716JavaScriptMIT License
- -securityFlicense-qualityA high-performance string search utility with Model Context Protocol integration that enables AI assistants to perform efficient pattern searching in files and strings.Last updated -JavaScript
- -securityAlicense-qualityA server implementation that exposes grep functionality through the Model Context Protocol, allowing MCP-compatible clients to search for patterns in files using regular expressions.Last updated -10PythonGPL 3.0