fd-mcp
A Model Context Protocol (MCP) server that provides fast file search capabilities using fd, a modern alternative to the traditional find command.
What is fd-mcp?
fd-mcp bridges fd with AI assistants like Claude Code through the Model Context Protocol. It exposes fd's powerful file search capabilities as MCP tools, enabling AI assistants to efficiently navigate and search codebases.
Why fd?
fd offers significant advantages over traditional file search tools:
Blazing Fast: Written in Rust, fd is often 5-10x faster than
findfor typical searchesRecursive by Default: Searches directories recursively without special flags (use
max_depthto limit)User-Friendly Syntax: Simple, intuitive patterns instead of cryptic flags (
fd patternvsfind -name "*pattern*")Smart Defaults: Automatically respects
.gitignoreand skips hidden files/directoriesColorized Output: Enhanced readability with syntax highlighting
Parallel Execution: Leverages multiple CPU cores for faster searches
Regex Support: Built-in regex pattern matching without complex syntax
Use Cases
This MCP server is particularly useful for:
Codebase Navigation: Quickly locate files by name, extension, or pattern across large projects
Project Analysis: Find all files of a specific type (e.g., all Python test files, all configuration files)
Code Exploration: Help AI assistants understand project structure by efficiently listing directories and files
Pattern Matching: Search for files using regex patterns (e.g., find all migration files, test suites)
Selective Searches: Filter by file type, depth, or exclude specific patterns
Performance: Fast searches even in monorepos or large codebases with thousands of files
Prerequisites
Install fd:
Install ripgrep (required for fd_search_content tool):
Installation
Usage with Claude Code
Add to your Claude Code MCP settings (~/.claude.json):
Or run directly:
🚀 Claude Code Integration Best Practices
Once configured, Claude Code will have access to all fd-mcp tools. Here's how to get the most out of them:
Quick Start Commands
The project includes helpful slash commands to get started:
/find-py- Find all Python files (demonstratesfd_search)/search-code- Search code patterns (demonstratesfd_search_content)/recent- Show recently modified files (demonstratesfd_recent_files)/count-files- Count files by type (demonstratesfd_count)/demo-mcp- Run a full demonstration of all tools
Tool Selection Guide
When Claude Code needs to find files:
✅ Use:
mcp__fd__fd_search(pattern=".*", path=".", extension="py")❌ Instead of:
bash find . -name "*.py"Why: 5-10x faster, respects .gitignore automatically
When Claude Code needs to search code:
✅ Use:
mcp__fd__fd_search_content(search_pattern="TODO", extension="py")❌ Instead of:
bash find . -exec grep "TODO" {} \;Why: 10-100x faster, single operation, shows context
When Claude Code needs to find recent changes:
✅ Use:
mcp__fd__fd_recent_files(hours=24)❌ Instead of:
bash find . -mtime -1Why: Intuitive time params, faster execution
Performance Benefits
The tools are optimized for AI assistant workflows:
Operation | Traditional | fd-mcp | Speedup |
Find 1000 Python files | 2.5s | 0.3s | 8x faster |
Search "TODO" in files | 15s | 0.5s | 30x faster |
Find files changed today | 3s | 0.4s | 7x faster |
Count all files | 2s | 0.25s | 8x faster |
Learning Resources
See
CLAUDE.mdfor comprehensive usage patterns and examplesCheck
.claude/commands/for ready-to-use slash commandsReview tool descriptions in Claude Code for quick reference
Tools
fd_search
Replaces:
Search for files and directories using fd (5-10x faster than find). Searches recursively by default through all subdirectories.
Parameter | Type | Description |
pattern | string | Regex pattern (required, use ".*" or "" for all) |
path | string | Search directory (required, e.g., ".") |
type | string | f=file, d=dir, l=symlink, x=exec, e=empty |
extension | string | Filter by extension |
hidden | bool | Include hidden files |
no_ignore | bool | Don't respect .gitignore |
max_depth | int | Max search depth |
exclude | string | Glob pattern to exclude |
case_sensitive | bool | Case-sensitive search |
absolute_path | bool | Return absolute paths |
max_results | int | Limit results (default: 100) |
fd_search_content ⭐
Replaces:
Search for content within files using fd+ripgrep. This is the key tool that replaces find . -exec grep pattern {} \; style commands.
Parameter | Type | Description |
search_pattern | string | Text/regex to search in files (required) |
file_pattern | string | Filter files by name pattern |
path | string | Search directory (default: ".") |
extension | string | Filter by extension (e.g., "py", "js") |
type | string | Filter by type (f=file, d=dir, etc.) |
hidden | bool | Include hidden files |
no_ignore | bool | Don't respect .gitignore |
case_sensitive | bool | Case-sensitive search |
context_lines | int | Lines of context around matches |
max_results | int | Max files to search (default: 100) |
Note: Requires ripgrep (rg) to be installed.
fd_exec
Replaces:
Execute a command on files found by fd. Use {} as placeholder for filename.
Parameter | Type | Description |
command | string | Command to run (use {} for filename) |
pattern | string | File name pattern |
path | string | Search directory (default: ".") |
type | string | Filter by type |
extension | string | Filter by extension |
hidden | bool | Include hidden files |
no_ignore | bool | Don't respect .gitignore |
max_files | int | Max files to process (default: 100) |
fd_recent_files
Replaces:
Find recently modified files.
Parameter | Type | Description |
path | string | Search directory (default: ".") |
hours | int | Modified within N hours (default: 24) |
type | string | Filter by type |
extension | string | Filter by extension |
max_results | int | Limit results (default: 50) |
fd_count
Replaces:
Count files matching a pattern.
Parameter | Type | Description |
pattern | string | Regex pattern (required, use ".*" or "" for all) |
path | string | Search directory (required, e.g., ".") |
type | string | Filter by type |
extension | string | Filter by extension |
hidden | bool | Include hidden files |
Examples
Basic File Search
Find all Python files (recursively):
Find test files in entire project tree:
List directories only (limit to 2 levels deep):
Search only current directory (no recursion):
Content Search (replaces find -exec grep)
Find "TODO" in all Python files:
Find "import React" in JavaScript/TypeScript files with context:
Find error handling in specific directory:
Execute Commands on Files
Count lines in all Python files:
Format all JavaScript files:
Find Recent Changes
Files modified in last 2 hours:
Recent Python files modified in last day:
Command Replacements
Old Command | New MCP Tool |
|
|
|
|
|
|
|
|
|
|
License
This project is licensed under the MIT License - see the LICENSE file for details.