Cover image
Try Now
2025-04-07

A secure Model Context Protocol (MCP) server providing filesystem access within predefined directories

3 years

Works with Finder

1

Github Watches

0

Github Forks

6

Github Stars


MCP Filesystem
Secure MCP Filesystem Server

A secure Model Context Protocol (MCP) server providing filesystem access within predefined directories

License GitHub top language GitHub language count Repository size GitHub last commit Maia


About   |    Technologies   |    Tools   |    Installation   |    Usage   |    License


:bookmark: About

MCP Filesystem Server provides secure filesystem access for AI models through the Model Context Protocol. It enforces strict path validation and only allows access to predefined directories.


:computer: Technologies


:wrench: Tools


:package: Installation

:heavy_check_mark: Prerequisites

The following software must be installed:


:arrow_down: Cloning the repository

  $ git clone https://github.com/gabrielmaialva33/mcp-filesystem.git
  $ cd mcp-filesystem

:arrow_forward: Running the application

Local Development

  # Install dependencies
  $ pnpm install

  # Build the application
  $ pnpm build

  # Run the server (specify directory to allow access to)
  $ pnpm start /path/to/allowed/directory

  # Or use configuration file
  $ pnpm start --config=config.json

Using NPM Package

  # Install globally
  $ npm install -g @gabrielmaialva33/mcp-filesystem

  # Run the server
  $ mcp-filesystem /path/to/allowed/directory

  # Or use with npx (no installation needed)
  $ npx @gabrielmaialva33/mcp-filesystem /path/to/allowed/directory

  # Create a sample configuration file
  $ npx @gabrielmaialva33/mcp-filesystem --create-config=config.json

Using Docker

  # Build the Docker image
  $ docker build -t gabrielmaialva33/mcp-filesystem .

  # Run using Docker
  $ docker run -i --rm -v /path/to/data:/data:ro gabrielmaialva33/mcp-filesystem /data

  # Use with config file
  $ docker run -i --rm -v /path/to/config.json:/app/config.json -v /path/to/data:/data gabrielmaialva33/mcp-filesystem --config=/app/config.json

Using Docker Compose

  # Create a data directory
  $ mkdir -p data

  # Start the server
  $ docker-compose up -d

:gear: Usage

Using with Claude Desktop

Claude Desktop can be configured to use this MCP server for filesystem access. Add the following to your claude_desktop_config.json:

Using Local Installation (Recommended)

{
  "mcpServers": {
    "filesystem": {
      "command": "mcp-filesystem",
      "args": [
        "/Users/gabrielmaia/Documents",
        "/Users/gabrielmaia/Desktop",
        "/Users/gabrielmaia/Downloads"
      ]
    }
  }
}

Make sure to make the executable available globally:

# Make the binary executable
chmod +x /Users/gabrielmaia/.nvm/versions/node/v22.14.0/bin/mcp-filesystem

Using NPX

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@gabrielmaialva33/mcp-filesystem",
        "/Users/username/Desktop",
        "/path/to/other/allowed/dir"
      ]
    }
  }
}

Using Docker

Note: When using Docker, all directories must be mounted to /projects by default. Adding the ro flag will make the directory read-only.

{
  "mcpServers": {
    "filesystem": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "--mount",
        "type=bind,src=/Users/username/Desktop,dst=/projects/Desktop",
        "--mount",
        "type=bind,src=/path/to/other/allowed/dir,dst=/projects/other/allowed/dir,ro",
        "--mount",
        "type=bind,src=/path/to/file.txt,dst=/projects/path/to/file.txt",
        "gabrielmaialva33/mcp-filesystem",
        "/projects"
      ]
    }
  }
}

Available Tools

The MCP Filesystem Server provides these tools:

File System Operations

  • read_file: Read a file's content
  • read_multiple_files: Read multiple files at once
  • write_file: Create or overwrite a file
  • edit_file: Make precise edits with diff preview
  • create_directory: Create directories recursively
  • list_directory: List directory contents
  • directory_tree: Get a recursive tree view
  • move_file: Move or rename files
  • search_files: Find files matching patterns
  • get_file_info: Get file metadata
  • list_allowed_directories: See accessible directories

