Skip to content

Commit ad4bd87

Browse files
committed
Merge remote-tracking branch 'origin/v2/main' into v2/fix/5004-everything-wave1-rollup
2 parents bc05e90 + acfbdd3 commit ad4bd87

24 files changed

Lines changed: 1222 additions & 361 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+
`edit_file` keeps a file's line endings: a CRLF file is written back with CRLF instead of being converted to LF. When `oldText` has no exact match and the whitespace-tolerant matcher is used, each replacement line now takes the indentation of the file line it replaces, shifted by its indentation relative to the matching `oldText` line, instead of only the first line being reindented.
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.

‎.github/workflows/python.yml‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,36 @@ jobs:
9999
- name: Coverage
100100
run: npm run coverage:py -- ${{ matrix.package }}
101101

102+
# The test suites on Windows (#1149), beside the Ubuntu `test` legs. Only
103+
# pytest: ruff, pyright and the build do not depend on the OS.
104+
test-windows:
105+
timeout-minutes: 20
106+
needs: [detect-packages]
107+
strategy:
108+
fail-fast: false
109+
matrix:
110+
package: ${{ fromJson(needs.detect-packages.outputs.packages) }}
111+
name: Test ${{ matrix.package }} (Windows)
112+
runs-on: windows-latest
113+
steps:
114+
- uses: actions/checkout@v6
115+
116+
- name: Install uv
117+
uses: astral-sh/setup-uv@v7
118+
119+
- name: Set up Python
120+
uses: actions/setup-python@v7
121+
with:
122+
python-version-file: "src/${{ matrix.package }}/.python-version"
123+
124+
- name: Install dependencies
125+
working-directory: src/${{ matrix.package }}
126+
run: uv sync --locked --all-extras --dev
127+
128+
- name: Run pytest
129+
working-directory: src/${{ matrix.package }}
130+
run: uv run --frozen pytest
131+
102132
build:
103133
timeout-minutes: 10
104134
needs: [detect-packages, test]

‎.github/workflows/typescript.yml‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,37 @@ jobs:
122122
working-directory: src/${{ matrix.package }}
123123
run: npm run coverage
124124

125+
# The test suites on Windows (#1149). Every other job runs on Ubuntu, so
126+
# Windows-only code paths (drive letters, UNC shares, no O_NOFOLLOW, rename
127+
# over a locked file) were only ever exercised by mocking `path.win32`. This
128+
# leg runs each server's own `npm test` on a real Windows runner. It is tests
129+
# only: format, lint, typecheck and coverage do not depend on the OS and stay
130+
# in the Ubuntu legs above.
131+
test-windows:
132+
timeout-minutes: 20
133+
needs: [detect-packages]
134+
strategy:
135+
fail-fast: false
136+
matrix:
137+
package: ${{ fromJson(needs.detect-packages.outputs.packages) }}
138+
name: Test ${{ matrix.package }} (Windows)
139+
runs-on: windows-latest
140+
steps:
141+
- uses: actions/checkout@v6
142+
143+
- uses: actions/setup-node@v7
144+
with:
145+
node-version: 22
146+
cache: npm
147+
148+
# The same install as the `validate` leg; its `prepare` builds `dist/`.
149+
- name: Install dependencies
150+
run: npm ci --workspace src/${{ matrix.package }} --include-workspace-root
151+
152+
- name: Run tests
153+
working-directory: src/${{ matrix.package }}
154+
run: npm test
155+
125156
# The boot smoke (#4871): every server started the way a client starts it —
126157
# the built `dist/index.js` for the TypeScript servers, the console script
127158
# through `uv run` for the Python ones — over each transport it implements,

‎docs/quality-gate.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ your machine. It is the strongest predictor of a green CI there is here, though
2222
not a proof: CI runs on Linux, on a fresh `npm ci`, with Node 22 and each
2323
Python server's pinned interpreter.
2424

25+
**The one exception is the Windows legs** (#1149): `test-windows` in both
26+
workflows runs each server's test suite (`npm test`, `pytest`) on a
27+
`windows-latest` runner. The gate runs the same suites, but only on your
28+
machine's OS, so a Windows-only failure (a drive letter, a UNC path, a missing
29+
`O_NOFOLLOW`, a locked file) shows up first in CI. When a PR touches
30+
platform-specific code, wait for those legs, not just the gate.
31+
2532
The inner-loop commands are subsets. They are for speed while working, and are
2633
never a substitute for the gate.
2734

‎src/filesystem/README.md‎

Lines changed: 9 additions & 2 deletions
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,14 +97,19 @@ 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
101107
- Features:
102108
- Line-based and multi-line content matching
103109
- Whitespace normalization with indentation preservation
104110
- Multiple simultaneous edits with correct positioning
105-
- Indentation style detection and preservation
111+
- Indentation style detection and preservation: when only whitespace differs, each replacement line takes the indentation of the line it replaces
112+
- Preserves the file's line endings (LF or CRLF)
106113
- Git-style diff output with context
107114
- Preview changes with dry run mode
108115
- Inputs:

0 commit comments

Comments
 (0)