MCP File System Server

MCP File System Server

A secure, sandboxed file system server that enables reading, writing, searching, and managing files through MCP-compatible AI clients with path traversal protection and size limits.

Category
Visit Server

README

๐Ÿ“ MCP File System Server

A secure, sandboxed file system server for the Model Context Protocol. Read, write, search, and manage files through any MCP-compatible AI client โ€” with path traversal protection, hidden file controls, and size limits.

License: MIT Python 3.10+


โœจ Features

  • ๐Ÿ”ง 5 Tools: read_file, write_file, list_directory, search_files, get_file_info
  • ๐Ÿ“„ 1 Resource: file://{path} โ€” read files via MCP resource URIs
  • ๐Ÿ›ก๏ธ Security-First Architecture: Sandbox isolation, path traversal prevention, max size limits
  • ๐Ÿ”ฅ Hidden File Control: Block .hidden files by default, opt-in with --allow-hidden
  • ๐Ÿ” Glob-Based Search: Search by pattern (*.py, *.md, data_*.csv)
  • ๐Ÿ“Š Rich Metadata: File size, timestamps, permissions, text/binary detection
  • ๐Ÿ–ฅ๏ธ Dual Transport: stdio and Streamable HTTP

๐Ÿš€ Quick Start

# 1. Setup
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

# 2. Create sandbox and run
mkdir -p /tmp/mcp-sandbox
python filesystem_server.py --sandbox /tmp/mcp-sandbox

๐Ÿ› ๏ธ Tools Reference

read_file(path: str) -> str

Read a file and return its contents with metadata (size, modified time, SHA256).

write_file(path: str, content: str) -> str

Write content to a file. Creates parent directories automatically.

list_directory(path: str) -> str

List files and directories with sizes and type indicators.

search_files(pattern: str, base_path: str = "") -> str

Search by glob pattern across the entire sandbox.

get_file_info(path: str) -> str

Get detailed metadata: type, size, timestamps, permissions, text/binary detection.


๐Ÿ›ก๏ธ Security Controls

--sandbox PATH          # Required: root directory (all operations restricted)
--allow-hidden          # Allow access to .hidden files and directories
--max-size N            # Max file size in MB (default: 10)
Attack Vector Protection
../../../etc/passwd โŒ Path traversal prevented
~/.ssh/id_rsa โŒ Outside sandbox
.env files โŒ Blocked by default
100GB file read โŒ Size limit (configurable)
Hidden directory listing โŒ Filtered by default

๐Ÿ“„ Resources

file://{path}

Read a file's raw content via MCP resource protocol.


๐Ÿ”Œ Connecting to Clients

Claude Desktop

{
  "mcpServers": {
    "filesystem": {
      "command": "python",
      "args": ["/ABSOLUTE/PATH/mcp-file-system-server/filesystem_server.py", "--sandbox", "/tmp/mcp-sandbox"]
    }
  }
}

Cursor

Settings โ†’ Features โ†’ MCP โ†’ Add Server:

  • Name: filesystem
  • Type: command
  • Command: python /ABSOLUTE/PATH/mcp-file-system-server/filesystem_server.py --sandbox /tmp/mcp-sandbox

๐Ÿ“ Project Structure

mcp-file-system-server/
โ”œโ”€โ”€ filesystem_server.py   # Main server (FastMCP + security)
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ setup.sh
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ .gitignore

๐Ÿงช Example Usage

# Read a file
read_file("/tmp/mcp-sandbox/data.txt")
# โ†’ "๐Ÿ“„ File: /tmp/mcp-sandbox/data.txt\nSize: 1,234 bytes\n..."

# Write a file
write_file("/tmp/mcp-sandbox/output/report.md", "# Report\n\nHello world!")
# โ†’ "โœ… Written 28 bytes to /tmp/mcp-sandbox/output/report.md"

# Search for Python files
search_files("**/*.py")
# โ†’ "๐Ÿ” 5 file(s) matching **/*.py:\n  ๐Ÿ“„ scripts/process.py (1,234 bytes)\n..."

๐Ÿ“œ License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured