SuperAPIAI Directory

modelcontextprotocol/server-filesystem

github.com · AI developer platforms

Filesystem MCP Server is one of the reference servers of the Model Context Protocol, implemented in Node.js and published as the npm package @modelcontextprotocol/server-filesystem. It provides filesystem operation capabilities to clients via MCP, including reading and writing files, creating/listing/deleting directories, moving files or directories, and retrieving file metadata. The server specifies the directories allowed for access via command-line arguments, and supports read-only mode as well as per-directory read-only settings, while being compatible with both the 2026-07-28 and 2025 generations of the protocol.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsmacOS · Linux

About this tool

Purpose

Filesystem MCP Server is a reference server of the Model Context Protocol (MCP), implemented in Node.js, providing controlled filesystem operation capabilities to MCP clients. It has been published to npm under the package name @modelcontextprotocol/server-filesystem.

Main capabilities

  • Read and write files
  • Create, list, and delete directories
  • Move files and directories
  • Retrieve file metadata
  • Directory access control via command-line arguments; Roots has been deprecated as a convenience mechanism of the 2025 era
  • Serve both generations of the protocol over stdio: 2026-07-28 clients (server/discover, no handshake) and 2025-era clients (initialize)

Usage

The server can only access its "allowed directories", which are passed in via the command line. The recommended approach is to specify the allowed directories when starting the server; options may appear before, between, or after the directories.

Read-only mode: after adding --read-only, the server only registers tools marked with readOnlyHint: true (read and list types); all write-type tools (such as write_file, edit_file) are not registered, cannot be listed by clients, and calls to them fail as unknown tools. This restriction is enforced by the server, independent of client configuration, behaves the same under npx and Docker, and applies to both generations of the protocol as well as to directories from client Roots.

Per-directory read-only: using --read-only-dir <path> makes a directory read-only while the remaining directories stay writable; multiple directories can be specified by repeating the option. A read-only directory is itself also an allowed directory and does not need to be listed separately. Write-type tools are still listed, but targets within read-only directories are rejected with an error. move_file is rejected when the source or target is inside a read-only directory or contains a read-only directory; copy_file can copy out of a read-only directory but cannot copy into it; edit_file is rejected even with dryRun. The check is based on the actual location after path resolution, so a symbolic link in a writable directory cannot redirect writes into a read-only directory. Read-only directories must exist when the server starts; failure to resolve them (missing, not a directory, or a dangling symbolic link) causes the server to fail to start. Nested directories within a read-only directory are likewise read-only, even if they are also specified as writable directories.This flag is fixed at startup and takes effect for both protocol generations; for 2025-era clients, Roots can replace the allowed directories but do not lift the read-only restriction. list_allowed_directories lists read-only directories after the allowed directories, and the server also logs read-only directories to stderr at startup.

MCP Roots (deprecated, 2025-era clients only): clients that use a 2025-era protocol version (initialize handshake) and support Roots can dynamically update the allowed directories. Roots notified by the client, when provided, fully replace the server-side allowed directories. To confine client Roots to the directories given on the command line, add --confine-roots: client Roots can only narrow the command-line directories, not replace or expand them. The server allows the intersection of the two: a root located inside a command-line directory is allowed as-is; a root that contains a command-line directory (e.g. /) is narrowed to that directory; a root outside all command-line directories is ignored and logged. If all roots are ignored, the server treats it as an update with no valid roots: before any root has taken effect, the command-line directories are retained; once a root has taken effect, access is revoked until the client again exposes a root located within them.

Important: if the server starts with no command-line arguments and a 2025-era client does not support the roots protocol, the server fails at initialization: it logs the reason to stderr, closes the connection, and exits with status code 1. A client that supports roots but does not provide (or does not provide a valid) root keeps the connection open but has no allowed directories until it sends roots/list_changed with a valid root. The 2026-07-28 protocol has no initialize handshake and no server-to-client roots/list request, so roots are never requested from 2026-07-28 clients: the command-line directories are the entire allowlist. If the server starts with no directories at all, every tool call on such a connection returns an error explanation.

Use cases

Suitable for scenarios requiring controlled read/write access to the local filesystem, directory management, and metadata queries through an MCP client, especially deployments that want to limit accessible directories via command-line arguments or need read-only protection for some directories.

Limitations

  • All filesystem operationsare all restricted to allowed directories; the server requires at least one allowed directory to run.
  • Paths are checked before use; on macOS and Linux, every write, read of file contents or metadata, and directory listing is performed from inside the checked directory, and if a directory in the path is replaced during the operation, the call is rejected with "Access denied - a directory on the path changed during the operation". Listing a directory requires entering that directory; a directory with only read permission and no execute permission is rejected with EACCES.
  • On Windows, paths naming NTFS alternate data streams (such as file.txt:stream, file.txt::$DATA) are rejected, even if inside an allowed directory; a colon is accepted only as a drive letter (C:, \?\C:).
  • On Windows, path components that are reserved device names (CON, PRN, AUX, NUL, COM1-COM9, LPT1-LPT9, in any case, with or without an extension, such as NUL.txt) are rejected; components ending in a dot or space (such as file.txt., dir \file.txt) are also rejected. . and .. are unaffected.
  • Windows limitation: the parent directory is replaced during the operation. On Linux and macOS the server anchors every write, read of file contents or metadata, and directory listing to the verified directory, so a directory replaced by a symbolic link after the check cannot redirect the operation; on Windows this cannot be done, and the operation is unprotected: a local second process that can already write inside the allowed directory can replace the parent directory with a junction (or directory symbolic link) between the check and the open, thereby redirecting the read, write, or directory listing outside the allowed directory. The server still checks the final component (writes reject a symbolic link or junction at the file's own name, and the opened file must be the file that the directory subsequently holds under that name), which narrows the window but does not close it.
  • Directory access control flow: at startup the server uses the directories from the command-line arguments (if provided); if no arguments are provided, it starts with an empty allowed directory. When a client connects, the first message determines the connection's protocol era: a 2026-07-28 client sends server/discover (or any request carrying a per-request _meta envelope), and the server uses the command-line directories without Roots processing; a 2025-era clientThe client sends initialize and its capabilities, and the server checks whether roots are supported (capabilities.roots). For 2025-era clients that support roots, during initialization the server requests roots via roots/list, the client returns the configured roots, and the server replaces all allowed directories with the client roots (when using --confine-roots, it takes the intersection with the command-line directories); tool calls that arrive before the initial roots are loaded will wait so they can be checked against the client roots. At runtime, the client can send notifications/roots/list_changed, and the server requests the updated roots and replaces the allowed directories again; tool calls that arrive while the update is being fetched will wait, avoiding running against a root the client has just revoked. Once client roots take effect, an update with no valid roots revokes access: every path is denied ("Access denied - no allowed directories") until the client exposes a root again; before any root takes effect, such an update retains the command-line directories. 2025-era clients that do not support roots continue to use only the command-line directories and cannot update dynamically; if there are also no command-line directories, the server logs an error, closes the connection, and exits with status code 1.
  • The server logs the effective allowed directories and their source to stderr at startup and whenever the allowed directories change (after initialize, after each Roots update, and when revocation results in no directories).
  • When using --confine-roots, if there are no command-line directories, the flag has no effect, and the server warns at startup.
  • A Root reached via a symbolic link is allowed both in its advertised form and in its resolved form; each request path is still resolved and checked against the resolved directories, and symbolic links inside a Root that point outside are denied.
  • It is recommended to also make protected directories read-only at the operating system level (file permissions or Docker's ro bind mounts) to provide defense in depth.
Up/Down to navigate · Enter to open · ESC to closeBrowse all tools