Skip to main content
Glama

MCP Filesystem Server

MIT License
40
7
  • Linux
  • Apple

:书签:关于

MCP 文件系统服务器通过模型上下文协议 (MCP Protocol) 为 AI 模型提供安全的文件系统访问。它强制执行严格的路径验证,并且仅允许访问预定义的目录。

:计算机:技术

扳手工具

:package: 安装

:heavy_check_mark:先决条件

必须安装以下软件:

:arrow_down:克隆存储库

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

:arrow_forward:运行应用程序

本地开发
# 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
使用 NPM 包
# 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
使用 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
使用 Docker Compose
# Create a data directory $ mkdir -p data # Start the server $ docker-compose up -d

:gear: 用法

与 Claude Desktop 一起使用

可以将 Claude Desktop 配置为使用此 MCP 服务器进行文件系统访问。将以下内容添加到claude_desktop_config.json文件中:

使用本地安装(推荐)
{ "mcpServers": { "filesystem": { "command": "mcp-filesystem", "args": [ "/Users/gabrielmaia/Documents", "/Users/gabrielmaia/Desktop", "/Users/gabrielmaia/Downloads" ] } } }

确保可执行文件在全球范围内可用:

# Make the binary executable chmod +x /Users/gabrielmaia/.nvm/versions/node/v22.14.0/bin/mcp-filesystem
使用 NPX
{ "mcpServers": { "filesystem": { "command": "npx", "args": [ "-y", "@gabrielmaialva33/mcp-filesystem", "/Users/username/Desktop", "/path/to/other/allowed/dir" ] } } }
使用 Docker

注意:使用 Docker 时,所有目录必须默认挂载到/projects 。添加ro标志将使目录变为只读。

{ "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" ] } } }

可用工具

MCP 文件系统服务器提供以下工具:

文件系统操作
  • read_file :读取文件的内容
  • read_multiple_files :一次读取多个文件
  • write_file :创建或覆盖文件
  • edit_file :使用 diff 预览进行精确编辑
  • create_directory :递归创建目录
  • list_directory :列出目录内容
  • directory_tree :获取递归树视图
  • move_file :移动或重命名文件
  • search_files :查找符合模式的文件
  • get_file_info :获取文件元数据
  • list_allowed_directories :查看可访问的目录
系统和网络运营
  • get_metrics :查看服务器性能指标(v0.3.0+)
  • execute_command :安全地执行系统命令(v0.3.1+)
  • curl_request :执行对外部 API 的 HTTP 请求(v1.2.0 中推出)
使用 curl_request 工具(v1.2.0 中推出)

curl_request工具允许您向外部 API 发出 HTTP 请求:

// 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}', })

有关更详细的示例,请参阅docs/curl-tool-examples.md文件。

:sparkles: 功能

核心功能

  • 安全访问:严格的路径验证可防止未经授权的访问
  • 文件操作:读取、写入、编辑和移动文件
  • 目录操作:创建、列出、获取树视图和搜索目录
  • 元数据访问:查看文件和目录信息
  • 命令执行:通过严格验证安全地执行系统命令
  • Docker 支持:使用 Docker 和 Docker Compose 轻松部署

v0.3.0 中的新功能

  • 结构化日志:具有不同级别(调试、信息、警告、错误)的详细日志记录
  • 性能指标:跟踪操作计数、错误和执行时间
  • 配置管理:支持JSON配置文件
  • 路径缓存:提高频繁访问路径的性能
  • 改进的错误处理:具有结构化信息的专门错误类型
  • 文件大小验证:防止加载过大的文件
  • CLI 改进:帮助命令、版本信息和配置生成

配置选项

您可以使用以下方式创建配置文件:

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

示例配置:

{ "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:作者

加布里埃尔·玛雅

执照

MIT 许可证

-
security - not tested
A
license - permissive license
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

安全的模型上下文协议服务器,在预定义目录内提供受控的文件系统访问,使 AI 模型能够通过严格的路径验证执行文件和目录操作。

  1. :计算机:技术
    1. 扳手工具
      1. :package: 安装
        1. :heavy\_check\_mark:先决条件
        2. :arrow\_down:克隆存储库
        3. :arrow\_forward:运行应用程序
      2. :gear: 用法
        1. 与 Claude Desktop 一起使用
        2. 可用工具
      3. :sparkles: 功能
        1. 核心功能
        2. v0.3.0 中的新功能
        3. 配置选项
        4. :writing\_hand:作者
      4. 执照

        Related MCP Servers

        • -
          security
          A
          license
          -
          quality
          A 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 -
          5
          Python
          MIT License
          • Apple
          • Linux
        • -
          security
          -
          license
          -
          quality
          A redesigned Model Context Protocol server that enables AI models to access filesystems through privacy-preserving path aliases with an optimized 6-function API interface.
          Last updated -
          TypeScript
          MIT License
        • -
          security
          F
          license
          -
          quality
          A Model Context Protocol server that extends AI capabilities by providing file system access and management functionalities to Claude or other AI assistants.
          Last updated -
          3
          TypeScript
          • Apple
        • A
          security
          A
          license
          A
          quality
          A 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 -
          9
          3
          TypeScript
          MIT License

        View all related MCP servers

        MCP directory API

        We provide all the information about MCP servers via our MCP API.

        curl -X GET 'https://glama.ai/api/mcp/v1/servers/gabrielmaialva33/mcp-filesystem'

        If you have feedback or need assistance with the MCP directory API, please join our Discord server