LocalFS MCP Server
Provides sandboxed access to local filesystem operations including directory and file management, content search with glob and regex patterns, and binary file support with configurable safety limits.
README
LocalFS MCP Server
A comprehensive filesystem management MCP (Model Context Protocol) server that provides sandboxed access to local filesystem operations. Built with Smithery CLI.
Features
16 Filesystem Tools
Directory Operations (5 tools)
list_directories- List subdirectories in a pathcreate_directory- Create new directories (with parent creation)delete_directory- Delete directories (recursive option)move_directory- Move or rename directoriesget_directory_metadata- Get directory statistics and info
File Operations (6 tools)
list_files- List files in a directoryread_file- Read file content with chunking supportwrite_file- Write or overwrite files (text and binary)append_file- Append content to existing filesdelete_file- Delete filesmove_file- Move or rename filesget_file_metadata- Get file stats (size, mime type, timestamps)
Search Operations (5 tools)
search_by_name- Exact filename matchsearch_by_glob- Glob pattern matching (.txt, **/.py)search_by_filename_regex- Regex pattern on filenamessearch_by_content_text- Plain text search in file contentsearch_by_content_regex- Regex search in file content
Binary File Support
- Automatic detection of binary vs text files
- Base64 encoding for binary content
- UTF-8 text handling with error recovery
Performance & Safety
- Chunked file reads for large files (offset/limit support)
- Configurable file size limits
- Configurable search depth limits
- Lazy directory traversal with generators
Prerequisites
- Python >= 3.10
- Smithery API key: Get yours at smithery.ai/account/api-keys
Getting Started
-
Install dependencies:
uv sync -
Run the development server:
uv run dev -
Test interactively with the playground:
uv run playground
Configuration
Each session requires a root_directory parameter and supports optional configuration:
root_directory: str # Required - sandbox root path
max_file_size_mb: int = 100 # Optional - max file size for operations
max_search_depth: int = 10 # Optional - max recursion depth for searches
Example Connection URL
http://localhost:8081/mcp?root_directory=/path/to/sandbox&max_file_size_mb=100
Usage Examples
Read a file
# Small file - read all at once
read_file(path="documents/readme.txt")
# Large file - read in chunks
read_file(path="large_file.bin", offset=0, limit=1048576) # First 1MB
Search for files
# Find all Python files
search_by_glob(pattern="**/*.py", recursive=true)
# Find files containing "TODO"
search_by_content_text(query="TODO", path="src", recursive=true)
Directory operations
# Create nested directories
create_directory(path="projects/new_project", create_parents=true)
# List directory contents
list_files(path="projects")
Development
Project Structure
Your server code is organized in src/local_filesystem/:
server.py- Main server setupcore/- Core utilities and exceptionssafety.py- Path validation and sandboxingexceptions.py- Custom exception classesconstants.py- Configuration constants
api/- API route handlersdirectory_routes.py- Directory operation endpointsfile_routes.py- File operation endpointssearch_routes.py- Search operation endpoints
services/- Business logic servicesdirectory_service.py- Directory managementfile_service.py- File managementsearch_service.py- Search capabilities
schemas/- Pydantic models and validation
Code Quality Tools
The project uses pre-commit hooks to maintain code quality:
- Black - Code formatting (line length: 100)
- Flake8 - Linting and style checking
- Mypy - Static type checking
Setup Pre-commit Hooks
# Install dependencies (includes pre-commit tools)
uv sync
# Install pre-commit hooks
uv run pre-commit install
# Run manually on all files
uv run pre-commit run --all-files
The hooks will automatically run on git commit to ensure code quality.
Security Features
- Sandboxed Operations: All paths validated against root directory
- Size Limits: Configurable limits prevent resource exhaustion
- Depth Limits: Recursive operations bounded by max_search_depth
- Path Traversal Protection: Prevents access outside sandbox root
Testing
Run the test suite:
# Run all tests
uv run pytest
# Run with coverage
uv run pytest --cov=src/local_filesystem
# Run specific test file
uv run pytest tests/integration/test_file_routes.py
Deploy
Ready to deploy? Push your code to GitHub and deploy to Smithery:
-
Create a new repository at github.com/new
-
Initialize git and push to GitHub:
git add . git commit -m "LocalFS MCP server" git remote add origin https://github.com/YOUR_USERNAME/YOUR_REPO.git git push -u origin main -
Deploy your server to Smithery at smithery.ai/new
Resources
- Documentation: smithery.ai/docs
- MCP Protocol: modelcontextprotocol.io
- Community: Discord
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。