该 MCP 服务器通过模型上下文协议(MCP)提供对本地文件系统的安全访问。
read_file
path(必填):要读取的文件路径read_multiple_files
paths(必填):要读取的文件路径列表write_file
path(必填):写入文件的路径,content(必填):要写入文件的内容copy_file
source(必填):文件或目录的源路径,destination(必填):目标路径move_file
source(必填):文件或目录的源路径,destination(必填):目标路径delete_file
path(必填):要删除的文件或目录路径,recursive(可选):是否递归删除目录(默认:false)list_directory
path(必填):要列出的目录路径create_directory
path(必填):要创建的目录路径tree
path(必填):要遍历的目录路径,depth(可选):最大遍历深度(默认:3),follow_symlinks(可选):是否跟随符号链接(默认:false)search_files
path(必填):搜索的起始路径,pattern(必填):与文件名匹配的搜索模式get_file_info
path(必填):文件或目录的路径list_allowed_directories
go install github.com/mark3labs/mcp-filesystem-server@latest
启动 MCP 服务器并指定允许的目录:
mcp-filesystem-server /path/to/allowed/directory [/another/allowed/directory ...]
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)
}
}

要将此服务器与支持 MCP 的应用程序集成:
{
"mcpServers": {
"filesystem": {
"command": "mcp-filesystem-server",
"args": ["/path/to/allowed/directory", "/another/allowed/directory"]
}
}
}

您可以使用 Docker 运行文件系统 MCP 服务器:
docker run -i --rm ghcr.io/mark3labs/mcp-filesystem-server:latest /path/to/allowed/directory

要将 Docker 镜像与支持 MCP 的应用程序集成:
{
"mcpServers": {
"filesystem": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"ghcr.io/mark3labs/mcp-filesystem-server:latest",
"/path/to/allowed/directory"
]
}
}
}

详情请参阅 LICENSE 文件。