Skip to content

Commit 59da46e

Browse files
committed
Merge remote-tracking branch 'origin/v2/main' into v2/fix/4991-filesystem-edit-line-endings
Signed-off-by: cliffhall <[email protected]> # Conflicts: # src/filesystem/__tests__/lib.test.ts
2 parents e0bf956 + 8decb40 commit 59da46e

17 files changed

Lines changed: 809 additions & 283 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@modelcontextprotocol/server-filesystem": patch
3+
---
4+
5+
`write_file` and `edit_file` now overwrite an existing file in place instead of renaming a temp file over it, so the file keeps its inode, creation time (birthtime), hard links and permission bits (#4512), and an overwrite no longer fails with `EPERM` on Windows when another process holds the file open (#3199). A symlink swapped in after the path was validated is still refused rather than written through, now by an `O_NOFOLLOW` open (on POSIX) and a check that the opened file is the one validated (on every platform). The overwrite is no longer crash-atomic. A read-only file is now refused (`EACCES`, or `EPERM` on Windows) instead of being replaced, since writing in place opens the file itself for writing.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@modelcontextprotocol/server-filesystem": patch
3+
---
4+
5+
Tool calls now wait for the client's initial roots before checking paths, so a call sent right after connecting is no longer refused with "Access denied" (#3204). A server started with no directories, connected to a client without Roots support, now fails visibly: it logs the reason, closes the connection and exits with status 1, instead of staying up and refusing every call (#4992).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@modelcontextprotocol/server-filesystem": patch
3+
---
4+
5+
Every tool's input and output schema in `tools/list` now declares `"$schema": "https://json-schema.org/draft/2020-12/schema"` instead of draft-07, so clients that validate tool schemas strictly against JSON Schema 2020-12 no longer reject every tool. The schemas are otherwise unchanged.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@modelcontextprotocol/server-filesystem": patch
3+
---
4+
5+
On Windows, a UNC share root given as an allowed directory (`\\server\share` or `\\server\share\`) now admits the files and subdirectories under it. Before, only the share root itself was accessible and every path below it was refused. Sibling shares such as `\\server\share-evil` are still refused.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@modelcontextprotocol/server-filesystem": patch
3+
---
4+
5+
Paths that differ from the names on disk only in Unicode form now resolve (#1970). An NFC spelling of an allowed directory whose name is stored NFD (macOS "Capture d’écran", Japanese dakuten) is no longer refused as outside the allowed directories, and a request that spells a U+202F or U+00A0 in a name as a plain space (the macOS screenshot "Screenshot … at 2.40.40 PM.png") finds the file instead of failing with ENOENT. The exact spelling still wins when it exists, and a name matching two entries is refused as ambiguous.

‎src/filesystem/README.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ MCP clients that support [Roots](https://modelcontextprotocol.io/docs/learn/clie
2828

2929
Roots notified by Client to Server, completely replace any server-side Allowed directories when provided.
3030

31-
**Important**: If server starts without command-line arguments AND client doesn't support roots protocol (or provides empty roots), the server will throw an error during initialization.
31+
**Important**: If server starts without command-line arguments AND client doesn't support roots protocol, the server fails at initialization: it logs the reason to stderr, closes the connection and exits with status 1. A client that supports roots but provides none (or none that are valid) keeps the connection, with no allowed directories until it sends `roots/list_changed` with valid roots.
3232

3333
This is the recommended method, as this enables runtime directory updates via `roots/list_changed` notifications without server restart, providing a more flexible and modern integration experience.
3434

@@ -48,12 +48,14 @@ The server's directory access control follows this flow:
4848
- **On initialization**: Server requests roots from client via `roots/list`
4949
- Client responds with its configured roots
5050
- Server replaces ALL allowed directories with client's roots
51+
- Tool calls that arrive before the initial roots are loaded wait for them, so they are checked against the client's roots
5152
- **On runtime updates**: Client can send `notifications/roots/list_changed`
5253
- Server requests updated roots and replaces allowed directories again
5354

5455
4. **Fallback Behavior** (if client doesn't support roots)
5556
- Server continues using command-line directories only
5657
- No dynamic updates possible
58+
- With no command-line directories either, the server logs an error, closes the connection and exits with status 1
5759

5860
5. **Access Control**
5961
- All filesystem operations are restricted to allowed directories
@@ -95,6 +97,10 @@ The server's directory access control follows this flow:
9597
- Inputs:
9698
- `path` (string): File location
9799
- `content` (string): File content
100+
- An existing file is overwritten in place, so it keeps its inode, creation
101+
time, hard links and permissions (`edit_file` writes the same way). The
102+
overwrite is not crash-atomic: a crash mid-write can leave the file partly
103+
written. A read-only file is refused rather than replaced
98104

99105
- **edit_file**
100106
- Make selective edits using advanced pattern matching and formatting

0 commit comments

Comments
 (0)