npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

filesystem-mcp-server

v2.0.0

Published

A comprehensive, secure, cross-platform MCP server for advanced file system operations

Downloads

15

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-server

Quick 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

  1. read_file

    • Description: Read the contents of a file
    • Parameters:
      • filePath (string): Path to the file to read
      • encoding (optional): Text encoding (utf8, ascii, base64, hex, binary, utf16le)
  2. write_file

    • Description: Write content to a file
    • Parameters:
      • filePath (string): Path to the file to write
      • content (string): Content to write
      • encoding (optional): Text encoding
      • createDirectories (optional boolean): Create parent directories if needed
  3. delete_file

    • Description: Delete a file
    • Parameters:
      • filePath (string): Path to the file to delete
  4. copy_file

    • Description: Copy a file from source to destination
    • Parameters:
      • sourcePath (string): Source file path
      • destinationPath (string): Destination file path
      • overwrite (optional boolean): Whether to overwrite existing files
  5. move_file

    • Description: Move or rename a file
    • Parameters:
      • sourcePath (string): Source file path
      • destinationPath (string): Destination file path
  6. get_file_info

    • Description: Get detailed information about a file or directory
    • Parameters:
      • path (string): Path to the file or directory
  7. file_exists

    • Description: Check if a file or directory exists
    • Parameters:
      • path (string): Path to check

Directory Operations

  1. list_directory

    • Description: List the contents of a directory
    • Parameters:
      • dirPath (string): Path to the directory
      • includeHidden (optional boolean): Include hidden files
  2. create_directory

    • Description: Create a new directory
    • Parameters:
      • dirPath (string): Path to create
      • recursive (optional boolean): Create parent directories
  3. delete_directory

    • Description: Delete a directory
    • Parameters:
      • dirPath (string): Path to delete
      • recursive (optional boolean): Delete recursively

Available Resources

File Resources

Access file contents using file:// URIs:

file:///path/to/your/file.txt

Directory Resources

Access directory listings using directory:// URIs:

directory:///path/to/your/directory

Security 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 utilities

Building

npm run build

Development Mode

npm run dev

Cleaning Build Files

npm run clean

Examples

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

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

Support

For issues and questions, please create an issue in the repository.