|
2 | 2 |
|
3 | 3 | [](https://github.com/safurrier/mcp-filesystem/blob/main/LICENSE) |
4 | 4 |
|
5 | | -A powerful Model Context Protocol (MCP) server for filesystem operations that provides Claude and other MCP clients with secure access to files and directories. |
| 5 | +A powerful Model Context Protocol (MCP) server for filesystem operations optimized for intelligent interaction with large files and filesystems. It provides secure access to files and directories with smart context management to maximize efficiency when working with extensive data. |
6 | 6 |
|
7 | | -## Features |
| 7 | +## Why MCP-Filesystem? |
| 8 | + |
| 9 | +- **Smart Context Management**: Work efficiently with large files and filesystems |
| 10 | + - Partial reading to focus only on relevant content |
| 11 | + - Precise context control for finding exactly what you need |
| 12 | + - Token-efficient search results with pagination |
| 13 | + - Multi-file operations to reduce request overhead |
| 14 | + |
| 15 | +- **Intelligent File Operations**: |
| 16 | + - Line-targeted reading with configurable context windows |
| 17 | + - Advanced editing with content verification to prevent conflicts |
| 18 | + - Fine-grained search capabilities that exceed standard grep |
| 19 | + - Relative line references for precise file manipulation |
| 20 | + |
| 21 | +## Key Features |
8 | 22 |
|
9 | 23 | - **Secure File Access**: Only allows operations within explicitly allowed directories |
10 | 24 | - **Comprehensive Operations**: Full set of file system capabilities |
11 | 25 | - Standard operations (read, write, list, move, delete) |
12 | 26 | - Enhanced operations (tree visualization, duplicate finding, etc.) |
13 | 27 | - Advanced search with grep integration (uses ripgrep when available) |
14 | | - - Context control (like grep's -A/-B/-C options) |
| 28 | + - Context control (like grep's -A/-B/-C options) |
15 | 29 | - Result pagination for large result sets |
16 | 30 | - Line-targeted operations with content verification and relative line numbers |
17 | 31 | - **Performance Optimized**: |
@@ -340,28 +354,74 @@ Arguments: { |
340 | 354 | } |
341 | 355 | ``` |
342 | 356 |
|
343 | | -## Efficient Workflow |
344 | | - |
345 | | -The tools are designed to work together efficiently: |
346 | | - |
347 | | -1. Use `grep_files` to find relevant content with precise context control |
348 | | - - Fine-grained control over context lines before/after matches |
349 | | - - Paginate through large result sets efficiently |
350 | | -2. Examine specific sections with `read_file_lines` using offset/limit |
351 | | - - Zero-based indexing with simple offset/limit parameters |
352 | | - - Control exactly how many lines to read |
353 | | -3. Make targeted edits with `edit_file_at_line` with content verification |
354 | | - - Verify content hasn't changed before editing |
355 | | - - Use relative line numbers for regional editing |
356 | | - - Multiple edit actions in a single operation |
357 | | - |
358 | | -This workflow allows Claude to work effectively even with very large codebases by focusing on just the relevant parts while ensuring edits are safe and precise. |
| 357 | +## Efficient Workflow for Large Files and Filesystems |
| 358 | + |
| 359 | +MCP-Filesystem is designed for intelligent interaction with large files and complex filesystems: |
| 360 | + |
| 361 | +1. **Smart Context Discovery** |
| 362 | + - Use `grep_files` to find exactly what you need with precise context control |
| 363 | + - Fine-grained control over context lines before/after matches prevents token waste |
| 364 | + - Paginate through large result sets efficiently without overwhelming token limits |
| 365 | + - Ripgrep integration handles massive filesystems with millions of files and lines |
| 366 | + |
| 367 | +2. **Targeted Reading** |
| 368 | + - Examine only relevant sections with `read_file_lines` using offset/limit |
| 369 | + - Zero-based indexing with simple offset/limit parameters for precise content retrieval |
| 370 | + - Control exactly how many lines to read to maximize token efficiency |
| 371 | + - Read multiple files simultaneously to reduce round-trips |
| 372 | + |
| 373 | +3. **Precise Editing** |
| 374 | + - Make targeted edits with `edit_file_at_line` with content verification |
| 375 | + - Verify content hasn't changed before editing to prevent conflicts |
| 376 | + - Use relative line numbers for regional editing in complex files |
| 377 | + - Multiple edit actions in a single operation for complex changes |
| 378 | + - Dry-run capability to preview changes before applying |
| 379 | + |
| 380 | +4. **Advanced Analysis** |
| 381 | + - Use specialized tools like `find_duplicate_files` and `compare_files` |
| 382 | + - Generate directory trees with `directory_tree` for quick navigation |
| 383 | + - Identify problematic areas with `find_large_files` and `find_empty_directories` |
| 384 | + |
| 385 | +This workflow is particularly valuable for AI-powered tools that need to work with large files and filesystems. For example, Claude and other advanced AI assistants can leverage these capabilities to efficiently navigate codebases, analyze log files, or work with any large text-based datasets while maintaining token efficiency. |
| 386 | + |
| 387 | +## Advantages Over Standard Filesystem MCP Servers |
| 388 | + |
| 389 | +Unlike basic filesystem MCP servers, MCP-Filesystem offers: |
| 390 | + |
| 391 | +1. **Token Efficiency** |
| 392 | + - Smart line-targeted operations avoid loading entire files into context |
| 393 | + - Pagination controls for large results prevent context overflow |
| 394 | + - Precise grep with context controls (not just whole file searches) |
| 395 | + - Multi-file reading reduces round-trip requests |
| 396 | + |
| 397 | +2. **Intelligent Editing** |
| 398 | + - Content verification to prevent edit conflicts |
| 399 | + - Line-targeted edits that don't require the entire file |
| 400 | + - Relative line number support for easier regional editing |
| 401 | + - Dry-run capability to preview changes before applying |
| 402 | + |
| 403 | +3. **Advanced Search** |
| 404 | + - Ripgrep integration for massive filesystem performance |
| 405 | + - Context-aware results (not just matches) |
| 406 | + - Fine-grained control over what gets returned |
| 407 | + - Pattern-based file finding with exclusion support |
| 408 | + |
| 409 | +4. **Additional Utilities** |
| 410 | + - File comparison and deduplication |
| 411 | + - Directory size calculation and analysis |
| 412 | + - Empty directory identification |
| 413 | + - Tree-based directory visualization |
| 414 | + |
| 415 | +5. **Security Focus** |
| 416 | + - Robust path validation and sandboxing |
| 417 | + - Protection against path traversal attacks |
| 418 | + - Symlink validation and security |
| 419 | + - Detailed error reporting without sensitive exposure |
359 | 420 |
|
360 | 421 | ## Known Issues and Limitations |
361 | 422 |
|
362 | | -- **Regex Escaping**: When using regex patterns with special characters like `\d`, `\w`, or `\s`, you may need to double-escape backslashes (e.g., `\\d`, `\\w`, `\\s`). This is due to how JSON processes escape characters. |
363 | 423 | - **Path Resolution**: Always use absolute paths for the most consistent results. Relative paths might be interpreted relative to the server's working directory rather than the allowed directories. |
364 | | -- **Performance**: For large directories, operations like `find_duplicate_files` might take significant time to complete. |
| 424 | +- **Performance**: For large directories, operations like `find_duplicate_files` or recusrive search might take significant time to complete. |
365 | 425 | - **Permission Handling**: The server operates with the same permissions as the user running it. Make sure the server has appropriate permissions for the directories it needs to access. |
366 | 426 |
|
367 | 427 | ## Security |
|
0 commit comments