Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

DirectoryResource listing uses OS path separators and unstable order

Offen Anfängerfreundlich
#3,589 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
86/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
python
Bereich
backend

Rechercherichtung

Beginne bei mcp.server.mcpserver.resources.DirectoryResource.read() und prüfe die Windows-Reproduktion im Issue zusammen mit dem getesteten Fix, der im Bericht verlinkt ist. Die Aufgabe ist erledigt, wenn rekursive Auflistungen plattformübergreifend / als Trennzeichen und eine stabile sortierte Reihenfolge verwenden und Tests dieses Verhalten abdecken.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

v1 v2
Initial Checks
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
Vorherrschende Sprache
Python
Sterne
24.3k
Forks
4k
Ø Merge
1 T. 7 Std.
Gemergte PRs (30 T.)
18

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus modelcontextprotocol/python-sdk

Alle Issues in modelcontextprotocol/python-sdk

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.