modelcontextprotocol / modelcontextprotocol/servers

Make filesystem directory-tree output ordering deterministic

Open
#3,539 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
90.5k
Forks
11.7k
Avg merge
2d 2h
Merged PRs (30d)
5

Description

Problem

Directory tree responses can vary by host filesystem enumeration order, causing unstable output for the same directory across runs.

Why now

The filesystem server is a reference implementation; deterministic output is required for reproducible comparisons and contract tests.

Expected behavior

For the same directory contents and exclude patterns, directory_tree should return a stable ordering across repeated runs and platforms.

Claim-to-codepath map

  • src/filesystem/index.ts
  • src/filesystem/lib.ts
  • src/filesystem/__tests__/directory-tree.test.ts
  • src/filesystem/__tests__/structured-content.test.ts

Validation requirements

  • Enforce deterministic sorting in recursive tree traversal.
  • Add test assertions for stable sibling ordering and nested ordering.
  • Run filesystem package tests.

Evidence packet

  • Commit under test: $(git -C /Users/davidahmann/Projects/agent-ecosystem/mcp-servers rev-parse HEAD)
  • Runtime: Node.js + vitest on macOS
  • Minimal repro: call directory_tree multiple times over same fixture and compare ordering of siblings.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/filesystem/index.ts and src/filesystem/lib.ts to trace directory_tree's recursive traversal and current filesystem enumeration. Review directory-tree.test.ts and structured-content.test.ts, then run the filesystem package tests. Done means repeated calls over the same fixture produce stable sibling and nested ordering across the stated cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
backend, testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.