Home / MCP / Filesystem MCP Server
Provides read/write access to filesystem directories with optional dynamic Roots updates for runtime access control.
Configuration
View docs{
"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",
"--mount",
"type=bind,src=/path/to/file.txt,dst=/projects/path/to/file.txt",
"mcp/filesystem",
"/projects"
]
}
}
}You run a filesystem-based MCP Server that lets clients read, write, and manage files and directories through the Model Context Protocol. It provides controlled access to specified directories, supports dynamic updates via Roots, and exposes a practical set of file-system operations you can perform over MCP clients.
Operate the filesystem MCP server to perform common file tasks from a client. You can start with a set of allowed directories either from the command line or via Roots support from your MCP client. When Roots are enabled, the client can dynamically update which directories are allowed without restarting the server. All operations stay within the allowed directories.
There are two ways to specify which directories your server can access. You can either provide them on startup or allow a client to push the directory list at runtime.
If you start with directories on the command line, use a command like this to run the server with two allowed directories.
mcp-server-filesystem /path/to/dir1 /path/to/dir2If your client supports Roots, you can dynamically replace all allowed directories when the client sends the initial roots list or whenever roots/list_changed notifications occur.
On initialization, the server requests the client’s roots and replaces all allowed directories with what the client provides. At runtime, any update to roots replaces the allowed directories again.
If the client does not support Roots, the server only uses the startup directories and cannot accept runtime updates.
All filesystem operations are restricted to the allowed directories. To verify which directories you can access, use the provided tool to list them. The server requires at least one allowed directory to operate.
Read the complete contents of a file as text, treated as UTF-8 text regardless of extension.
Read an image or audio file and stream base64-encoded data with the appropriate MIME type.
Read multiple files in parallel without failing the whole operation on individual read errors.
List directory contents with a [FILE] or [DIR] prefix.
List contents with sizes and include summary metrics like total files, total directories, and combined size.
Move or rename files and directories; fails if the destination already exists.
Recursively search for files or directories by pattern, with support for exclusions.
Get a recursive JSON tree of a directory’s contents, including nested children for directories.
Return detailed metadata for a file or directory, including size, times, type, and permissions.
List all directories the server is currently allowed to access.
Create a directory (or ensure it exists), creating parent directories as needed.
Create a new file or overwrite an existing one.
Apply complex edits with pattern matching, formatting, and diff output; supports dry-run previews.