Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

filesystem: expandHome() does not handle Windows backslash separator (~\path)

オープン 初心者向け
#5,180 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@BOHAOYUAN がすでに取り組んでいます。

2026年10月20日 から。

  • #1 @BOHAOYUAN による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
node.js, typescript
領域
backend

調査の方向性

チルダ展開のチェックが示されている src/filesystem/path-utils.ts と src/filesystem/roots-utils.ts を読みます。~/ と ~\ のパスがどのように処理されるかを比較し、expandHome とルートパスの展開をカバーするテストを探します。Windows のバックスラッシュ付きチルダパスがホームディレクトリに展開され、既存のケースも引き続き動作すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug server-filesystem v2
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
  1. Run @modelcontextprotocol/server-filesystem on Windows.
  2. Supply an allowed directory argument or path with native Windows backslash tilde notation, e.g., ~\projects or ~\Documents\notes.txt.
  3. expandHome in src/filesystem/path-utils.ts executes:
    export function expandHome(filepath: string): string {
        if (filepath.startsWith("~/") || filepath === "~") {
            return path.join(os.homedir(), filepath.slice(1));
        }
        return filepath;
    }
    
    And similarly in 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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

modelcontextprotocol/servers のほかの issue

modelcontextprotocol/servers の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。