X

test1

Information

MCP 文件系统服务器 此MCP服务器通过模型上下文协议(MCP)提供对本地文件系统的安全访问。 组件 资源 file:// 名称: 文件系统 描述: 访问本地文件系统上的文件和目录 工具 文件操作 read_file 从文件系统中读取一个文件的全部内容 参数: path (必需): 要读取的文件路径 read_multiple_files 在单次操作中读取多个文件的内容 参数: paths (必需): 要读取的文件路径列表 write_file 创建新文件或将现有文件用新内容覆盖 参数: path (必需): 写入文件的路径, content (必需): 要写入文件的内容 copy_file 复制文件和目录 参数: source (必需): 文件或目录的源路径, destination (必需): 目标路径 move_file 移动或重命名文件和目录 参数: source (必需): 文件或目录的源路径, destination (必需): 目标路径 delete_file 从文件系统中删除文件或目录 参数: path (必需): 要删除的文件或目录路径, recursive (可选): 是否递归删除目录 (默认: false) modify_file 通过字符串匹配或正则表达式查找并替换文本来更新文件 参数: path (必需): 要修改的文件路径, find (必需): 要搜索的文本, replace (必需): 替换为的文本, all_occurrences (可选): 替换所有出现 (默认: true), regex (可选): 将查找模式视为正则表达式 (默认: false) 目录操作 list_directory 获取指定路径下所有文件和目录的详细列表 参数: path (必需): 要列出的目录路径 create_directory 创建新目录或确保目录存在 参数: path (必需): 要创建的目录路径 tree 返回目录结构的分层JSON表示 参数: path (必需): 要遍历的目录路径, depth (可选): 最大遍历深度 (默认: 3), follow_symlinks (可选): 是否跟随符号链接 (默认: false) 搜索与信息 search_files 递归搜索符合模式的文件和目录 参数: path (必需): 搜索的起始路径, pattern (必需): 用于匹配文件名的搜索模式 search_within_files 在目录树中的文件内容内搜索文本 参数: path (必需): 搜索的起始目录, substring (必需): 要在文件内容中搜索的文本, depth (可选): 最大目录搜索深度, max_results (可选): 返回的最大结果数 (默认: 1000) get_file_info 获取有关文件或目录的详细元数据 参数: path (必需): 文件或目录的路径 list_allowed_directories 返回该服务器允许访问的目录列表 参数: 无 特性 对指定目录的安全访问 路径验证以防止目录遍历攻击 带有安全检查的符号链接解析 MIME类型检测 支持文本、二进制和图像文件 内联内容和base64编码的大小限制 开始使用 安装 使用Go安装 bash go install github.com/mark3labs/mcp-filesystem-server@latest 使用 作为独立服务器 启动带有允许目录的MCP服务器: bash mcp-filesystem-server /path/to/allowed/directory [/another/allowed/directory ...] 作为Go项目中的库 go package main import ( "log" "os" "github.com/mark3labs/mcp-filesystem-server/filesystemserver" ) func main() \{ // 创建一个新的文件系统服务器,包含允许的目录 allowedDirs := []string\{"/path/to/allowed/directory", "/another/allowed/directory"\} fs, err := filesystemserver.NewFilesystemServer(allowedDirs) if err != nil \{ log.Fatalf("Failed to create server: %v", err) \} // 服务请求 if err := fs.Serve(); err != nil \{ log.Fatalf("Server error: %v", err) \} \}### 使用 Model Context Protocol 要将此服务器与支持MCP的应用程序集成: json \{ "mcpServers": \{ "filesystem": \{ "command": "mcp-filesystem-server", "args": ["/path/to/allowed/directory", "/another/allowed/directory"] \} \} \} Docker 使用Docker运行 您可以使用Docker来运行Filesystem MCP服务器: bash docker run -i --rm ghcr.io/mark3labs/mcp-filesystem-server /path/to/allowed/directory 使用MCP的Docker配置 要将Docker镜像与支持MCP的应用程序集成: json \{ "mcpServers": \{ "filesystem": \{ "command": "docker", "args": [ "run", "-i", "--rm", "ghcr.io/mark3labs/mcp-filesystem-server", "/path/to/allowed/directory" ] \} \} \} 如果您需要容器内的更改反映到主机文件系统上,可以挂载一个卷。这允许容器访问和修改主机系统上的文件。以下是一个示例: json \{ "mcpServers": \{ "filesystem": \{ "command": "docker", "args": [ "run", "-i", "--rm", "--volume=/allowed/directory/in/host:/allowed/directory/in/container", "ghcr.io/mark3labs/mcp-filesystem-server", "/allowed/directory/in/container" ] \} \} \} 许可证 有关详细信息,请参阅LICENSE文件。

Prompts

Reviews

Tags

Write Your Review

Detailed Ratings

ALL
Correctness
Helpfulness
Interesting
Upload Pictures and Videos

Name
Size
Type
Download
Last Modified
  • Community

Add Discussion

Upload Pictures and Videos