:书签:关于
MCP 文件系统服务器通过模型上下文协议 (MCP Protocol) 为 AI 模型提供安全的文件系统访问。它强制执行严格的路径验证,并且仅允许访问预定义的目录。
:计算机:技术
扳手工具
:package: 安装
:heavy_check_mark:先决条件
必须安装以下软件:
- Node.js (>=18.0.0)
- Git
- pnpm (>=8.0.0)
- Docker (可选)
- Docker Compose (可选)
:arrow_down:克隆存储库
:arrow_forward:运行应用程序
本地开发
使用 NPM 包
使用 Docker
使用 Docker Compose
:gear: 用法
与 Claude Desktop 一起使用
可以将 Claude Desktop 配置为使用此 MCP 服务器进行文件系统访问。将以下内容添加到claude_desktop_config.json
文件中:
使用本地安装(推荐)
确保可执行文件在全球范围内可用:
使用 NPX
使用 Docker
注意:使用 Docker 时,所有目录必须默认挂载到/projects
。添加ro
标志将使目录变为只读。
可用工具
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 请求:
有关更详细的示例,请参阅docs/curl-tool-examples.md
文件。
:sparkles: 功能
核心功能
- 安全访问:严格的路径验证可防止未经授权的访问
- 文件操作:读取、写入、编辑和移动文件
- 目录操作:创建、列出、获取树视图和搜索目录
- 元数据访问:查看文件和目录信息
- 命令执行:通过严格验证安全地执行系统命令
- Docker 支持:使用 Docker 和 Docker Compose 轻松部署
v0.3.0 中的新功能
- 结构化日志:具有不同级别(调试、信息、警告、错误)的详细日志记录
- 性能指标:跟踪操作计数、错误和执行时间
- 配置管理:支持JSON配置文件
- 路径缓存:提高频繁访问路径的性能
- 改进的错误处理:具有结构化信息的专门错误类型
- 文件大小验证:防止加载过大的文件
- CLI 改进:帮助命令、版本信息和配置生成
配置选项
您可以使用以下方式创建配置文件:
示例配置:
:writing_hand:作者
加布里埃尔·玛雅 |
执照
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
安全的模型上下文协议服务器,在预定义目录内提供受控的文件系统访问,使 AI 模型能够通过严格的路径验证执行文件和目录操作。
Related MCP Servers
- -securityAlicense-qualityA 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 -5PythonMIT License
- -security-license-qualityA 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 -TypeScriptMIT License
- -securityFlicense-qualityA Model Context Protocol server that extends AI capabilities by providing file system access and management functionalities to Claude or other AI assistants.Last updated -3TypeScript
- AsecurityAlicenseAqualityA 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 -93TypeScriptMIT License