grep_files
Search files and directories for specific patterns or regex with customizable filters, context lines, and output formats on the MCP Filesystem Server.
Instructions
Search for pattern in files, similar to grep.
Args:
path: Starting directory or file path
pattern: Text or regex pattern to search for
is_regex: Whether to treat pattern as regex
case_sensitive: Whether search is case sensitive
whole_word: Match whole words only
include_patterns: Only include files matching these patterns
exclude_patterns: Exclude files matching these patterns
context_lines: Number of lines to show before AND after matches (like grep -C)
context_before: Number of lines to show BEFORE matches (like grep -B)
context_after: Number of lines to show AFTER matches (like grep -A)
results_offset: Start at Nth match (0-based, for pagination)
results_limit: Return at most this many matches (for pagination)
max_results: Maximum total matches to find during search
max_file_size_mb: Skip files larger than this size
recursive: Whether to search subdirectories
max_depth: Maximum directory depth to recurse
count_only: Only show match counts per file
format: Output format ('text' or 'json')
ctx: MCP context
Returns:
Search results
Input Schema
Name | Required | Description | Default |
---|---|---|---|
case_sensitive | No | ||
context_after | No | ||
context_before | No | ||
context_lines | No | ||
count_only | No | ||
exclude_patterns | No | ||
format | No | text | |
include_patterns | No | ||
is_regex | No | ||
max_depth | No | ||
max_file_size_mb | No | ||
max_results | No | ||
path | Yes | ||
pattern | Yes | ||
recursive | No | ||
results_limit | No | ||
results_offset | No | ||
whole_word | No |
Input Schema (JSON Schema)
{
"properties": {
"case_sensitive": {
"default": true,
"title": "Case Sensitive",
"type": "boolean"
},
"context_after": {
"default": 0,
"title": "Context After",
"type": "integer"
},
"context_before": {
"default": 0,
"title": "Context Before",
"type": "integer"
},
"context_lines": {
"default": 0,
"title": "Context Lines",
"type": "integer"
},
"count_only": {
"default": false,
"title": "Count Only",
"type": "boolean"
},
"exclude_patterns": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Exclude Patterns"
},
"format": {
"default": "text",
"title": "Format",
"type": "string"
},
"include_patterns": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Include Patterns"
},
"is_regex": {
"default": false,
"title": "Is Regex",
"type": "boolean"
},
"max_depth": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Max Depth"
},
"max_file_size_mb": {
"default": 10,
"title": "Max File Size Mb",
"type": "number"
},
"max_results": {
"default": 1000,
"title": "Max Results",
"type": "integer"
},
"path": {
"title": "Path",
"type": "string"
},
"pattern": {
"title": "Pattern",
"type": "string"
},
"recursive": {
"default": true,
"title": "Recursive",
"type": "boolean"
},
"results_limit": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Results Limit"
},
"results_offset": {
"default": 0,
"title": "Results Offset",
"type": "integer"
},
"whole_word": {
"default": false,
"title": "Whole Word",
"type": "boolean"
}
},
"required": [
"path",
"pattern"
],
"title": "grep_filesArguments",
"type": "object"
}