modelcontextprotocol/server-filesystem
Free官方参考实现,提供对本地文件系统的直接访问,带可配置权限。
FreeFree tier
About modelcontextprotocol/server-filesystem
The Filesystem MCP Server is a Node.js implementation of the Model Context Protocol (MCP) for filesystem operations. It provides a secure and flexible way for MCP clients to interact with the local file system. The server supports reading and writing files, creating, listing, and deleting directories, moving files and directories, searching for files, and retrieving file metadata. A key feature is dynamic directory access control via MCP Roots, allowing clients to update allowed directories at runtime. Alternatively, directories can be specified via command-line arguments. The server includes API tools such as read_text_file and read_media_file. It is published on npm as @modelcontextprotocol/server-filesystem.
Key Features
Read/write files with text and media support
Create, list, and delete directories
Move files and directories
Search files by path patterns
Get file metadata (size, modification time, etc.)
Dynamic directory access control via MCP Roots
Command-line arguments for allowed directories
MCP protocol integration for AI agents and assistants
Pros & Cons
Pros
- Secure directory restriction prevents unauthorized file access
- Dynamic roots allow runtime updates without server restart
- Follows the official MCP specification for interoperability
- Published as a standard npm package for easy installation
- Supports both text and media file reading (base64)
Cons
- Requires at least one allowed directory to start; error if none provided
- Text files are always treated as UTF-8 regardless of actual encoding
- Media files are returned as base64 which may be large for big files
Best For
Providing file system access to AI agents via MCPReading configuration files and data files in MCP-based workflowsWriting logs or outputs from AI interactions to local storageManaging project directories and files from MCP-compatible IDEsBuilding tools that need to search and inspect file metadata
FAQ
How do I specify allowed directories?
You can specify directories via command-line arguments when starting the server (e.g., `mcp-server-filesystem /path/to/dir1 /path/to/dir2`), or by using MCP Roots protocol where the client dynamically provides directories during initialization and updates.
What happens if no directories are provided?
If the server starts without command-line arguments and the client does not support the roots protocol or provides empty roots, the server will throw an error during initialization because at least one allowed directory is required.
Can I read image files with this server?
Yes, the `read_media_file` tool reads a file and returns it as a base64-encoded content block with its MIME type, allowing reading of images and other binary files.