The MCP Filesystem Server provides secure access to files and directories with intelligent context management, allowing for efficient interaction with large files and complex filesystems. It offers smart partial reading, precise context control, and token-efficient operations designed to work seamlessly with Claude and other AI assistants.
Before installing, you'll need to have:
# Install uv using the official installer
curl -fsSL https://raw.githubusercontent.com/astral-sh/uv/main/install.sh | bash
# Or with pipx
pipx install uv
# Clone the repository
git clone https://github.com/safurrier/mcp-filesystem.git
cd mcp-filesystem
# Install dependencies with uv
uv pip sync requirements.txt requirements-dev.txt
You'll need absolute paths for both the repository and any directories you want to access:
# Get the absolute path to the repository
REPO_PATH=$(pwd)
echo "Repository path: $REPO_PATH"
# Get absolute paths to directories you want to access
realpath ~/Documents
realpath ~/Downloads
# Or on systems without realpath:
echo "$(cd ~/Documents && pwd)"
Locate your Claude Desktop configuration file:
~/Library/Application\ Support/Claude/claude_desktop_config.json
%APPDATA%/Claude/claude_desktop_config.json
Add the MCP Filesystem server configuration:
{
"mcpServers": {
"mcp-filesystem": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/mcp-filesystem",
"run",
"run_server.py",
"/absolute/path/to/dir1",
"/absolute/path/to/dir2"
]
}
}
}
Important: All paths must be absolute (full paths from the root directory).
To debug issues or observe Claude's requests:
# On macOS
tail -n 20 -f ~/Library/Logs/Claude/mcp-server-mcp-filesystem.log
# On Windows (PowerShell)
Get-Content -Path "$env:APPDATA\Claude\Logs\mcp-server-mcp-filesystem.log" -Tail 20 -Wait
You can run the server directly with:
# Using uv (recommended)
uv run run_server.py /path/to/dir1 /path/to/dir2
# Or using standard Python
python run_server.py /path/to/dir1 /path/to/dir2
# Example with actual paths
uv run run_server.py /Users/username/Documents /Users/username/Downloads
--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 informationFor interactive testing and debugging:
# Basic usage
npx @modelcontextprotocol/inspector uv run run_server.py /path/to/directory
# With SSE transport
npx @modelcontextprotocol/inspector uv run run_server.py /path/to/directory --transport sse --port 8080
# With debug output
npx @modelcontextprotocol/inspector uv run run_server.py /path/to/directory --debug
Tool: read_file_lines
Arguments: {
"path": "/path/to/file.txt",
"offset": 99, # 0-based indexing (line 100)
"limit": 51, # Read 51 lines
"encoding": "utf-8" # Optional encoding
}
Tool: grep_files
Arguments: {
"path": "/path/to/search",
"pattern": "function\\s+\\w+\\(",
"is_regex": true,
"context_before": 2, # Show 2 lines before each match
"context_after": 5, # Show 5 lines after each match
"include_patterns": ["*.js", "*.ts"],
"results_offset": 0, # Start from the first match
"results_limit": 20 # Show at most 20 matches
}
Tool: edit_file_at_line
Arguments: {
"path": "/path/to/file.txt",
"line_edits": [
{
"line_number": 15,
"action": "replace",
"content": "This is the new content for line 15\n",
"expected_content": "Original content of line 15\n" # Verify content before editing
},
{
"line_number": 20,
"action": "delete"
}
],
"offset": 0, # Start considering lines from this offset
"relative_line_numbers": false, # Whether line numbers are relative to offset
"abort_on_verification_failure": true, # Stop on verification failure
"dry_run": true # Preview changes without applying
}
Tool: find_duplicate_files
Arguments: {
"path": "/path/to/search",
"recursive": true,
"min_size": 1024,
"format": "text"
}
For best performance with search functionality:
rg
)There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.