Skip to content

fix(filesystem): support cross-device moves - #4720

Open
Excelius-Wang wants to merge 1 commit into
modelcontextprotocol:mainfrom
Excelius-Wang:fix/filesystem-cross-device-move
Open

fix(filesystem): support cross-device moves#4720
Excelius-Wang wants to merge 1 commit into
modelcontextprotocol:mainfrom
Excelius-Wang:fix/filesystem-cross-device-move

Conversation

@Excelius-Wang

Copy link
Copy Markdown

Description

Fall back to a staged copy-and-remove operation when move_file encounters an EXDEV cross-device rename error.

Server Details

  • Server: filesystem
  • Changes to: move_file tool

Motivation and Context

fs.rename cannot move files or directories across filesystem boundaries. This commonly occurs between container volumes, network mounts, and local disks.

The fallback copies the source to a randomized temporary path beside the destination, renames the completed copy into place, and removes the source only after finalization. Failed copies are cleaned up without exposing a partial destination.

Relative symbolic links, timestamps, permissions, and the existing no-overwrite behavior are preserved.

How Has This Been Tested?

  • npm test — 174 passed
  • npm run build
  • 62 focused move and filesystem tests
  • Real cross-device move between /tmp and /dev/shm
  • Verified directory and file permissions
  • Verified relative symbolic links
  • Verified cleanup and source retention after copy failure
  • Verified non-EXDEV errors do not trigger the fallback
  • Verified final rename failures clean the staged copy

Breaking Changes

None. Same-filesystem moves continue to use the existing rename path.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • My changes follow MCP security best practices
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • No README, environment variable, or client configuration changes are required

Copilot AI balanced review requested due to automatic review settings August 30, 2026 09:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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