MCP Filesystem Server

MCP Filesystem Server

Provides secure filesystem access for AI models through the Model Context Protocol with strict path validation, file operations, directory management, and system command execution within predefined directories.

Category
访问服务器

README

<h1 align="center"> <br> <img src="https://raw.githubusercontent.com/gabrielmaialva33/mcp-filesystem/master/.github/assets/mcp.png" alt="MCP Filesystem" width="200"> <br> Secure <a href="https://modelcontextprotocol.io/introduction">MCP</a> Filesystem Server <br> </h1>

<p align="center"> <strong>A secure Model Context Protocol (MCP) server providing filesystem access within predefined directories</strong> </p>

<p align="center"> <img src="https://img.shields.io/github/license/gabrielmaialva33/mcp-filesystem?color=00b8d3?style=flat&logo=appveyor" alt="License" /> <img src="https://img.shields.io/github/languages/top/gabrielmaialva33/mcp-filesystem?style=flat&logo=appveyor" alt="GitHub top language" > <img src="https://img.shields.io/github/languages/count/gabrielmaialva33/mcp-filesystem?style=flat&logo=appveyor" alt="GitHub language count" > <img src="https://img.shields.io/github/repo-size/gabrielmaialva33/mcp-filesystem?style=flat&logo=appveyor" alt="Repository size" > <a href="https://github.com/gabrielmaialva33/mcp-filesystem/commits/master"> <img src="https://img.shields.io/github/last-commit/gabrielmaialva33/mcp-filesystem?style=flat&logo=appveyor" alt="GitHub last commit" > <img src="https://img.shields.io/badge/made%20by-Maia-15c3d6?style=flat&logo=appveyor" alt="Maia" >
</a> </p>

<br>

<p align="center"> <a href="#bookmark-about">About</a>   |    <a href="#computer-technologies">Technologies</a>   |    <a href="#wrench-tools">Tools</a>   |    <a href="#package-installation">Installation</a>   |    <a href="#gear-usage">Usage</a>   |    <a href="#memo-license">License</a> </p>

<br>

: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.

<br>

:computer: Technologies

<br>

:wrench: Tools

<br>

:package: Installation

:heavy_check_mark: Prerequisites

The following software must be installed:

<br>

:arrow_down: Cloning the repository

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

<br>

: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

<br>

: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.

<br>

: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
  }
}

<br>

:writing_hand: Author

Gabriel Maia
Gabriel Maia

License

MIT License

<p align="center"><img src="https://raw.githubusercontent.com/gabrielmaialva33/gabrielmaialva33/master/assets/gray0_ctp_on_line.svg?sanitize=true" /></p> <p align="center">© 2024-present <a href="https://github.com/gabrielmaialva33/" target="_blank">Maia</a> </p>

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选