MM

mark3labs/mcp-filesystem-server

部署与 DevOps

本页由 AI 翻译,技术细节请以原文为准。 查看原文

693 stars 116 forks 质量 69 趋势 21MIT

Go 服务器实现了用于文件系统操作的模型上下文协议(MCP)。

概览

该MCP服务器通过模型上下文协议(MCP)提供对本地文件系统的安全访问。 - - 名称:文件系统- 描述:访问本地文件系统中的文件和目录 - - 从文件系统读取文件的完整内容- 参数:路径(必需):读取文件的路径 - - 在一次操作中读取多个文件的内容- 参数:路径(必需):需读取的文件路径列表 - - 创建新文件或覆盖已有文件添加新内容- 参数:路径(必需):写入文件的路径,内容(必需):写入文件的内容 - - 复制文件和目录- 参数:来源(必需):文件或目录的源路径,目的(必需):目的路径 - - 移动或重命名文件和目录- 参数:源(必需):文件或目录的源路径,目的(必需):目的路径 - - 从文件系统中删除文件或目录- 参数:路径(必修):...

概述(AI 翻译)

该MCP服务器通过模型上下文协议(MCP)提供对本地文件系统的安全访问。

组成部分

资源

  • file://
  • 名称:文件系统
  • 描述:访问本地文件系统中的文件和目录

工具

文件操作

  • read_file

  • 从文件系统读取文件的完整内容

  • 参数:path(必需):读取文件路径

  • read_multiple_files

  • 一次操作读取多个文件的内容

  • 参数:paths(必需):需读取的文件路径列表

  • write_file

  • 创建新文件或覆盖现有文件以新内容

  • 参数:path(必需):写入文件的路径,content(必需):写入文件的内容

  • copy_file

  • 复制文件和目录

  • 参数:source(必需):文件或目录的源路径,destination(必需):目的路径

  • move_file

  • 移动或重命名文件和目录

  • 参数:source(必需):文件或目录的源路径,destination(必需):目的路径

  • delete_file

  • 从文件系统中删除文件或目录

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

MCP Filesystem Server

This MCP server provides secure access to the local filesystem via the Model Context Protocol (MCP).

Components

Resources

  • file://
    • Name: File System
    • Description: Access to files and directories on the local file system

Tools

File Operations

  • read_file

    • Read the complete contents of a file from the file system
    • Parameters: path (required): Path to the file to read
  • read_multiple_files

    • Read the contents of multiple files in a single operation
    • Parameters: paths (required): List of file paths to read
  • write_file

    • Create a new file or overwrite an existing file with new content
    • Parameters: path (required): Path where to write the file, content (required): Content to write to the file
  • copy_file

    • Copy files and directories
    • Parameters: source (required): Source path of the file or directory, destination (required): Destination path
  • move_file

    • Move or rename files and directories
    • Parameters: source (required): Source path of the file or directory, destination (required): Destination path
  • delete_file

    • Delete a file or directory from the file system
    • Parameters: path (required): Path to the file or directory to delete, recursive (optional): Whether to recursively delete directories (default: false)
  • modify_file

    • Update file by finding and replacing text using string matching or regex
    • Parameters: path (required): Path to the file to modify, find (required): Text to search for, replace (required): Text to replace with, all_occurrences (optional): Replace all occurrences (default: true), regex (optional): Treat find pattern as regex (default: false)

Directory Operations

  • list_directory

    • Get a detailed listing of all files and directories in a specified path
    • Parameters: path (required): Path of the directory to list
  • create_directory

    • Create a new directory or ensure a directory exists
    • Parameters: path (required): Path of the directory to create
  • tree

    • Returns a hierarchical JSON representation of a directory structure
    • Parameters: path (required): Path of the directory to traverse, depth (optional): Maximum depth to traverse (default: 3), follow_symlinks (optional): Whether to follow symbolic links (default: false)

Search and Information

  • search_files

    • Recursively search for files and directories matching a pattern
    • Parameters: path (required): Starting path for the search, pattern (required): Search pattern to match against file names
  • search_within_files

    • Search for text within file contents across directory trees
    • Parameters: path (required): Starting directory for the search, substring (required): Text to search for within file contents, depth (optional): Maximum directory depth to search, max_results (optional): Maximum number of results to return (default: 1000)
在 GitHub 查看完整 README

安装

docker run -i --rm ghcr.io/mark3labs/mcp-filesystem-server:latest /path/to/allowed/directory
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "filesystem": { "command": "mcp-filesystem-server", "args": ["/path/to/allowed/directory", "/another/allowed/directory"] } } }