<div align="center">
# Filesystem MCP π
**Secure filesystem operations for AI agents - Token-optimized with batch processing**
[](https://www.npmjs.com/package/@sylphlab/filesystem-mcp)
[](https://hub.docker.com/r/sylphlab/filesystem-mcp)
[](https://github.com/SylphxAI/filesystem-mcp/blob/main/LICENSE)
**Batch operations** β’ **Project root safety** β’ **Token optimized** β’ **Zod validation**
[Quick Start](#-quick-start) β’ [Installation](#-installation) β’ [Tools](#-features)
<a href="https://glama.ai/mcp/servers/@sylphlab/filesystem-mcp">
<img width="380" height="200" src="https://glama.ai/mcp/servers/@sylphlab/filesystem-mcp/badge" alt="Filesystem MCP Server" />
</a>
</div>
---
## π Overview
Empower your AI agents (like Claude/Cline) with secure, efficient, and token-saving access to your project files. This Node.js server implements the [Model Context Protocol (MCP)](https://docs.modelcontextprotocol.com/) to provide a robust set of filesystem tools.
**The Problem:**
```
Traditional AI filesystem access:
- Shell commands for each operation β
- No batch processing (high token cost) β
- Unsafe (no project root boundaries) β
- High latency (shell spawn overhead) β
```
**The Solution:**
```
Filesystem MCP Server:
- Batch operations (10+ files at once) β
- Token optimized (reduce round trips) β
- Secure (confined to project root) β
- Direct API (no shell overhead) β
```
**Result: Safe, fast, and token-efficient filesystem operations for AI agents.**
---
## β‘ Performance Advantages
### Token & Latency Optimization
| Metric | Individual Shell Commands | Filesystem MCP | Improvement |
|--------|---------------------------|----------------|-------------|
| **Operations/Request** | 1 file | 10+ files | **10x reduction** |
| **Round Trips** | N operations | 1 request | **NΓ fewer** |
| **Latency** | Shell spawn per op | Direct API | **5-10Γ faster** |
| **Token Usage** | High overhead | Batched context | **50-70% less** |
| **Error Reporting** | stderr parsing | Per-item status | Detailed |
### Real-World Benefits
- **Batch file reads** - Read 10 files in one request vs 10 requests
- **Multi-file edits** - Edit multiple files with single tool call
- **Recursive operations** - List entire directory trees efficiently
- **Detailed status** - Per-item success/failure reporting
---
## π― Why Choose This Server?
### Security & Safety
- **π‘οΈ Project Root Confinement** - All operations restricted to `cwd` at launch
- **π Permission Control** - Built-in chmod/chown tools
- **β
Validation** - Zod schemas validate all arguments
- **π« Path Traversal Prevention** - Cannot escape project directory
### Efficiency & Performance
- **β‘ Batch Processing** - Process multiple files/directories per request
- **π― Token Optimized** - Reduce AI-server communication overhead
- **π Direct API** - No shell process spawning
- **π Detailed Results** - Per-item status for batch operations
### Developer Experience
- **π§ Easy Setup** - `npx`/`bunx` for instant use
- **π³ Docker Ready** - Official Docker image available
- **π¦ Comprehensive Tools** - 11+ filesystem operations
- **π MCP Standard** - Full protocol compliance
---
## π¦ Installation
### Method 1: npx/bunx (Recommended)
The simplest way - always uses latest version from npm.
**Using npx:**
```json
{
"mcpServers": {
"filesystem-mcp": {
"command": "npx",
"args": ["@sylphlab/filesystem-mcp"],
"name": "Filesystem (npx)"
}
}
}
```
**Using bunx:**
```json
{
"mcpServers": {
"filesystem-mcp": {
"command": "bunx",
"args": ["@sylphlab/filesystem-mcp"],
"name": "Filesystem (bunx)"
}
}
}
```
**Important:** The server uses its own Current Working Directory (`cwd`) as the project root. Ensure your MCP host (e.g., Cline/VSCode) launches the command with `cwd` set to your project's root directory.
### Method 2: Docker
Use the official Docker image for containerized environments.
```json
{
"mcpServers": {
"filesystem-mcp": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-v",
"/path/to/your/project:/app",
"sylphlab/filesystem-mcp:latest"
],
"name": "Filesystem (Docker)"
}
}
}
```
**Remember to replace `/path/to/your/project` with your actual project path.**
### Method 3: Local Build (Development)
```bash
# Clone repository
git clone https://github.com/SylphxAI/filesystem-mcp.git
cd filesystem-mcp
# Install dependencies
pnpm install
# Build
pnpm run build
# Watch mode (auto-rebuild)
pnpm run dev
```
**MCP Host Configuration:**
```json
{
"mcpServers": {
"filesystem-mcp": {
"command": "node",
"args": ["/path/to/filesystem-mcp/dist/index.js"],
"name": "Filesystem (Local Build)"
}
}
}
```
---
## π Quick Start
Once configured in your MCP host (see Installation), your AI agent can immediately use the filesystem tools.
### Example Agent Interaction
```xml
<use_mcp_tool>
<server_name>filesystem-mcp</server_name>
<tool_name>read_content</tool_name>
<arguments>{"paths": ["src/index.ts", "package.json"]}</arguments>
</use_mcp_tool>
```
**Server Response:**
```json
{
"results": [
{
"path": "src/index.ts",
"content": "...",
"success": true
},
{
"path": "package.json",
"content": "...",
"success": true
}
]
}
```
---
## π Features
### File Operations
| Tool | Description | Batch Support |
|------|-------------|---------------|
| **read_content** | Read file contents | β
Multiple files |
| **write_content** | Write/append to files | β
Multiple files |
| **edit_file** | Surgical edits with diff output | β
Multiple files |
| **search_files** | Regex search with context | β
Multiple files |
| **replace_content** | Multi-file search & replace | β
Multiple files |
### Directory Operations
| Tool | Description | Batch Support |
|------|-------------|---------------|
| **list_files** | List files/directories recursively | Single path |
| **stat_items** | Get detailed file/directory status | β
Multiple items |
| **create_directories** | Create directories with parents | β
Multiple paths |
### Management Operations
| Tool | Description | Batch Support |
|------|-------------|---------------|
| **delete_items** | Remove files/directories | β
Multiple items |
| **move_items** | Move/rename files/directories | β
Multiple items |
| **copy_items** | Copy files/directories | β
Multiple items |
### Permission Operations
| Tool | Description | Batch Support |
|------|-------------|---------------|
| **chmod_items** | Change POSIX permissions | β
Multiple items |
| **chown_items** | Change ownership | β
Multiple items |
**Key Benefit:** Tools supporting batch operations process each item individually and return detailed per-item status reports.
---
## π‘ Design Philosophy
### Core Principles
1. **Security First**
- All operations confined to project root
- Path traversal prevention
- Permission controls built-in
2. **Efficiency Focused**
- Batch processing reduces token usage
- Direct API calls (no shell overhead)
- Minimal communication round trips
3. **Robustness**
- Per-item success/failure reporting
- Detailed error messages
- Zod schema validation
4. **Simplicity**
- Clear, consistent API
- MCP standard compliance
- Easy integration
---
## π Comparison with Alternatives
| Feature | Filesystem MCP | Shell Commands | Other Scripts |
|---------|----------------|----------------|---------------|
| **Security** | β
Root confined | β Full shell access | β οΈ Variable |
| **Token Efficiency** | β
Batching | β One op/command | β οΈ Variable |
| **Latency** | β
Direct API | β Shell spawn | β οΈ Variable |
| **Batch Operations** | β
Most tools | β No | β οΈ Maybe |
| **Error Reporting** | β
Per-item detail | β stderr parsing | β οΈ Variable |
| **Setup** | β
Easy (npx/Docker) | β οΈ Secure shell setup | β οΈ Custom |
| **MCP Standard** | β
Full compliance | β No | β οΈ Variable |
---
## π οΈ Tech Stack
| Component | Technology |
|-----------|------------|
| **Language** | TypeScript (strict mode) |
| **Runtime** | Node.js / Bun |
| **Protocol** | Model Context Protocol (MCP) |
| **Validation** | Zod schemas |
| **Package Manager** | pnpm |
| **Distribution** | npm + Docker Hub |
---
## π― Use Cases
### AI Agent Development
Enable AI agents to:
- **Read project files** - Access code, configs, docs
- **Edit multiple files** - Refactor across codebase
- **Search codebases** - Find patterns and definitions
- **Manage project structure** - Create, move, organize files
### Code Assistants
Build powerful coding tools:
- **Cline/Claude integration** - Direct filesystem access
- **Batch refactoring** - Edit multiple files at once
- **Safe operations** - Confined to project directory
- **Efficient operations** - Reduce token costs
### Automation & Scripting
Automate development tasks:
- **File generation** - Create boilerplate files
- **Project setup** - Initialize directory structures
- **Batch processing** - Handle multiple files efficiently
- **Content transformation** - Search and replace across files
---
## πΊοΈ Roadmap
**β
Completed**
- [x] Core filesystem operations (read, write, edit, etc.)
- [x] Batch processing for most tools
- [x] Project root security
- [x] Docker image
- [x] npm package
- [x] Zod validation
**π Planned**
- [ ] File watching capabilities
- [ ] Streaming support for large files
- [ ] Advanced filtering for `list_files`
- [ ] Performance benchmarks
- [ ] Compression/decompression tools
- [ ] Symlink management
---
## π€ Contributing
Contributions are welcome! Please follow these guidelines:
1. **Fork the repository**
2. **Create a feature branch** - `git checkout -b feature/my-feature`
3. **Write tests** - Ensure good coverage
4. **Follow TypeScript strict mode** - Type safety first
5. **Add documentation** - Update README if needed
6. **Submit a pull request**
### Development Setup
```bash
# Clone and install
git clone https://github.com/SylphxAI/filesystem-mcp.git
cd filesystem-mcp
pnpm install
# Build
pnpm run build
# Watch mode (auto-rebuild)
pnpm run dev
```
---
## π€ Support
[](https://www.npmjs.com/package/@sylphlab/filesystem-mcp)
[](https://github.com/SylphxAI/filesystem-mcp/issues)
- π [Bug Reports](https://github.com/SylphxAI/filesystem-mcp/issues)
- π¬ [Discussions](https://github.com/SylphxAI/filesystem-mcp/discussions)
- π§ [Email](mailto:hi@sylphx.com)
**Show Your Support:**
β Star β’ π Watch β’ π Report bugs β’ π‘ Suggest features β’ π Contribute
---
## π License
MIT Β© [Sylphx](https://sylphx.com)
---
## π Credits
Built with:
- [Model Context Protocol](https://docs.modelcontextprotocol.com/) - MCP standard
- [Zod](https://zod.dev) - Schema validation
- [TypeScript](https://typescriptlang.org) - Type safety
- [pnpm](https://pnpm.io) - Package manager
Special thanks to the MCP community β€οΈ
---
## π Publishing
This repository uses GitHub Actions to automatically publish to:
- **npm**: [@sylphlab/filesystem-mcp](https://www.npmjs.com/package/@sylphlab/filesystem-mcp)
- **Docker Hub**: [sylphlab/filesystem-mcp](https://hub.docker.com/r/sylphlab/filesystem-mcp)
Triggered on version tags (`v*.*.*`) pushed to `main` branch.
**Required secrets**: `NPM_TOKEN`, `DOCKERHUB_USERNAME`, `DOCKERHUB_TOKEN`
---
<p align="center">
<strong>Secure. Efficient. Token-optimized.</strong>
<br>
<sub>The filesystem MCP server that saves tokens and keeps your projects safe</sub>
<br><br>
<a href="https://sylphx.com">sylphx.com</a> β’
<a href="https://x.com/SylphxAI">@SylphxAI</a> β’
<a href="mailto:hi@sylphx.com">hi@sylphx.com</a>
</p>