You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 8a3fe59
Browse filesBrowse the repository at this point in the historyBrowse files
fix(filesystem): refuse to start on an unresolvable --read-only-dir
A read-only directory is now resolved with the same realpath write
validation uses, and must be an existing directory when the server
starts. A missing directory, a dangling symlink or a name the disk
spells differently is refused at startup instead of being recorded
under a spelling write validation would never produce, which left it
writable. Replaces the nearest-ancestor resolution from the last round.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
Copy file name to clipboardExpand all lines: .changeset/filesystem-5348-read-only-dirs.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,4 +2,4 @@
2
2
"@modelcontextprotocol/server-filesystem": minor
3
3
---
4
4
5
-
Add `--read-only-dir <path>`, repeatable, to make one allowed directory read-only while the others stay writable. Every write tool stays listed but refuses a target inside a read-only directory (`move_file` on either end, including moving a directory that contains one, and `copy_file` on its destination), checked on the resolved path so a symlink cannot route around it; a 2025-era client's Roots never lift the marking. `list_allowed_directories` names the read-only directories.
5
+
Add `--read-only-dir <path>`, repeatable, to make one allowed directory read-only while the others stay writable. Every write tool stays listed but refuses a target inside a read-only directory (`move_file` on either end, including moving a directory that contains one, and `copy_file` on its destination), checked on the resolved path so a symlink cannot route around it; a 2025-era client's Roots never lift the marking. Each read-only directory must exist when the server starts, or it refuses to start. `list_allowed_directories` names the read-only directories.
- A read-only directory is an allowed directory too, so it need not also be listed on its own.
56
56
- Every write tool (`write_file`, `append_file`, `edit_file`, `create_directory`, `move_file` and `copy_file`) stays listed, since the other directories are writable, but refuses a target inside a read-only directory with an error such as `Access denied - read-only directory: /path/to/reference/notes.md is in /path/to/reference, which the server was started with --read-only-dir`. `move_file` is refused when either its source or its destination is inside one or contains one, so a protected directory cannot be carried away by moving its parent; `copy_file` may copy out of one, never into it. `edit_file` is refused there even with `dryRun`.
57
-
- The check runs on a path's resolved location, so a symlink in a writable directory cannot route a write into a read-only one. A read-only directory that does not exist yet is still protected: it is resolved through its nearest existing ancestor, so it covers the path a write would create.
57
+
- The check runs on a path's resolved location, so a symlink in a writable directory cannot route a write into a read-only one. A read-only directory must therefore exist when the server starts: one that cannot be resolved (missing, not a directory, or a dangling symlink) stops the server from starting, rather than leaving a path it could not pin down writable.
58
58
- A path inside any read-only directory is refused, so a directory nested inside a read-only one is read-only too, even if it is also given as a writable directory.
59
59
- The marking is fixed at startup and holds on both protocol eras. A 2025-era client's Roots can replace the allowed directories (see Method 2), but Roots say nothing about writing, so they never lift it: a write into a read-only directory is refused whichever directories are in force, with or without `--confine-roots`.
60
60
-`list_allowed_directories` lists the read-only directories after the allowed ones, and the server logs them to stderr at startup.
`--read-only-dir ${dir} is not an existing directory (${errorinstanceofError ? error.message : String(error)}); a read-only directory must exist when the server starts`,
0 commit comments