Home / MCP / Filesystem MCP Server

Filesystem MCP Server

Provides read/write access to filesystem directories with optional dynamic Roots updates for runtime access control.

javascript
74.1kstars
Installation
Add the following to your MCP client configuration file.

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.

How to use

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.

Access control and Roots

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/dir2

Dynamic Roots (recommended)

If 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.

Access rules and utilities

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.

Available tools

read_text_file

Read the complete contents of a file as text, treated as UTF-8 text regardless of extension.

read_media_file

Read an image or audio file and stream base64-encoded data with the appropriate MIME type.

read_multiple_files

Read multiple files in parallel without failing the whole operation on individual read errors.

list_directory

List directory contents with a [FILE] or [DIR] prefix.

list_directory_with_sizes

List contents with sizes and include summary metrics like total files, total directories, and combined size.

move_file

Move or rename files and directories; fails if the destination already exists.

search_files

Recursively search for files or directories by pattern, with support for exclusions.

directory_tree

Get a recursive JSON tree of a directory’s contents, including nested children for directories.

get_file_info

Return detailed metadata for a file or directory, including size, times, type, and permissions.

list_allowed_directories

List all directories the server is currently allowed to access.

create_directory

Create a directory (or ensure it exists), creating parent directories as needed.

write_file

Create a new file or overwrite an existing one.

edit_file

Apply complex edits with pattern matching, formatting, and diff output; supports dry-run previews.