DirectoryResource listing uses OS path separators and unstable order
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 86/100
Hướng nghiên cứu
Bắt đầu từ mcp.server.mcpserver.resources.DirectoryResource.read() và xem xét việc tái hiện trên Windows trong issue, cùng với bản sửa lỗi đã được kiểm thử được liên kết từ báo cáo. Hoàn thành có nghĩa là các danh sách đệ quy sử dụng / làm dấu phân cách và có thứ tự được sắp xếp ổn định trên mọi nền tảng, với các bài kiểm thử bao quát hành vi này.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 24.4k
- Fork
- 4k
- Merge trung bình
- 2 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 19
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelcontextprotocol/python-sdk
-
P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
modelcontextprotocol/python-sdk#3597 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
v1 v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
modelcontextprotocol/python-sdk#3592 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
modelcontextprotocol/python-sdk#3590 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
v1 v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
modelcontextprotocol/python-sdk#3585 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
v1 v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
modelcontextprotocol/python-sdk#3578 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của modelcontextprotocol/python-sdk
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
letsencrypt/cp-cps#353 ·
-
Marble Madness II is missingĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
PedestrianDynamics/pyFDS-Evac#394 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
DOI-USGS/pywatershed#421 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
python-pillow/Pillow#10087 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày