JUHE API Marketplace
safurrier avatar
MCP Server

MCP Filesystem Server

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.

66
GitHub Stars
6/24/2026
Last Updated
MCP Server Configuration
1{
2 "name": "mcp-filesystem",
3 "command": "uv",
4 "args": [
5 "--directory",
6 "/absolute/path/to/mcp-filesystem",
7 "run",
8 "run_server.py",
9 "/absolute/path/to/allowed-dir-1",
10 "/absolute/path/to/allowed-dir-2"
11 ]
12}
JSON12 lines
  1. Home
  2. MCP Servers
  3. mcp-filesystem

README Documentation

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 --version

Success signal:

MCP Filesystem Server v0.2.0
A Model Context Protocol server for filesystem operations

uv 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 --help

The 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.

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.json
  • Windows: %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-filesystem appears in Claude Desktop's MCP tools.
  • The tool list includes list_allowed_directories, read_file, grep_files, and edit_file_at_line.
  • Calling list_allowed_directories returns 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 -Wait

Run 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/dir2

If you do not pass directories, the server allows the current working directory.

Options verified from the CLI:

OptionMeaning
--transport, -tTransport protocol. Default: stdio. Use sse for SSE.
--port, -pPort for SSE transport. Default: 8000.
--debug, -dEnable debug logging through FASTMCP_LOG_LEVEL=DEBUG.
--version, -vPrint version information and exit.
--helpPrint CLI help and exit.

For MCP Inspector testing, run from a checkout:

npx @modelcontextprotocol/inspector uv run run_server.py /absolute/path/to/test-dir

The 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_DIRS when 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

ToolUse it for
list_allowed_directoriesShow the sandbox roots available to this server process.
list_directoryList files and directories, with optional hidden-file and pattern filtering.
get_file_infoReturn file or directory metadata.
read_fileRead one complete file.
read_multiple_filesRead several complete files in one tool call.
read_file_linesRead a line range with offset and limit.
head_fileRead the first N lines of a text file.
tail_fileRead the last N lines of a text file.
directory_treeReturn a recursive directory tree with depth and pattern controls.

Search

ToolUse it for
grep_filesSearch 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.
search_filesFind files or directories by glob pattern, optionally requiring content matches.

Mutating filesystem operations

ToolUse it for
write_fileCreate or overwrite a file. Can create parent directories when requested.
create_directoryCreate a directory, optionally including parents.
move_fileMove or rename a file or directory.
edit_fileApply old-text/new-text edits and return a git-style diff. Supports dry_run.
edit_file_at_lineApply line-targeted edits. Supports verification, relative line numbers, abort-on-verification-failure, and dry_run.

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

ToolUse it for
calculate_directory_sizeCalculate directory size as human-readable text, bytes, or JSON.
find_duplicate_filesFind duplicate files by size and content hash.
compare_filesCompare two text files and return similarity plus diff output.
find_large_filesFind files above a size threshold.
find_empty_directoriesFind 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-extras

Run 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_filesystem

The 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, mypy

make 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:

  1. Run uv run run_server.py --version from the checkout.
  2. Confirm the Claude config uses an absolute path after --directory.
  3. Confirm every allowed directory path is absolute and exists.
  4. 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.

Quick Install

Quick Actions

View on GitHubView All Servers

Key Features

Model Context Protocol
Secure Communication
Real-time Updates
Open Source

Boost your projects with Wisdom Gate LLM API

Supporting GPT-5, Claude-4, DeepSeek v3, Gemini and more.

Enjoy a free trial and save 20%+ compared to official pricing.

Learn More
JUHE API Marketplace

Accelerate development, innovate faster, and transform your business with our comprehensive API ecosystem.

JUHE API VS

  • vs. RapidAPI
  • vs. API Layer
  • API Platforms 2025
  • API Marketplaces 2025
  • Best Alternatives to RapidAPI

For Developers

  • Console
  • Collections
  • Documentation
  • MCP Servers
  • Free APIs
  • Temp Mail Demo

Product

  • Browse APIs
  • Suggest an API
  • Wisdom Gate LLM
  • Global SMS Messaging
  • Temp Mail API

Company

  • What's New
  • Welcome
  • About Us
  • Contact Support
  • Terms of Service
  • Privacy Policy
Featured on Startup FameFeatured on Twelve ToolsFazier badgeJuheAPI Marketplace - Connect smarter, beyond APIs | Product Huntai tools code.marketDang.aiFeatured on ShowMeBestAI
Copyright © 2026 JUHEDATA HK LIMITED - All rights reserved