Back to MCP directory
publicPublicdnsLocal runtime

mcp-server-filesystem

一个基于Go语言实现的文件系统MCP服务器,提供多种文件操作工具,支持JSON数据返回和gitignore风格排除模式。

article

README

🚀 文件系统 MCP 服务器

本项目是一个基于 Go 语言实现的文件系统操作模型上下文协议(MCP)服务器。其灵感源自 Anthropic 的参考实现,具体可查看 modelcontextprotocol/servers。该服务器能帮助用户更高效地进行文件系统操作,提供了一系列实用的工具和功能。

🚀 快速开始

本服务器是基于 Go 语言实现的文件系统操作模型上下文协议(MCP)服务器,灵感来源于 Anthropic 的参考实现。它在功能上有一定的优化和改进,能为用户提供便捷的文件系统操作体验。

✨ 主要特性

与参考实现相比,本项目具有以下显著差异:

  • get_file_infodirectory_tree 命令返回 JSON 数据,方便数据处理和解析。
  • search_files 工具支持类似于 .gitignore 的排除模式,让文件搜索更加灵活。

📦 安装指南

使用以下命令安装服务器:

go install github.com/optistar/mcp-server-filesystem/cmd/mcp-server-filesystem@latest

可执行文件将安装到 Go 二进制目录中,通常为 ~/go/bin。如果该路径不在您的 PATH 环境变量中,请进行相应配置。您还可以通过设置 GOBIN 环境变量来更改安装目录。

📚 详细文档

测试

包含完整的测试套件以确保服务器按预期运行:

  • 可以使用 go test 命令正常运行测试。
  • 一个 tester 命令将测试套件打包为 MCP 客户端,可用于测试 MCP 服务器命令或其他 MCP 服务器实现。

工具

该服务器提供了以下与文件系统交互的工具:

  • create_directory:创建新目录或确保指定目录存在。
  • directory_tree:获取文件和目录的递归树视图,并以 JSON 结构返回。
  • edit_file:对文本文件进行基于行的编辑。
  • get_file_info:检索文件或目录的详细元数据。
  • list_allowed_directories:返回该服务器允许访问的所有目录列表。
  • list_directory:获取指定路径下所有文件和目录的详细清单。
  • move_file:移动或重命名文件和目录。
  • read_file:读取文件系统的完整内容。
  • read_multiple_files:同时读取多个文件的内容。
  • search_files:递归搜索匹配特定模式的文件和目录。
  • write_file:创建新文件或完全覆盖现有文件以写入新内容。

有关每个工具的详细信息,请使用 inspector 进行查看。

其他实现

此仓库与 mark3labs/mcp-filesystem-server 无关。

📄 许可证

本项目的代码根据 MIT 许可证分发。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client