DirectoryResource listing uses OS path separators and unstable order
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
mcp.server.mcpserver.resources.DirectoryResource.read() から始め、issue にある Windows での再現手順と、レポートからリンクされているテスト済みの修正を確認します。再帰的な一覧が / を区切り文字として使用し、すべてのプラットフォームで安定したソート順になることをテストでカバーできれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Initial Checks
- I confirm that I'm using the newest release of my line (the latest 2.x, or the latest 1.x if I'm still on v1)
- I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue
Release line
2.x (current stable)
Description
What happened
DirectoryResource.read() returns str(path.relative_to(...)), so on Windows a
recursive listing contains sub\c.txt, while Linux/macOS return sub/c.txt.
The file order also follows glob(), which depends on the filesystem, so the
same directory can produce a different JSON listing on different machines.
Expected
Resource content is sent to clients, so the listing should be the same on every
platform: / separators and a stable (sorted) order.
Reproduce (on Windows)
import anyio, tempfile
from pathlib import Path
from mcp.server.mcpserver.resources import DirectoryResource
root = Path(tempfile.mkdtemp())
(root / "sub").mkdir()
(root / "sub" / "c.txt").write_text("c", encoding="utf-8")
r = DirectoryResource(uri="dir://x", name="x", path=root, recursive=True)
print(anyio.run(r.read)) # {"files": ["sub\\c.txt"]}
Possible fix
Use Path.as_posix() and sorted(...) in read(). I have a tested fix with
tests on my fork: https://github.com/tasnemawawde-afk/python-sdk/commit/06f76b5c8458cc847425c707a4d75d67ed814c6b
Happy to open a PR if a maintainer wants one.
(I used Claude to help find and write this fix; I reviewed it and ran the tests myself.)
Example Code
Python & MCP Python SDK
Python 3.14.7, Windows 11
MCP Python SDK: main branch at commit f1b6589
- 主要言語
- Python
- スター
- 24.4k
- フォーク
- 4k
- 平均マージ
- 1日 7時間
- マージ済み PR(30日)
- 18
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelcontextprotocol/python-sdk のほかの issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
modelcontextprotocol/python-sdk#3590 ·
メンテナーはふだん 1 日以内に返信
-
v1 v2
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
modelcontextprotocol/python-sdk#3585 ·
メンテナーはふだん 1 日以内に返信
-
v1 v2
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
modelcontextprotocol/python-sdk#3578 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
v1 v2
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
modelcontextprotocol/python-sdk#3573 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
v2
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
modelcontextprotocol/python-sdk#3566 ·
メンテナーはふだん 1 日以内に返信
modelcontextprotocol/python-sdk の issue をすべて見る
似ている issue
-
ACK_WAITING HELP_WANTED UPDATE_CS
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
OWASP/CheatSheetSeries#2458 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
BasedHardware/omi#19711 ·
メンテナーはふだん 1 日以内に返信
-
Qwen3_5MoeModel no longer returns router_logits, breaking aux loss with output_router_logits=Trueオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
huggingface/transformers#49172 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
vllm-project/vllm-metal#885 ·
メンテナーはふだん 1 日以内に返信