System & Network Operations

  • get_metrics: View server performance metrics (v0.3.0+)
  • execute_command: Execute system commands securely (v0.3.1+)
  • curl_request: Execute HTTP requests to external APIs (coming in v1.2.0)

Using curl_request Tool (Coming in v1.2.0)

The curl_request tool will allow you to make HTTP requests to external APIs:

// Example: Making a GET request with authentication
curl_request({
  url: 'https://api.example.com/data',
  method: 'GET',
  headers: {
    Authorization: 'Bearer your_token_here',
  },
})

// Example: POST request with JSON data
curl_request({
  url: 'https://api.example.com/create',
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  data: '{"name":"Example","value":123}',
})

See the docs/curl-tool-examples.md file for more detailed examples.


:sparkles: Features

Core Features

  • Secure Access: Strict path validation prevents unauthorized access
  • File Operations: Read, write, edit, and move files
  • Directory Operations: Create, list, get tree views, and search directories
  • Metadata Access: View file and directory information
  • Command Execution: Securely execute system commands with strict validation
  • Docker Support: Easy deployment with Docker and Docker Compose

New Features in v0.3.0

  • Structured Logging: Detailed logging with different levels (debug, info, warn, error)
  • Performance Metrics: Track operation counts, errors, and execution times
  • Configuration Management: Support for JSON configuration files
  • Path Caching: Improved performance for frequently accessed paths
  • Improved Error Handling: Specialized error types with structured information
  • File Size Validation: Prevent loading excessively large files
  • CLI Improvements: Help command, version info, and config generation

Configuration Options

You can create a configuration file using:

$ mcp-filesystem --create-config=config.json

Example configuration:

{
  "allowedDirectories": ["/path/to/allowed/dir1", "/path/to/allowed/dir2"],
  "logLevel": "info",
  "logFile": "/path/to/logs/mcp-filesystem.log",
  "serverName": "secure-filesystem-server",
  "serverVersion": "0.3.0",
  "cache": {
    "enabled": true,
    "maxSize": 1000,
    "ttlMs": 60000
  },
  "metrics": {
    "enabled": true,
    "reportIntervalMs": 60000
  },
  "security": {
    "maxFileSize": 10485760,
    "allowSymlinks": true,
    "validateRealPath": true
  }
}

:writing_hand: Author

Gabriel Maia
Gabriel Maia

License

MIT License

© 2024-present Maia

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

  • https://reddgr.com
  • Delivers concise Python code and interprets non-English comments

  • 林乔安妮
  • A fashion stylist GPT offering outfit suggestions for various scenarios.

  • 田中 楓太
  • A virtual science instructor for engaging and informative lessons.

  • ShrimpingIt
  • Micropython I2C-based manipulation of the MCP series GPIO expander, derived from Adafruit_MCP230xx

  • apappascs
  • Discover the most comprehensive and up-to-date collection of MCP servers in the market. This repository serves as a centralized hub, offering an extensive catalog of open-source and proprietary MCP servers, complete with features, documentation links, and contributors.

  • GeyserMC
  • A library for communication with a Minecraft client/server.

  • awslabs
  • AWS MCP Servers — specialized MCP servers that bring AWS best practices directly to your development workflow

  • Mintplex-Labs
  • The all-in-one Desktop & Docker AI application with built-in RAG, AI agents, No-code agent builder, MCP compatibility, and more.

  • 1Panel-dev
  • 💬 MaxKB is an open-source AI assistant for enterprise. It seamlessly integrates RAG pipelines, supports robust workflows, and provides MCP tool-use capabilities.

  • modelcontextprotocol
  • Model Context Protocol Servers

    Reviews

    4 (1)
    Avatar
    user_qcM2vhRI
    2025-04-16

    As a loyal user of mcp-filesystem, I am thoroughly impressed by its seamless performance and user-friendly interface. This open-source project by gabrielmaialva33 is an excellent tool for managing file systems efficiently. It handles complex file operations effortlessly, making it a go-to solution for developers. Highly recommended!