The File Operations MCP Server enables advanced file and directory management with streaming, patching, and change tracking support.
- File Management: Copy, read, write, move, append, and delete files with options for overwriting and encoding
- Directory Management: Create, remove, list, and copy directories with recursive capabilities
- Change Monitoring: Watch directories for changes, unwatch directories, check watching status
- Change Tracking: Retrieve and clear recorded file system changes with filtering options
- Resource Access: Access file contents via
file://{path}
, metadata viametadata://{path}
, directory listings viadirectory://{path}
, and recent changes viafile:///recent-changes
- Progress Reporting: Track progress of long operations like directory copying
- Security: Path validation, input sanitization, and rate limiting for safe operations
File Operations MCP Server
A Model Context Protocol (MCP) server that provides enhanced file operation capabilities with streaming, patching, and change tracking support.
Features
- Basic File Operations: Copy, read, write, move, and delete files
- Directory Operations: Create, remove, and copy directories
- File Watching: Monitor files and directories for changes
- Change Tracking: Track and query file operation history
- Streaming Support: Handle large files efficiently with streaming
- HTTP Interface: Streamable HTTP interface with Server-Sent Events (SSE)
- Resource Support: Access files and directories through MCP resources
- Progress Reporting: Real-time progress updates for long operations
- Rate Limiting: Protection against excessive requests
- Enhanced Security: Path validation and input sanitization
- Robust Error Handling: Comprehensive error handling and reporting
- Type Safety: Full TypeScript support with strict type checking
- Docker Support: Containerized deployment with volume mounting
Installation
Installing via Smithery
To install File Operations Server for Claude Desktop automatically via Smithery:
Manual Installation
Docker Installation
See DOCKER.md for comprehensive Docker setup instructions including local drive mounting for Windows and Linux.
Quick Docker Start:
Usage
Transport Modes
The server supports two transport modes:
1. Stdio Transport (Default)
For direct integration with MCP clients like Claude Desktop:
2. HTTP Transport with SSE (New in v1.5)
For remote connections and web applications:
The HTTP server provides:
- SSE Endpoint:
GET http://localhost:3001/sse
- Establishes streaming connection - Messages Endpoint:
POST http://localhost:3001/messages
- Receives client messages - Health Check:
GET http://localhost:3001/health
- Server status - Sessions:
GET http://localhost:3001/sessions
- Active connection info
Starting the Server
Development Mode
Production Mode
Available Tools
Basic File Operations
copy_file
: Copy a file to a new locationread_file
: Read content from a filewrite_file
: Write content to a filemove_file
: Move/rename a filedelete_file
: Delete a fileappend_file
: Append content to a file
Directory Operations
make_directory
: Create a directoryremove_directory
: Remove a directorycopy_directory
: Copy a directory recursively (with progress reporting)
Watch Operations
watch_directory
: Start watching a directory for changesunwatch_directory
: Stop watching a directory
Change Tracking
get_changes
: Get the list of recorded changesclear_changes
: Clear all recorded changes
Available Resources
Static Resources
file:///recent-changes
: List of recent file system changes
Resource Templates
file://{path}
: Access file contentsmetadata://{path}
: Access file metadatadirectory://{path}
: List directory contents
Example Usage
Using Stdio Transport (MCP Clients)
Using HTTP Transport (Web/Remote)
Connecting via JavaScript:
Using curl for testing:
Interactive Web Client:
A complete interactive example is available at examples/http-client.html
. Open this file in a web browser to test the HTTP interface with a user-friendly GUI.
What's New in v1.5
MCP SDK v1.5 Upgrade
- Streamable HTTP Interface: New HTTP transport with Server-Sent Events (SSE)
- Enhanced API: Upgraded to MCP SDK v1.5 with improved zod-based schemas
- Multiple Connections: Support for simultaneous HTTP connections with session management
- Better Type Safety: Improved TypeScript integration and error handling
Streaming Features
- Large File Support: Efficient streaming for large file operations
- Real-time Progress: Progress updates via SSE for long-running operations
- Session Management: Multiple client connections with isolated sessions
- HTTP API: RESTful endpoints alongside traditional MCP protocol
Docker Support
Quick Start with Docker
Volume Mounting
Windows:
Linux/macOS:
For comprehensive Docker setup instructions including local drive mounting for Windows and Linux, see DOCKER.md.
Rate Limits
The server implements rate limiting to prevent abuse:
- Tools: 100 requests per minute
- Resources: 200 requests per minute
- Watch Operations: 20 operations per minute
Rate limit errors include a retry-after period in the error message.
Security Features
Path Validation
All file paths are validated to prevent directory traversal attacks:
- No parent directory references (
../
) - Proper path normalization
- Input sanitization
Resource Protection
- Rate limiting on all operations
- Proper error handling and logging
- Input validation on all parameters
- Safe resource cleanup
Progress Reporting
Long-running operations like directory copying provide progress updates:
Progress can be tracked through the progress token returned in the operation result.
Development
Building
Linting
Formatting
Testing
Configuration
Environment Variables
Variable | Default | Description |
---|---|---|
MCP_TRANSPORT | stdio | Transport mode: stdio or http |
MCP_HTTP_PORT | 3001 | Port for HTTP transport |
Transport Selection
- Stdio: Best for MCP clients like Claude Desktop, direct integration
- HTTP: Best for web applications, remote access, development/testing
The server can be configured through various settings:
- Rate Limiting: Configure request limits and windows
- Progress Reporting: Control update frequency and detail level
- Resource Access: Configure resource permissions and limits
- Security Settings: Configure path validation rules
- Change Tracking: Set retention periods and storage options
- Watch Settings: Configure debounce times and recursive watching
Error Handling
The server provides detailed error information through the FileOperationError
class and MCP error codes:
Standard MCP Error Codes
InvalidRequest
: Invalid parameters or request formatMethodNotFound
: Unknown tool or resource requestedInvalidParams
: Invalid parameters (e.g., path validation failure)InternalError
: Server-side errors
Custom Error Types
- File operation failures
- Rate limit exceeded
- Path validation errors
- Resource access errors
Each error includes:
- Specific error code
- Detailed error message
- Relevant metadata (file paths, limits, etc.)
- Stack traces in development mode
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Tools
A Model Context Protocol server that enables enhanced file system operations including reading, writing, copying, moving files with streaming capabilities, directory management, file watching, and change tracking.
- Features
- Installation
- Usage
- Rate Limits
- Security Features
- Progress Reporting
- Development
- Configuration
- Error Handling
- Contributing
- License
Related Resources
Related MCP Servers
- -securityAlicense-qualityA Model Context Protocol server that provides file system operations, analysis, and manipulation capabilities through a standardized tool interface.Last updated -4TypeScriptMIT License
- AsecurityAlicenseAqualityA 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.Last updated -2145PythonMIT License
- AsecurityAlicenseAqualityA server implementing the Model Context Protocol that provides filesystem operations (read/write, directory management, file movement) through a standardized interface with security controls for allowed directories.Last updated -93TypeScriptMIT License
- -securityAlicense-qualityA Model Context Protocol server that provides intelligent file reading and semantic search capabilities across multiple document formats with security-first access controls.Last updated -5PythonMIT License