Filesystem MCP Server 是官方的吗?
是的。它是 `modelcontextprotocol/servers` 仓库中的参考服务器,在 npm 上以 `@modelcontextprotocol/server-filesystem` 发布。

@modelcontextprotocol
基本信息
Model Context Protocol 服务器
使用下面的配置,将此服务器添加到你的 MCP 客户端。
{
"mcpServers": {
"filesystem": {
"command": "docker",
"args": [
"build",
"-t",
"mcp/filesystem",
"-f",
"src/filesystem/Dockerfile",
"."
]
}
}
}Read complete contents of a file as text
Read a file and return it as a base64-encoded content block with its MIME type
Read multiple files simultaneously
Create new file or overwrite existing (exercise caution with this)
Make selective edits using advanced pattern matching and formatting
Create new directory or ensure it exists
List directory contents with [FILE] or [DIR] prefixes
List directory contents with [FILE] or [DIR] prefixes, including file sizes
Move or rename files and directories
Recursively search for files/directories that match or do not match patterns
Get recursive JSON tree structure of directory contents
Get detailed file/directory metadata
List all directories the server is allowed to access
Filesystem MCP Server 是 Model Context Protocol 项目提供的参考版 filesystem MCP 服务器:一个 Node.js 服务器,让 Claude 和其他 MCP 客户端可以读取、写入、编辑、移动和搜索文件,但只限于你允许的目录。
它在 npm 上以 @modelcontextprotocol/server-filesystem 发布,Docker 镜像为 mcp/filesystem,源码位于官方 modelcontextprotocol/servers 仓库(MIT License)。它通过 stdio 在本地运行,不需要 API key,并且每个工具都被标注为不会访问互联网或其他外部系统。
前置条件:Node.js(用于 npx)或 Docker。无需账号或 API key。唯一必需的输入是至少一个允许访问的目录,可以通过命令行参数提供,也可以由客户端通过 MCP Roots 提供。
以命令行参数指定允许的目录:
mcp-server-filesystem /path/to/dir1 /path/to/dir2
推荐使用 MCP Roots:支持 Roots 的客户端会把工作区文件夹发送给服务器,服务器用它们替换命令行中的目录列表,并在运行时通过 roots/list_changed 接收变更,无需重启。
在 claude_desktop_config.json 中添加以下内容,并列出要开放的文件夹:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/username/Desktop",
"/path/to/other/allowed/dir"
]
}
}
}
在 Windows 上,通过 cmd /c 启动 npx:
{
"mcpServers": {
"filesystem": {
"command": "cmd",
"args": [
"/c",
"npx",
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/username/Desktop",
"/path/to/other/allowed/dir"
]
}
}
}
使用 Docker 时,把每个目录挂载到 /projects 下。加上 ro 后,该挂载对服务器只读:
{
"mcpServers": {
"filesystem": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--mount", "type=bind,src=/Users/username/Desktop,dst=/projects/Desktop",
"--mount", "type=bind,src=/path/to/other/allowed/dir,dst=/projects/other/allowed/dir,ro",
"mcp/filesystem",
"/projects"
]
}
}
}
在命令面板中运行 MCP: Open User Configuration,或在工作区中创建 .vscode/mcp.json 以便与他人共享配置。注意 VS Code 使用的是 servers 键:
{
"servers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"${workspaceFolder}"
]
}
}
}
Docker 版本会把 ${workspaceFolder} 挂载到 /projects/workspace,并把 /projects 作为参数传入。
README 没有为这两个客户端提供步骤,但它们都可以运行同样的 stdio 命令。在 Claude Code 中:
claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem /path/to/allowed/dir
在 Cursor 中,把上面 Claude Desktop 的 mcpServers 配置块添加到 Cursor 的 mcp.json。
list_allowed_directories 可显示当前生效的目录。read_text_file 支持 head/tail 行数限制,read_media_file 以 base64 内容块返回图片和音频,并附带 MIME 类型。edit_file 进行定点查找替换,保留缩进和 LF/CRLF 换行符,返回 git 风格的 diff,并支持 dryRun 预览。directory_tree,两者都支持排除模式。ro),用于模型可以读取但不能修改的文件夹。该服务器提供 13 个工具,分为三组:
read_text_file、read_media_file 和 read_multiple_files(单个读取失败不会中断整批操作)。list_directory、list_directory_with_sizes(可按名称或大小排序,并给出汇总)、directory_tree、search_files、get_file_info(大小、时间、类型、权限)和 list_allowed_directories。write_file 创建或覆盖文件,edit_file 进行选择性编辑,create_directory 创建嵌套文件夹,move_file 移动或重命名文件,目标已存在时会失败。没有删除工具。README 将 write_file、edit_file 和 move_file 标为破坏性操作。
getUser 调用改名为 fetchUser,先给我看 diff。”args 中至少添加一个允许的目录。list_allowed_directories 查看当前列表,并注意 Roots 会完全替换命令行目录。/projects 下,并且如 README 示例所示,/projects 作为目录参数传给服务器。npx: 使用上面所示的 cmd /c npx ... 写法。是的。它是 `modelcontextprotocol/servers` 仓库中的参考服务器,在 npm 上以 `@modelcontextprotocol/server-filesystem` 发布。
免费。它以 MIT License 开源,在本地运行,不需要 API key 或付费服务。
把允许的目录作为参数传入,或让支持 Roots 的客户端提供。所有操作都限制在这些路径内。使用 Docker 时,只挂载需要的目录,并添加 `ro` 实现只读访问。
它没有提供删除工具。不过 `write_file` 会覆盖文件,`edit_file` 会修改文件,`move_file` 会移除源文件,因此授予写入权限时需要谨慎。
可以。在 `edit_file` 中把 `dryRun` 设为 `true`,即可获得 diff 而不修改文件。README 建议先这样做。
支持。它是标准的 stdio MCP 服务器。README 记录了 Claude Desktop 和 VS Code 的用法;Claude Code 和 Cursor 可以运行同样的 `npx` 命令。
本地。它通过 stdio 在你的机器上运行,只在允许的目录内访问本地文件系统。
`read_media_file` 会把图片和音频作为 image 或 audio 内容返回,其他文件类型则作为嵌入的 base64 resource 返回。
MCP server for working with PDF files
A MCP server providing realistic browser-like HTTP request capabilities with accurate TLS/JA3/JA4 fingerprints for bypassing anti-bot measures. It also supports converting PDF and HTML documents to Markdown for easier processing by LLMs.
Blazing-fast, asynchronous MCP server for seamless filesystem operations.
MCP Workspace Server: A secure Model Context Protocol server providing file, git, and GitHub tools for AI assistants within a sandboxed project directory.
评论