Repository navigation
Description
Package: @modelcontextprotocol/server-filesystem
Version: 2026.7.10
Node: v25.2.1
OS: Windows 11 (server process on Windows; reached over HTTP via supergateway)
Related: #4628 —
move_filesilently overwrites an existing destination.
Same underlying pattern: the README documents behaviour the implementation does not have.
Summary
The README documents create_directory as recursive:
- create_directory
- Create new directory or ensure it exists
- Input:
path(string)- Creates parent directories if needed
- Succeeds silently if directory exists
In practice it fails when any intermediate directory is missing.
Reproduction
Given an allowed directory <allowed_dir> in which _diag does not exist:
create_directorywithpath = <allowed_dir>/_diag/nested/deep
Expected: all three levels created.
Actual:
Parent directory does not exist: <allowed_dir>/_diag/nested
- Calling
create_directoryonce per level —<allowed_dir>/_diag, then<allowed_dir>/_diag/nested— succeeds. So only the recursive case is broken.
Related: write_file behaves the same way
Writing to a path whose parent directory does not exist fails with the identical message rather than creating the parent:
Parent directory does not exist: <allowed_dir>/_diag
This is not documented either way, so it may well be intended — but the shared error string suggests both tools go through the same validation layer, and a fix in one place likely affects both. Worth deciding explicitly whether write_file should be recursive, and documenting the answer.
Cause
Two plausible candidates:
- a missing
{ recursive: true }onfs.mkdir; or - a path-validation layer that resolves and checks the parent before
mkdiris reached, rejecting a parent that does not yet exist. The wording of the error ("Parent directory does not exist") points at this one, sincefs.mkdiritself would surfaceENOENT.
Suggested fix
Either pass { recursive: true } (and let the validation layer walk up to the nearest existing ancestor, checking that it is inside an allowed directory), or drop the "Creates parent directories if needed" bullet from the README and from the tool description.
The first matches the documented contract and the behaviour of mkdir -p, which is what callers will assume.
Activity
CryoThrust commentedon Aug 28, 2026
I checked the current filesystem server:
create_directoryalready callsfs.mkdir(validPath, { recursive: true }), so the reported behavior is fixed on currentmain. I will not open a duplicate PR.olaservo commentedon Aug 28, 2026
Confirmed on
main.create_directorydoes callfs.mkdir(..., { recursive: true }), butvalidatePathonly realpath'd the immediate parent and threwParent directory does not existwhen that was missing, so the recursive mkdir was never reached. #4631 fixes it invalidatePath.write_filekeeps failing on a missing parent, which is intended.fix(filesystem): create_directory doesn't create parent directories (m…