filesystem: expandHome() does not handle Windows backslash separator (~\path)
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 76/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- node.js, typescript
- 領域
- backend
調査の方向性
チルダ展開のチェックが示されている src/filesystem/path-utils.ts と src/filesystem/roots-utils.ts を読みます。~/ と ~\ のパスがどのように処理されるかを比較し、expandHome とルートパスの展開をカバーするテストを探します。Windows のバックスラッシュ付きチルダパスがホームディレクトリに展開され、既存のケースも引き続き動作すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Which server?
filesystem (@modelcontextprotocol/server-filesystem)
Server version
latest (v2/main)
How did you run the server?
npx (npm package)
Transport
stdio
Protocol era
Modern (2026-07-28)
MCP client and version
Claude Desktop / MCP Inspector
Operating system and runtime
Windows 11 / Windows Server, Node.js v20+ / v22+
Server configuration
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "~\\projects"]
}
}
}
Steps to reproduce
- Run
@modelcontextprotocol/server-filesystemon Windows. - Supply an allowed directory argument or path with native Windows backslash tilde notation, e.g.,
~\projectsor~\Documents\notes.txt. expandHomeinsrc/filesystem/path-utils.tsexecutes:
And similarly inexport function expandHome(filepath: string): string { if (filepath.startsWith("~/") || filepath === "~") { return path.join(os.homedir(), filepath.slice(1)); } return filepath; }src/filesystem/roots-utils.ts:if (rawPath.startsWith("~/") || rawPath === "~") { ... }
Expected behavior
On Windows platforms, tilde followed by a backslash (~\) is the natural path separator convention when invoking CLI commands or passing configurations (e.g. ~\workspace). expandHome should recognize both ~/ and ~\ prefixes and expand them to os.homedir().
Actual behavior
Because the condition strictly checks .startsWith("~/"), any path formatted with backslashes (such as ~\projects or ~\\projects) fails to match. expandHome returns the raw string unchanged.
Downstream, path.resolve() interprets ~ as a literal directory name relative to the current working directory (e.g. C:\current\dir\~\projects), causing directory validation to fail with:
Access denied - Path does not exist or is outside allowed directories
Logs or error output
Node.js REPL test:
> const path = require('path');
> const os = require('os');
> function expandHome(p) { if (p.startsWith('~/') || p === '~') return path.join(os.homedir(), p.slice(1)); return p; }
> expandHome('~/test')
'C:\\Users\\User\\test' // OK (POSIX slash)
> expandHome('~\\test')
'~\\test' // Fails to expand Windows backslash
Already prototyped a fix?
Update expandHome in src/filesystem/path-utils.ts and roots-utils.ts to recognize ~\:
export function expandHome(filepath: string): string {
if (filepath === "~" || filepath.startsWith("~/") || filepath.startsWith("~\\")) {
return path.join(os.homedir(), filepath.slice(1));
}
return filepath;
}
Before you submit
- I searched existing issues and this is not a duplicate.
- This is not a security vulnerability report (those go through the private advisory form).
- 主要言語
- TypeScript
- スター
- 91.4k
- フォーク
- 11.8k
- 平均マージ
- 7時間 36分
- マージ済み PR(30日)
- 126
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelcontextprotocol/servers のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
modelcontextprotocol/servers#5216 ·
メンテナーはふだん 1 日以内に返信
-
bug v2
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
modelcontextprotocol/servers#5215 ·
メンテナーはふだん 1 日以内に返信
-
documentation server-git server-time v2
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
modelcontextprotocol/servers#5213 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
documentation v2
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
modelcontextprotocol/servers#5212 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
documentation v2
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
modelcontextprotocol/servers#5211 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
modelcontextprotocol/servers の issue をすべて見る
似ている issue
-
[BUG] rag: sentence content can cross the reported sentence boundaries対応中かも @LJK-ikun が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
bug needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
README: the Resource URI Schemas example's file://documents/* pattern only matches that literal URIオープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
platformatic/mcp#361 ·
メンテナーはふだん 1 日以内に返信
-
frontend
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Push: sem service worker ou sem VAPID, o interruptor de Notificações fica ligado sem avisar nadaオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
melgarafael/DeskcommCRM#3164 ·
メンテナーはふだん 1 日以内に返信