Allows displaying GitHub license badges in the project README through the Shields.io integration.
MCP Filesystem Server
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.
Why MCP-Filesystem?
Smart Context Management: Work efficiently with large files and filesystems
Partial reading to focus only on relevant content
Precise context control for finding exactly what you need
Token-efficient search results with pagination
Multi-file operations to reduce request overhead
Intelligent File Operations:
Line-targeted reading with configurable context windows
Advanced editing with content verification to prevent conflicts
Fine-grained search capabilities that exceed standard grep
Relative line references for precise file manipulation
Key Features
Secure File Access: Only allows operations within explicitly allowed directories
Comprehensive Operations: Full set of file system capabilities
Standard operations (read, write, list, move, delete)
Enhanced operations (tree visualization, duplicate finding, etc.)
Advanced search with grep integration (uses ripgrep when available)
Context control (like grep's -A/-B/-C options)
Result pagination for large result sets
Line-targeted operations with content verification and relative line numbers
Performance Optimized:
Efficiently handles large files and directories
Ripgrep integration for blazing fast searches
Line-targeted operations to avoid loading entire files
Comprehensive Testing: 75+ tests with behavior-driven approach
Cross-Platform: Works on Windows, macOS, and Linux
Quickstart Guide
1. Clone and Setup
First, install uv if you haven't already:
Then clone the repository and install dependencies:
2. Get Absolute Paths
You'll need absolute paths both for the repository location and any directories you want to access:
3. Configure Claude Desktop
Open your Claude Desktop configuration file:
On macOS:
~/Library/Application\ Support/Claude/claude_desktop_config.json
On Windows:
%APPDATA%/Claude/claude_desktop_config.json
Add the following configuration (substitute your actual paths):
Important: All paths must be absolute (full paths from root directory). Use
realpath
orpwd
to ensure you have the correct absolute paths.
4. Restart Claude Desktop
After saving your configuration, restart Claude Desktop for the changes to take effect.
Installation
Usage
Watch Server Logs
You can monitor the server logs from Claude Desktop with:
This is particularly useful for debugging issues or seeing exactly what Claude is requesting.
Running the Server
Run the server with access to specific directories:
Options
--transport
or-t
: Transport protocol (stdio or sse, default: stdio)--port
or-p
: Port for SSE transport (default: 8000)--debug
or-d
: Enable debug logging--version
or-v
: Show version information
Using with MCP Inspector
For interactive testing and debugging with the MCP Inspector:
This server has been built with the FastMCP SDK for better alignment with current MCP best practices. It uses an efficient component caching system and direct decorator pattern.
Claude Desktop Integration
Edit your Claude Desktop config file to integrate MCP-Filesystem:
Config file location:
On macOS:
~/Library/Application\ Support/Claude/claude_desktop_config.json
On Windows:
%APPDATA%/Claude/claude_desktop_config.json
To allow access to specific directories, add them as additional arguments:
Note: The
--directory
flag is important as it tells uv where to find the repository containing run_server.py. Replace/path/to/mcp-filesystem/repo
with the actual path to where you cloned the repository on your system.
Development
Running Tests
Code Style and Quality
Available Tools
Basic File Operations
read_file: Read the complete contents of a file
read_multiple_files: Read multiple files simultaneously
write_file: Create a new file or overwrite an existing file
create_directory: Create a new directory or ensure a directory exists
list_directory: Get a detailed listing of files and directories
move_file: Move or rename files and directories
get_file_info: Retrieve detailed metadata about a file or directory
list_allowed_directories: List directories the server is allowed to access
Line-Targeted Operations
read_file_lines: Read specific line ranges with offset/limit parameters
edit_file_at_line: Make precise edits with content verification and relative line numbers
Support for content verification to prevent editing outdated content
Relative line numbers for easier regional editing
Multiple edit actions (replace, insert_before, insert_after, delete)
head_file: Read the first N lines of a text file
tail_file: Read the last N lines of a text file
Advanced Search
grep_files: Search for patterns in files with powerful options
Ripgrep integration for performance (with Python fallback)
Fine-grained context control (like grep's -A/-B/-C options)
Result pagination for large search results
RegEx support with case sensitivity and whole word options
search_files: Search for files matching patterns with content search
directory_tree: Get a recursive tree view of files and directories
Analytics and Reporting
calculate_directory_size: Calculate the total size of a directory
find_duplicate_files: Find duplicate files by comparing content
compare_files: Compare two text files and show differences
find_large_files: Find files larger than a specified size
find_empty_directories: Find empty directories
Usage Examples
Reading File Lines
Searching for Content with Grep
Line-Targeted Editing
Finding Duplicate Files
Efficient Workflow for Large Files and Filesystems
MCP-Filesystem is designed for intelligent interaction with large files and complex filesystems:
Smart Context Discovery
Use
grep_files
to find exactly what you need with precise context controlFine-grained control over context lines before/after matches prevents token waste
Paginate through large result sets efficiently without overwhelming token limits
Ripgrep integration handles massive filesystems with millions of files and lines
Targeted Reading
Examine only relevant sections with
read_file_lines
using offset/limitZero-based indexing with simple offset/limit parameters for precise content retrieval
Control exactly how many lines to read to maximize token efficiency
Read multiple files simultaneously to reduce round-trips
Precise Editing
Make targeted edits with
edit_file_at_line
with content verificationVerify content hasn't changed before editing to prevent conflicts
Use relative line numbers for regional editing in complex files
Multiple edit actions in a single operation for complex changes
Dry-run capability to preview changes before applying
Advanced Analysis
Use specialized tools like
find_duplicate_files
andcompare_files
Generate directory trees with
directory_tree
for quick navigationIdentify problematic areas with
find_large_files
andfind_empty_directories
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.
Advantages Over Standard Filesystem MCP Servers
Unlike basic filesystem MCP servers, MCP-Filesystem offers:
Token Efficiency
Smart line-targeted operations avoid loading entire files into context
Pagination controls for large results prevent context overflow
Precise grep with context controls (not just whole file searches)
Multi-file reading reduces round-trip requests
Intelligent Editing
Content verification to prevent edit conflicts
Line-targeted edits that don't require the entire file
Relative line number support for easier regional editing
Dry-run capability to preview changes before applying
Advanced Search
Ripgrep integration for massive filesystem performance
Context-aware results (not just matches)
Fine-grained control over what gets returned
Pattern-based file finding with exclusion support
Additional Utilities
File comparison and deduplication
Directory size calculation and analysis
Empty directory identification
Tree-based directory visualization
Security Focus
Robust path validation and sandboxing
Protection against path traversal attacks
Symlink validation and security
Detailed error reporting without sensitive exposure
Known Issues and Limitations
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.
Performance: For large directories, operations like
find_duplicate_files
or recusrive search might take significant time to complete.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.
Security
The server enforces strict path validation to prevent access outside allowed directories:
Only allows operations within explicitly allowed directories
Provides protection against path traversal attacks
Validates symlinks to ensure they don't point outside allowed directories
Returns meaningful error messages without exposing sensitive information
Performance Considerations
For best performance with grep functionality:
Install ripgrep (
rg
)The server automatically uses ripgrep if available, with a Python fallback
License
local-only server
The server can only run on the client's local machine because it depends on local resources.
Tools
A Model Context Protocol server that provides secure and intelligent interaction with files and filesystems, offering smart context management and token-efficient operations for working with large files and complex directory structures.
Related MCP Servers
- -securityAlicense-qualityA Model Context Protocol server that provides file system operations, analysis, and manipulation capabilities through a standardized tool interface.Last updated -4MIT License
- AsecurityAlicenseAqualityA Model Context Protocol server that enables enhanced file system operations including reading, writing, copying, moving files with streaming capabilities, directory management, file watching, and change tracking.Last updated -16MIT License
- AsecurityAlicenseAqualityA secure Model Context Protocol server that provides controlled filesystem access within predefined directories, enabling AI models to perform file and directory operations with strict path validation.Last updated -1667MIT License
- AsecurityAlicenseAqualityA server implementing the Model Context Protocol that provides filesystem operations (read/write, directory management, file movement) through a standardized interface with security controls for allowed directories.Last updated -93MIT License