MCP Filesystem Server
The MCP Filesystem Server provides sandboxed filesystem access for MCP clients, enabling reading, searching, editing, and managing files and directories within explicitly allowed paths. All operations are validated against allowed directory roots, with symlink checks to prevent sandbox escaping.
File Reading
read_file– Read a complete fileread_multiple_files– Read several files in one callread_file_lines– Read a specific line rangehead_file/tail_file– Read the first or last N lines
Discovery & Inspection
list_allowed_directories– Show accessible sandbox rootslist_directory– List contents with optional filteringget_file_info– Retrieve file/directory metadatadirectory_tree– Recursive tree with depth/pattern controlssearch_files– Find files by glob pattern with optional content matching
Content Search
grep_files– Regex/literal search with context lines, pagination, size limits, and optional JSON output (uses ripgrep when available)
File & Directory Mutation
write_file– Create or overwrite a file (with optional parent directory creation)create_directory– Create a directory, including parents optionallymove_file– Move or rename a file or directoryedit_file– Apply old-text/new-text replacements with git-style diff preview anddry_runsupportedit_file_at_line– Line-targeted edits with verification, relative line numbers, anddry_runsupport
Analysis & Cleanup
calculate_directory_size– Total directory size in human-readable, bytes, or JSON formatfind_duplicate_files– Find duplicates by size and content hashcompare_files– Compare two text files with similarity score and diff outputfind_large_files– Locate files above a size thresholdfind_empty_directories– Identify empty directories within a path
Allows displaying GitHub license badges in the project README through the Shields.io integration.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Filesystem Serversearch for TODO comments in my project directory"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Filesystem Server
Status: This project is no longer under active development. It was useful when MCP clients and agent harnesses were still early and did not yet have good built-in file search or filesystem interaction. Modern clients may already cover much of what this server provides.
MCP Filesystem Server lets an MCP client read, search, and edit files inside directories you explicitly allow. It is useful when Claude Desktop or another MCP client needs filesystem access with path sandboxing, line-range reads, grep-style search, and edit previews.
The server does not grant whole-disk access. At startup you pass one or more allowed directories; every tool call is validated against those roots.
Quick start from a source checkout
This README documents running the server from this repository. Published-package installation is not verified here.
git clone https://github.com/safurrier/mcp-filesystem.git
cd mcp-filesystem
uv sync --frozen
uv run run_server.py --versionSuccess signal:
MCP Filesystem Server v0.2.0
A Model Context Protocol server for filesystem operationsuv sync --frozen installs the locked dependencies into .venv in the checkout.
To see the command-line options without starting an MCP session:
uv run run_server.py --helpThe main entry points in this repo are:
uv run run_server.py ...— direct script used by tests and the Claude Desktop examples below.uv run mcp-filesystem ...— installed console script with the same Typer CLI.
Related MCP server: File Operations MCP Server
Connect it to Claude Desktop
Use absolute paths for both the repository and the directories you want the server to access:
REPO_PATH=$(pwd)
PROJECTS_PATH=$(cd ~/Projects && pwd)
DOCUMENTS_PATH=$(cd ~/Documents && pwd)
printf 'repo=%s\nprojects=%s\ndocuments=%s\n' "$REPO_PATH" "$PROJECTS_PATH" "$DOCUMENTS_PATH"Edit Claude Desktop's config file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
Add one server entry, replacing the example paths with your own absolute paths:
{
"mcpServers": {
"mcp-filesystem": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/mcp-filesystem",
"run",
"run_server.py",
"/absolute/path/to/allowed-dir-1",
"/absolute/path/to/allowed-dir-2"
]
}
}
}Restart Claude Desktop after saving the file.
Claude-side success signals:
The MCP server named
mcp-filesystemappears in Claude Desktop's MCP tools.The tool list includes
list_allowed_directories,read_file,grep_files, andedit_file_at_line.Calling
list_allowed_directoriesreturns only the directories you passed in the config.
If the server does not appear, watch the Claude Desktop MCP log:
# macOS
tail -n 50 -f ~/Library/Logs/Claude/mcp-server-mcp-filesystem.log
# Windows PowerShell
Get-Content -Path "$env:APPDATA\Claude\Logs\mcp-server-mcp-filesystem.log" -Tail 50 -WaitRun the server manually
The server uses stdio by default, which is what MCP clients such as Claude Desktop expect:
uv run run_server.py /absolute/path/to/dir1 /absolute/path/to/dir2If you do not pass directories, the server allows the current working directory.
Options verified from the CLI:
Option | Meaning |
| Transport protocol. Default: |
| Port for SSE transport. Default: |
| Enable debug logging through |
| Print version information and exit. |
| Print CLI help and exit. |
For MCP Inspector testing, run from a checkout:
npx @modelcontextprotocol/inspector uv run run_server.py /absolute/path/to/test-dirThe Inspector command may download Node packages through npx if they are not already installed.
How access control works
Allowed roots come from positional CLI arguments, or from
MCP_ALLOWED_DIRSwhen the CLI sets it.If neither is set, the current working directory is the only allowed root.
Paths are validated before filesystem operations run.
Symlinks are checked so a path inside an allowed root cannot point outside it.
The server runs with the operating-system permissions of the user that started it.
Practical rule: pass the narrowest directory that contains the files you want Claude to work with. Do not pass /, your full home directory, or a secrets directory unless you mean to expose it to the MCP client.
MCP tools
Tool names below are taken from mcp_filesystem/server.py.
Discovery and read-only file access
Tool | Use it for |
| Show the sandbox roots available to this server process. |
| List files and directories, with optional hidden-file and pattern filtering. |
| Return file or directory metadata. |
| Read one complete file. |
| Read several complete files in one tool call. |
| Read a line range with |
| Read the first N lines of a text file. |
| Read the last N lines of a text file. |
| Return a recursive directory tree with depth and pattern controls. |
Search
Tool | Use it for |
| Search file contents with literal or regex matching, context lines, pagination, size limits, and optional JSON output. Uses ripgrep when available and falls back to Python. |
| Find files or directories by glob pattern, optionally requiring content matches. |
Mutating filesystem operations
Tool | Use it for |
| Create or overwrite a file. Can create parent directories when requested. |
| Create a directory, optionally including parents. |
| Move or rename a file or directory. |
| Apply old-text/new-text edits and return a git-style diff. Supports |
| Apply line-targeted edits. Supports verification, relative line numbers, abort-on-verification-failure, and |
Start mutating work with dry_run: true where the tool supports it. For write_file, create_directory, and move_file, choose a temporary test directory first if you are checking behavior.
Analysis and cleanup helpers
Tool | Use it for |
| Calculate directory size as human-readable text, bytes, or JSON. |
| Find duplicate files by size and content hash. |
| Compare two text files and return similarity plus diff output. |
| Find files above a size threshold. |
| Find empty directories. |
These helpers can scan many files. Use narrow allowed directories and result limits for large trees.
Common workflows
Read a specific part of a large file
Use grep_files to find a match, then read_file_lines to inspect the surrounding range. read_file_lines uses a 0-based offset and a maximum limit.
{
"path": "/absolute/path/to/file.log",
"offset": 1200,
"limit": 80,
"encoding": "utf-8"
}Search with context and pagination
{
"path": "/absolute/path/to/project",
"pattern": "def main",
"is_regex": false,
"context_before": 2,
"context_after": 4,
"include_patterns": ["*.py"],
"results_offset": 0,
"results_limit": 20
}Preview a line-targeted edit
{
"path": "/absolute/path/to/file.txt",
"line_edits": [
{
"line_number": 15,
"action": "replace",
"content": "replacement text\n",
"expected_content": "old text\n"
}
],
"abort_on_verification_failure": true,
"dry_run": true
}Then repeat with dry_run: false only after the preview is correct.
Development
Set up the checkout:
uv sync --frozen --all-extrasRun focused checks while editing:
uv run -m pytest tests/test_cli.py
uv run -m pytest tests/test_server_unit.py
uv run -m ruff check mcp_filesystem tests
uv run -m mypy mcp_filesystemThe Makefile also provides maintainer workflows:
make setup # compiles requirements, creates .venv, syncs deps, installs pre-commit hooks
make check # setup, lint with --fix, format, tests with coverage, mypymake check mutates local files because it may update requirements, install hooks, apply Ruff fixes, and write coverage data.
Troubleshooting
Claude Desktop cannot start the server
Do this:
Run
uv run run_server.py --versionfrom the checkout.Confirm the Claude config uses an absolute path after
--directory.Confirm every allowed directory path is absolute and exists.
Check the Claude MCP log shown above.
Do not use relative paths in the Claude config; they may be resolved relative to the client process, not this repository.
A file outside the allowed directory is rejected
That is expected. Restart the MCP server with the narrowest additional allowed root that contains the file.
Search is slower than expected
Install ripgrep (rg). The server uses ripgrep when it is available and falls back to Python search otherwise.
A mutating tool changed the wrong file
Prefer edit_file_at_line with expected_content, abort_on_verification_failure: true, and dry_run: true before applying changes. For whole-file replacement, use read_file or get_file_info first so the client has the current path and content.
Further reading
CONTRIBUTING.md — contribution flow and maintainer expectations.
CHANGELOG.md — notable changes and API behavior notes.
LICENSE — MIT license.
Maintenance
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/safurrier/mcp-filesystem'
If you have feedback or need assistance with the MCP directory API, please join our Discord server