Skip to content

feat: Add compare_directories tool for directory comparison#3890

Open
nagual2 wants to merge 7 commits intomodelcontextprotocol:mainfrom
nagual2:feature/compare-directories
Open

feat: Add compare_directories tool for directory comparison#3890
nagual2 wants to merge 7 commits intomodelcontextprotocol:mainfrom
nagual2:feature/compare-directories

Conversation

@nagual2
Copy link
Copy Markdown

@nagual2 nagual2 commented Apr 10, 2026

Summary

Adds compare_directories tool to filesystem MCP server for comparing two directory structures.

New Tool: compare_directories

Compares two directories and returns:

  • onlyInDir1: Files only in first directory
  • onlyInDir2: Files only in second directory
  • differentContent: Files with different size/mtime
  • identical: Identical files

Changes

  • src/filesystem/lib.ts - Added compareDirectories() function
  • src/filesystem/index.ts - Registered tool
  • src/filesystem/__tests__/lib.test.ts - Added 6 tests

Tests

✅ Files unique to each directory
✅ Content difference detection
✅ Identical file identification
✅ Empty directory handling
✅ Nested structures

All tests pass with npm test.

Copy link
Copy Markdown
Member

@olaservo olaservo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. A couple of implementation issues and a scope question:

Implementation issues:

  1. The compareContent parameter is accepted in the schema and function signature but never used — comparison always uses size/mtime regardless of the flag. Either implement content comparison or remove the parameter.
  2. Files with identical content but different timestamps will be reported as "different," and files with different content but the same size/mtime will be reported as "identical." This should at least be documented clearly, or addressed with actual content hashing when compareContent is true.

Scope question:
Per our CONTRIBUTING.md, we're selective about new features that aren't core to a server's purpose. Directory comparison feels like it could be composed by an LLM using existing tools (directory_tree, read_file), or handled by a dedicated server. Would you consider publishing this as a standalone MCP server on the Registry instead?


This review was assisted by Claude Code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants