The Filesystem MCP Server enables secure and efficient filesystem operations for AI agents within a defined root directory. Key capabilities include:
๐ Explore & Inspect: List files/directories (recursively with optional stats), get detailed status for multiple items
๐ Read & Write: Read from multiple files, write/append content with automatic directory creation
๐๏ธ Manage Files/Directories: Create directories with intermediate paths, delete multiple files/directories
โ๏ธ Move & Copy: Move/rename or copy multiple files/directories
๐ Control Permissions: Change POSIX permissions (chmod) and ownership (chown) for multiple items
๐ Search & Replace: Search using regex with glob filtering, replace content across multiple files
Filesystem MCP Server (@sylphlab/filesystem-mcp)
Empower your AI agents (like Cline/Claude) with secure, efficient, and token-saving access to your project files. This Node.js server implements the Model Context Protocol (MCP) to provide a robust set of filesystem tools, operating safely within a defined project root directory.
Installation
There are several ways to use the Filesystem MCP Server:
1. Recommended:
The simplest way is via npx or bunx, configured directly in your MCP host environment (e.g., Roo/Cline's mcp_settings.json). This ensures you always use the latest version from npm without needing local installation or Docker.
Example (
Example (
Important: The server uses its own Current Working Directory (cwd) as the project root. Ensure your MCP Host (e.g., Cline/VSCode) is configured to launch the command with the cwd set to your active project's root directory.
2. Docker
Use the official Docker image for containerized environments.
Example MCP Host Configuration:
Remember to replace
3. Local Build (For Development)
Clone:
git clone https://github.com/sylphlab/filesystem-mcp.gitInstall:
cd filesystem-mcp && pnpm install(Using pnpm now)Build:
pnpm run buildConfigure MCP Host:
{ "mcpServers": { "filesystem-mcp": { "command": "node", "args": ["/path/to/cloned/repo/filesystem-mcp/dist/index.js"], // Updated build dir "name": "Filesystem (Local Build)" } } }Note: Launch the
nodecommand from the directory you intend as the project root.
Related MCP server: drupal-modules-mcp MCP Server
Quick Start
Once the server is configured in your MCP host (see Installation), your AI agent can immediately start using the filesystem tools.
Example Agent Interaction (Conceptual):
Why Choose This Project?
๐ก๏ธ Secure & Convenient Project Root Focus: Operations confined to the project root (
cwdat launch).โก Optimized & Consolidated Tools: Batch operations reduce AI-server round trips, saving tokens and latency. Reliable results for each item in a batch.
๐ Easy Integration: Quick setup via
npx/bunx.๐ณ Containerized Option: Available as a Docker image.
๐ง Comprehensive Functionality: Covers a wide range of filesystem tasks.
โ Robust Validation: Uses Zod schemas for argument validation.
Performance Advantages
(Placeholder: Add benchmark results and comparisons here, demonstrating advantages over alternative methods like individual shell commands.)
Batch Operations: Significantly reduces overhead compared to single operations.
Direct API Usage: More efficient than spawning shell processes for each command.
(Add specific benchmark data when available)
Features
This server equips your AI agent with a powerful and efficient filesystem toolkit:
๐ Explore & Inspect ( List files/directories (recursive, stats), get detailed status for multiple items.
๐ Read & Write Content ( Read/write/append multiple files, creates parent directories.
โ๏ธ Precision Editing & Searching ( Surgical edits (insert, replace, delete) across multiple files with indentation preservation and diff output; regex search with context; multi-file search/replace.
๐๏ธ Manage Directories ( Create multiple directories including intermediate parents.
๐๏ธ Delete Safely ( Remove multiple files/directories recursively.
โ๏ธ Move & Copy ( Move/rename/copy multiple files/directories.
๐ Control Permissions ( Change POSIX permissions and ownership for multiple items.
Key Benefit: All tools accepting multiple paths/operations process each item individually and return a detailed status report.
Design Philosophy
(Placeholder: Explain the core design principles.)
Security First: Prioritize preventing access outside the project root.
Efficiency: Minimize communication overhead and token usage for AI interactions.
Robustness: Provide detailed results and error reporting for batch operations.
Simplicity: Offer a clear and consistent API via MCP.
Standard Compliance: Adhere strictly to the Model Context Protocol.
Comparison with Other Solutions
(Placeholder: Objectively compare with alternatives.)
Feature/Aspect | Filesystem MCP Server | Individual Shell Commands (via Agent) | Other Custom Scripts |
Security | High (Root Confined) | Low (Agent needs shell access) | Variable |
Efficiency (Tokens) | High (Batching) | Low (One command per op) | Variable |
Latency | Low (Direct API) | High (Shell spawn overhead) | Variable |
Batch Operations | Yes (Most tools) | No | Maybe |
Error Reporting | Detailed (Per item) | Basic (stdout/stderr parsing) | Variable |
Setup | Easy (npx/Docker) | Requires secure shell setup | Custom |
Future Plans
(Placeholder: List upcoming features or improvements.)
Explore file watching capabilities.
Investigate streaming support for very large files.
Enhance performance for specific operations.
Add more advanced filtering options for
list_files.
Documentation
(Placeholder: Add link to the full documentation website once available.)
Full documentation, including detailed API references and examples, will be available at: [Link to Docs Site]
Contributing
Contributions are welcome! Please open an issue or submit a pull request on the GitHub repository.
License
This project is released under the MIT License.
Development
Clone:
git clone https://github.com/sylphlab/filesystem-mcp.gitInstall:
cd filesystem-mcp && pnpm installBuild:
pnpm run build(compiles TypeScript todist/)Watch:
pnpm run dev(optional, recompiles on save)
Publishing (via GitHub Actions)
This repository uses GitHub Actions (.github/workflows/publish.yml) to automatically publish the package to npm and build/push a Docker image to Docker Hub on pushes of version tags (v*.*.*) to the main branch. Requires NPM_TOKEN, DOCKERHUB_USERNAME, and DOCKERHUB_TOKEN secrets configured in the GitHub repository settings.