Package Exports
- filesystem-mcp-server
- filesystem-mcp-server/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (filesystem-mcp-server) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Filesystem MCP Server
A comprehensive, secure, cross-platform MCP (Model Context Protocol) server for advanced file system operations with enterprise-grade security features.
Features
🔒 Security & Access Control
- Path Validation: Prevents directory traversal attacks
- Sandboxing: Configurable path restrictions
- Rate Limiting: Prevents abuse with configurable limits
- Audit Logging: Comprehensive operation tracking
- Permission Validation: File system permission checks
📁 File Operations
- Basic Operations: Read, write, delete, copy, move files
- Directory Operations: Create, list, delete directories
- Batch Operations: Efficient bulk file operations
- File Information: Detailed metadata and statistics
- Search: Advanced file search with filters
🗜️ Compression & Archives
- ZIP Support: Create and extract ZIP archives
- GZIP Support: Single file compression
- Archive Listing: View archive contents
- Nested Archives: Handle complex archive structures
👁️ File Watching
- Real-time Monitoring: Watch files and directories for changes
- Event Filtering: Configurable event types
- Cross-platform: Works on Windows, macOS, and Linux
🌐 Cross-Platform Compatibility
- Windows: Full support including long paths
- macOS: Native file system features
- Linux: POSIX compliance
- Path Handling: Automatic path normalization
Installation
npm install filesystem-mcp-serverQuick Start
Basic Usage
import { FileSystemMCPServer } from 'filesystem-mcp-server';
const server = new FileSystemMCPServer({
allowedPaths: ['/safe/directory'],
restrictedPaths: ['/system', '/etc'],
rateLimit: {
enabled: true,
maxRequests: 100,
windowMs: 60000
}
});
await server.start();Available Tools
File Operations
read_file
- Description: Read the contents of a file
- Parameters:
filePath(string): Path to the file to readencoding(optional): Text encoding (utf8, ascii, base64, hex, binary, utf16le)
write_file
- Description: Write content to a file
- Parameters:
filePath(string): Path to the file to writecontent(string): Content to writeencoding(optional): Text encodingcreateDirectories(optional boolean): Create parent directories if needed
delete_file
- Description: Delete a file
- Parameters:
filePath(string): Path to the file to delete
copy_file
- Description: Copy a file from source to destination
- Parameters:
sourcePath(string): Source file pathdestinationPath(string): Destination file pathoverwrite(optional boolean): Whether to overwrite existing files
move_file
- Description: Move or rename a file
- Parameters:
sourcePath(string): Source file pathdestinationPath(string): Destination file path
get_file_info
- Description: Get detailed information about a file or directory
- Parameters:
path(string): Path to the file or directory
file_exists
- Description: Check if a file or directory exists
- Parameters:
path(string): Path to check
Directory Operations
list_directory
- Description: List the contents of a directory
- Parameters:
dirPath(string): Path to the directoryincludeHidden(optional boolean): Include hidden files
create_directory
- Description: Create a new directory
- Parameters:
dirPath(string): Path to createrecursive(optional boolean): Create parent directories
delete_directory
- Description: Delete a directory
- Parameters:
dirPath(string): Path to deleterecursive(optional boolean): Delete recursively
Available Resources
File Resources
Access file contents using file:// URIs:
file:///path/to/your/file.txtDirectory Resources
Access directory listings using directory:// URIs:
directory:///path/to/your/directorySecurity Features
- Path Validation: All paths are validated and normalized to prevent directory traversal attacks
- Permission Checking: File and directory permissions are checked before operations
- Error Handling: Comprehensive error handling with descriptive messages
- Cross-Platform Support: Works on both Windows and Linux with proper path handling
Configuration
The server runs with stdio transport by default. For custom configurations or different transports, modify the src/index.ts file.
Development
Project Structure
src/
├── index.ts # Main server entry point
├── tools/
│ └── fileSystemTools.ts # File system tool implementations
├── resources/
│ └── fileSystemResources.ts # File system resource implementations
└── utils/
├── fileOperations.ts # Core file system operations
└── pathUtils.ts # Path validation and utilitiesBuilding
npm run buildDevelopment Mode
npm run devCleaning Build Files
npm run cleanExamples
Reading a File
{
"name": "read_file",
"arguments": {
"filePath": "/path/to/file.txt",
"encoding": "utf8"
}
}Writing a File
{
"name": "write_file",
"arguments": {
"filePath": "/path/to/new-file.txt",
"content": "Hello, World!",
"createDirectories": true
}
}Listing a Directory
{
"name": "list_directory",
"arguments": {
"dirPath": "/path/to/directory",
"includeHidden": false
}
}Error Handling
All operations include comprehensive error handling:
- Invalid paths are rejected with descriptive error messages
- Permission errors are clearly reported
- File not found errors include the attempted path
- Directory traversal attempts are blocked
License
MIT License - see LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Support
For issues and questions, please create an issue in the repository.