Grep MCP Server
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
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Grep MCP Server find all email addresses in the src directory"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Server for Grep
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.spawnInput validation with Zod schemas
No shell injection vulnerabilities
Path validation and sanitization
Related MCP server: Greply MCP Server
Installation
Method 1: NPM Installation (Recommended)
# Install globally
npm install -g @247arjun/mcp-grep
# Or install locally in your project
npm install @247arjun/mcp-grepMethod 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
npm linkMethod 3: Direct from GitHub
# Install directly from GitHub
npm install -g git+https://github.com/247arjun/mcp-grep.gitConfiguration
Claude Desktop Setup
Add to your Claude Desktop configuration file:
Location:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%/Claude/claude_desktop_config.json
Configuration:
{
"mcpServers": {
"mcp-grep": {
"command": "mcp-grep",
"args": []
}
}
}Alternative: Using npx (no global install needed)
{
"mcpServers": {
"mcp-grep": {
"command": "npx",
"args": ["@247arjun/mcp-grep"]
}
}
}Local Development Setup
{
"mcpServers": {
"mcp-grep": {
"command": "node",
"args": ["/absolute/path/to/mcp-grep/build/index.js"]
}
}
}After adding the configuration, restart Claude Desktop to load the MCP server.
Verification
Test that the server is working:
# Test the built server
node build/index.js
# Should show: "Grep MCP Server running on stdio"
# Press Ctrl+C to exitAvailable 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:
{
"intent": "email addresses",
"target": "./src",
"show_context": true,
"context_lines": 1
}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:
{
"pattern": "function\\s+\\w+\\s*\\(",
"target": "./src",
"file_extensions": ["js", "ts"],
"show_context": true
}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
{
"tool": "grep_search_intent",
"intent": "email addresses",
"target": "./src",
"show_context": true
}Find all TODO comments
{
"tool": "grep_search_intent",
"intent": "todo comments",
"target": "./",
"file_extensions": ["js", "ts", "py"]
}Search for function definitions with regex
{
"tool": "grep_regex",
"pattern": "^\\s*function\\s+\\w+",
"target": "./src",
"file_extensions": ["js"]
}Count occurrences of a word
{
"tool": "grep_count",
"pattern": "async",
"target": "./src",
"by_file": true
}List files containing import statements
{
"tool": "grep_files_with_matches",
"pattern": "^import",
"target": "./src",
"file_extensions": ["js", "ts"]
}Development
Build and Run
# Development with auto-rebuild
npm run dev
# Production build
npm run build
# Start the server
npm startProject Structure
mcp-grep/
āāā src/
ā āāā index.ts # Main server implementation
āāā build/ # Compiled JavaScript output
āāā package.json # Project configuration
āāā tsconfig.json # TypeScript configuration
āāā README.md # This fileTroubleshooting
Common Issues
"Command not found" error
Ensure mcp-grep is installed globally:
npm install -g @247arjun/mcp-grepOr use npx:
"command": "npx", "args": ["@247arjun/mcp-grep"]
"Permission denied" error
Check file permissions:
chmod +x build/index.jsRebuild the project:
npm run build
MCP server not appearing in Claude
Verify JSON syntax in configuration file
Restart Claude Desktop completely
Check that the command path is correct
"grep command not found"
Install grep on your system (usually pre-installed on macOS/Linux)
Windows users: Install via WSL or use Git Bash
Debugging
Enable verbose logging by setting environment variable:
# For development
DEBUG=1 node build/index.js
# Test with sample input
echo '{"jsonrpc": "2.0", "method": "initialize", "params": {}}' | node build/index.jsSecurity Notes
Uses
spawnwithshell: falseto prevent command injectionValidates 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
Available Tools
5 toolsgrep_advancedC
Execute grep with custom arguments (advanced usage)
Inputs: args (required).
grep_countC
Count the number of matches for a pattern
Inputs: pattern (required), target (required), case_sensitive, whole_words, +2 more.
grep_files_with_matchesB
List only the names of files that contain the pattern
Inputs: pattern (required), target (required), case_sensitive, whole_words, +2 more.
grep_regexC
Search using a direct regex pattern
Inputs: pattern (required), target (required), case_sensitive, whole_words, +5 more.
grep_search_intentB
Search for patterns using plain English descriptions (e.g., 'email addresses', 'phone numbers', 'TODO comments')
Inputs: intent (required), target (required), case_sensitive, max_results, +2 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogā¦
TDQS
Scored across 5 tools
The tools have overlapping purposes, as grep_advanced, grep_regex, and grep_search_intent all perform pattern searches, which could cause confusion. However, grep_count and grep_files_with_matches are more distinct in focusing on counting matches and listing files, respectively, which helps mitigate ambiguity.
All tool names follow a consistent snake_case pattern with a 'grep_' prefix, making them predictable and easy to understand. This uniformity enhances clarity and usability across the tool set.
With 5 tools, the server is well-scoped for a grep-focused utility, offering a reasonable range of operations without being overwhelming. Each tool appears to serve a specific function, justifying its inclusion.
The tool set covers core grep functionalities like searching, counting, and file listing, with advanced and intent-based options. A minor gap is the lack of a basic grep tool for simple pattern matching, but agents can work around this using the provided tools.
Maintenance
Related MCP Connectors
Read and search folders on your own computer with explicit consent. Files are never uploaded.
Search your Obsidian vault to quickly find notes by title or keyword, summarize related content, aā¦
Search prompts, CLAUDE.md/AGENTS.md templates, Cursor rules, Agent Skills and MCP servers.
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Related MCP Servers
- AlicenseBqualityDmaintenanceProvides ripgrep search capabilities to MCP clients like Claude, allowing high-performance text searches across files on your system.5904 npm79MIT
- AlicenseBqualityDmaintenanceEnables file and directory searching through the greply CLI tool with configurable search options like context lines, case sensitivity, and pattern matching. Provides direct access to powerful grep-like functionality from MCP-compatible clients.213 npmMIT
- -licenseNot gradedqualityNot gradedmaintenanceEnables exploration and search of local filesystems using glob pattern matching to find files and grep to search for text patterns within files.-
- FlicenseNot gradedqualityNot gradedmaintenanceEnables exploration and search of local filesystems using glob pattern matching to find files and grep to search for text patterns within files.-