Skip to content

feat(filesystem): add compare_files tool for file diff comparison - #4024

Closed
factspark23-hash wants to merge 1 commit into
modelcontextprotocol:mainfrom
factspark23-hash:feat/compare-files
Closed

factspark23-hash wants to merge 1 commit into
modelcontextprotocol:mainfrom
factspark23-hash:feat/compare-files

Conversation

@factspark23-hash

Copy link
Copy Markdown

What

Add a new compare_files tool that compares two files and returns a unified diff.

Why

Currently there is no way to compare two files through MCP. Users often need to:

  • Verify an edit was applied correctly
  • Understand differences between file versions
  • Review changes before committing

Without this tool, agents must read both files entirely and manually diff them, which is inefficient and error-prone.

How

compare_files({
  file1: "path/to/original.ts",
  file2: "path/to/modified.ts",
  contextLines: 3  // optional, default 3
})

Returns unified diff output, or reports files as identical.

Changes

  • src/filesystem/index.ts:
    • Added CompareFilesArgsSchema with file1, file2, contextLines params
    • Registered compare_files tool using existing createUnifiedDiff from lib.ts
    • Both files must be within allowed directories

New tool that compares two files and returns a unified diff output.
- Shows exactly what changed between two files
- Configurable context lines (default: 3)
- Reports when files are identical
- Uses existing createUnifiedDiff utility
- Both files must be within allowed directories

Useful for code review, change verification, and understanding
differences between file versions.

@LuuOW LuuOW left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Technical audit: Verified MCP server implementation for consistency with current SDK patterns.

@cliffhall cliffhall added the closed-out-of-scope Closed: out of scope here; listings and new servers go to the MCP Registry (#4875) label Oct 20, 2026
@cliffhall

Copy link
Copy Markdown
Member

Thank you for this pull request, and apologies for the long wait for a response.

These servers are reference implementations: they exist to show how each part of MCP is used, not to be general-purpose products, so new features are taken selectively, and this change isn't one the maintainers plan to take. This repository also now accepts issues, not pull requests, from anyone but its maintainers; the policy is in CONTRIBUTING.md.

This is not a judgment on the idea or on you. A server in the MCP Registry may well offer it, and anyone is welcome to build on these servers to do so. If you think we've misread it, please open an issue describing the problem and the expected behavior.

This is part of the backlog triage in #4875.

@cliffhall cliffhall closed this Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

closed-out-of-scope Closed: out of scope here; listings and new servers go to the MCP Registry (#4875)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants