Intelligent file organization MCP server for Claude with security-hardened operations, auto-categorization, and duplicate detection
npm install file-organizer-mcpVersion: 3.1.5 | MCP Protocol: 2024-11-05 | Node: ā„18.0.0
Why Us ⢠Quick Start ⢠Features ⢠Tools ⢠Examples ⢠API ⢠Security ⢠Architecture
---






> A powerful, security-hardened Model Context Protocol (MCP) server for intelligent file organization with Claude
---
Traditional filesystem MCP servers provide primitive tools: read, write, make, delete. When you ask an AI to organize a folder using only these tools, the AI must:
1. Think 50 steps ahead - Planning file moves, renames, and categorizations
2. Waste tokens - Describing every single file operation in detail
3. Risk hallucinations - More steps = more chances for the AI to make mistakes
4. Move slowly - Each primitive operation requires separate reasoning
We provide specialized, high-level tools that encapsulate complex file operations:
| Primitive Approach | File Organizer MCP |
| ------------------------------------------------------ | ---------------------------------------------------- |
| read ā analyze ā read ā write ā rename ā ... | organize_files() - one tool, complete organization |
| 50+ reasoning steps | 1 reasoning step |
| High token usage | Minimal tokens |
| Error-prone | Atomic, rollback-safe operations |
The AI simply decides _what_ to do. We handle _how_ to do it securely.
šÆ Install from MCP Registry ⢠š¦ View on NPM ⢠š Report Issues
---
Just run this single command and follow the interactive prompts:
``bash`
npx file-organizer-mcp --setup
That's it! The wizard will:
- ā
Auto-detect your installed AI clients (Claude Desktop, Cursor, Windsurf, Cline, etc.)
- ā
Configure them automatically with one click
- ā
Let you choose which folders to organize
- ā
Set up your preferences
- Node.js 18+ (only requirement!)
1. Install - Run the command above
2. Select clients - Pick which AI apps you want to use (Claude, Cursor, etc.)
3. Choose folders - Select Downloads, Desktop, Documents, etc.
4. Done! - Start chatting with your AI about files
Try these commands in your AI client:
- "Organize my Downloads folder""Find duplicate files in my Documents"
- "Show me my largest files"
-
The setup wizard auto-detects and configures:
| Client | Platform | Auto-Config |
| ---------------------- | ------------------- | ----------- |
| Claude Desktop | Windows, Mac | ā
Yes |
| Cursor | Windows, Mac, Linux | ā
Yes |
| Windsurf | Windows, Mac | ā
Yes |
| Cline (VS Code) | All platforms | ā
Yes |
| Roo Code (VS Code) | All platforms | ā
Yes |
| Continue (VS Code) | All platforms | ā
Yes |
> š” Don't see your client? The file organizer works with any MCP-compatible client. Check your client's documentation for manual configuration.
---
- š¤ Auto-categorization - Intelligently organizes files into 12+ categories
- š
Smart Scheduling - Cron-based automatic organization with per-directory configuration
- š Duplicate Detection - Finds duplicate files using SHA-256 content hashing
- š·ļø Smart Metadata - Extracts EXIF/ID3 tags for content-aware organization
- āļø Batch Renaming - Flexible renaming with patterns, regex, and case conversion
- š”ļø Smart Conflict Resolution - Handles filename conflicts (rename/skip/overwrite)
- šļø Dry Run Mode - Preview changes before executing
- š File Watching - Watch directories and auto-organize on schedule
- ā±ļø Age-Based Filtering - Skip files newer than X minutes (prevents organizing in-progress downloads)
- š Comprehensive Scanning - Detailed directory analysis with statistics
- š Space Analysis - Quickly identify space-consuming files
- ā®ļø Rollback Support - Undo file organization operations
- āļø Safe Atomic Moves - Uses COPYFILE_EXCL to prevent race conditions during file moves.file-organizer-backups
- š¾ Automatic Backups - Safely backs up files before overwriting to
- š Structured Logging - JSON-formatted logs with configurable log levels
- š Audit Trail - Complete logging of all operations for transparency
- š» Multi-Platform Support - Native support for Windows, macOS, and Linux
This server implements a multi-layered security architecture designed to operate safely in untrusted environments.
- TOCTOU Mitigation: Critical file operations uses File Descriptors (fs.open with O_NOFOLLOW) to prevent Time-of-Check-Time-of-Use race conditions.%2e%2e
- Path Traversal Protection:
- Robust canonicalization handling URI encodings (), null bytes, and Unicode normalization.
- Strict sandboxing ensuring operations stay within allowed directories.
- Input Sanitization:
- All category names and inputs are sanitized to prevent XSS, Command Injection, and Path Injection.
- ReDoS protection on regex inputs.
- DoS Prevention:
- Timeouts on deep scanning and unique file analysis.
- Maximum file count and depth limits.
- Strict Validation:
- Windows Reserved Names (CON, NUL, etc.) are blocked.
- Symbolic links are strictly managed or blocked in critical paths.
- Race Conditions on Deletion: While read/write operations are secured via File Descriptors, file deletion on some platforms (Windows) relies on path locking, which reduces but may not entirely eliminate deletion race windows.
- Symlinks: Symlinks are generally blocked from being opened as files to prevent security issues.
- Windows: Requires standard user permissions. Admin privileges are not recommended or supported.
- Race Condition Mitigation: Uses atomic copy-then-delete strategy to prevent data loss if a file is modified during a move operation.
- Safe Overwrites: When conflict_strategy: 'overwrite' is used, the existing file is moved to a timestamped backup folder before replacement.
Run npx file-organizer-mcp --setup for guided configuration:
- š Folder Selection - Interactively choose folders to manage
- ā” Conflict Handling - Set default rename/skip/overwrite strategy
- š
Schedule Setup - Configure automatic organization schedules
- š¤ Claude Integration - Auto-generates claude_desktop_config.json
New Features:
- š§ Interactive Setup Wizard - Run npx file-organizer-mcp --setup for guided configurationfile_organizer_watch_directory
- š
Smart Scheduling - Cron-based watch mode with
- ā±ļø Age Filtering - Skip recently modified files during auto-organization
- šµ Smart Metadata - Organize images by Year/Month and audio by Artist/Album
- š·ļø Batch Renaming - Bulk renaming with patterns, regex, and numbering
- āļø Conflict Strategy - Configurable default conflict resolution
- š”ļø Enhanced Security - Improved symlink detection and path validation
See CHANGELOG.md for full details.
- Fixed test coverage and added 57 new test cases
- Improved duplicate detection accuracy
- Enhanced file categorization logic
- Better handling of special characters in filenames
- Improved error messages for permission denied scenarios
---
#### file_organizer_scan_directory
Scan directory with detailed file information including size, dates, and extensions.
Parameters:
- directory (string, required) - Full path to directoryinclude_subdirs
- (boolean, optional) - Include subdirectories (default: false)max_depth
- (number, optional) - Maximum depth (default: -1, max: 10)limit
- (number, optional) - Max files per page (default: 100, max: 1000)offset
- (number, optional) - Pagination offset (default: 0)response_format
- ('json'|'markdown', optional) - Output format (default: 'markdown')
Annotations: ā Read-only ⢠┠Idempotent ⢠š Filesystem access
Example:
`typescript`
file_organizer_scan_directory({
directory: '/Users/john/Downloads',
include_subdirs: true,
max_depth: 3,
limit: 100,
});
---
#### file_organizer_list_files
List all files in a directory with basic information. Simple, fast listing.
Parameters:
- directory (string, required) - Full path to directoryresponse_format
- ('json'|'markdown', optional) - Output format
Annotations: ā Read-only ⢠┠Idempotent
---
#### file_organizer_categorize_by_type
Group files by category with statistics. Shows breakdown by file type.
Parameters:
- directory (string, required) - Full path to directoryinclude_subdirs
- (boolean, optional) - Include subdirectoriesresponse_format
- ('json'|'markdown', optional) - Output format
Returns: Category breakdown with file counts and sizes
Example:
`typescript`
file_organizer_categorize_by_type({
directory: '/Users/john/Downloads',
});
// Output:
// Executables - 12 files (45 MB)
// Videos - 24 files (2.3 GB)
// Documents - 89 files (234 MB)
---
#### file_organizer_find_largest_files
Find the largest space-consuming files in a directory.
Parameters:
- directory (string, required) - Full path to directoryinclude_subdirs
- (boolean, optional) - Include subdirectoriestop_n
- (number, optional) - Number of files to return (default: 10)response_format
- ('json'|'markdown', optional) - Output format
Use Cases: Space cleanup, identifying large downloads, finding old backups
---
#### file_organizer_find_duplicate_files
Find duplicate files using SHA-256 content hashing.
Parameters:
- directory (string, required) - Full path to directoryresponse_format
- ('json'|'markdown', optional) - Output format
Returns: Duplicate groups with wasted space calculation
Note: Files larger than 100MB are skipped (security limit)
---
#### file_organizer_analyze_duplicates
Advanced duplicate analysis with keep/delete suggestions based on location, name quality, and age.
Parameters:
- directory (string, required) - Full path to directoryresponse_format
- ('json'|'markdown', optional) - Output format
Returns: Duplicate groups with intelligent recommendations
---
#### file_organizer_preview_organization
Preview file organization WITHOUT making changes. Shows planned moves, conflicts, and reasons.
Parameters:
- directory (string, required) - Full path to directoryconflict_strategy
- ('rename'|'skip'|'overwrite'|'overwrite_if_newer', optional) - Conflict resolution (default: 'rename')
Annotations: ā Read-only ⢠š Dry-run
Example:
`typescript`
file_organizer_preview_organization({
directory: '/Users/john/Downloads',
conflict_strategy: 'rename',
});
---
#### file_organizer_organize_files
Automatically organize files into categorized folders.
Parameters:
- directory (string, required) - Full path to directorydry_run
- (boolean, optional) - Preview without moving (default: true)conflict_strategy
- ('rename'|'skip'|'overwrite'|'overwrite_if_newer', optional) - How to handle conflictsresponse_format
- ('json'|'markdown', optional) - Output format
Returns: Organization summary with actions taken and errors
ā ļø Modifies filesystem - Use dry_run: true first!
Example:
`typescript
// Preview first
file_organizer_organize_files({
directory: '/Users/john/Downloads',
dry_run: true,
});
// Then execute
file_organizer_organize_files({
directory: '/Users/john/Downloads',
dry_run: false,
});
`
---
#### file_organizer_undo_last_operation
Reverse file moves and renames from a previous organization.
Parameters:
- directory (string, required) - Full path to directoryresponse_format
- ('json'|'markdown', optional) - Output format
Returns: Rollback results with success/failure counts
---
#### file_organizer_batch_rename
Batch rename files using pattern matching, case conversion, or sequence numbering.
Parameters:
- directory (string, optional) - Directory to scan (either this or files required)files
- (array, optional) - Specific files to renamerules
- (array, required) - Renaming rules:type
- : 'find_replace' | 'case' | 'add_text' | 'numbering'dry_run
- _...plus rule-specific options (replace, with, conversion, text, position, etc.)_
- (boolean, optional) - Preview only (default: true)
Annotations: ā ļø Destructive (if dry_run=false) ⢠š Dry-run
Example:
`typescript`
file_organizer_batch_rename({
directory: '/Docs',
rules: [
{ type: 'find_replace', find: 'IMG', replace: 'Photo' },
{ type: 'case', conversion: 'lowercase' },
],
dry_run: true,
});
---
#### file_organizer_watch_directory
Add a directory to the automatic organization watch list with cron-based scheduling.
Files will be automatically organized based on the schedule you set.
Parameters:
- directory (string, required) - Full path to the directory to watchschedule
- (string, required) - Cron expression (e.g., "0 10 *" for daily at 10am)auto_organize
- (boolean, optional) - Enable auto-organization (default: true)min_file_age_minutes
- (number, optional) - Only organize files older than X minutesmax_files_per_run
- (number, optional) - Maximum files to process per runresponse_format
- ('json'|'markdown', optional) - Output format
Cron Expression Examples:
| Expression | Schedule |
| -------------- | ---------------------------- |
| 0 10 * | Daily at 10:00 AM |/30 *
| | Every 30 minutes |0 /6
| | Every 6 hours |0 9 1
| | Every Monday at 9:00 AM |0 0 0
| | Weekly on Sunday at midnight |
Example:
`typescript`
// Watch Downloads folder - organize daily at 9am, files must be 5+ minutes old
file_organizer_watch_directory({
directory: '/Users/john/Downloads',
schedule: '0 9 *',
min_file_age_minutes: 5,
max_files_per_run: 100,
});
---
#### file_organizer_unwatch_directory
Remove a directory from the watch list.
Parameters:
- directory (string, required) - Full path to remove from watch listresponse_format
- ('json'|'markdown', optional) - Output format
---
#### file_organizer_list_watches
List all directories currently being watched with their schedules.
Parameters:
- response_format ('json'|'markdown', optional) - Output format
Returns: List of watched directories with schedules and rules
---
#### file_organizer_get_categories
Returns the list of categories used for file organization.
Parameters: None
Returns: List of all file categories and their extensions
---
#### file_organizer_set_custom_rules
Customize how files are categorized. Rules persist for the current session.
Parameters:
- rules (array, required) - Array of rule objects, each containing:category
- (string, required) - Target category nameextensions
- (array of strings, optional) - File extensions to matchfilename_pattern
- (string, optional) - Glob pattern to match filenamespriority
- (number, optional) - Rule priority (lower = higher priority)
Example:
`typescript`
file_organizer_set_custom_rules({
rules: [
{ category: 'Tax Docs', extensions: ['.pdf'], filename_pattern: 'tax', priority: 1 },
{
category: 'Receipts',
extensions: ['.pdf', '.png'],
filename_pattern: 'receipt',
priority: 2,
},
],
});
---
#### file_organizer_delete_duplicates
Permanently delete specified duplicate files. This operation is destructive and cannot be undone.
Parameters:
- files_to_delete (array of strings, required) - Full paths of duplicate files to removeverify_duplicates
- (boolean, optional) - Re-verify files are duplicates before deleting (default: true)create_backup_manifest
- (boolean, optional) - Save a manifest of deleted files for reference (default: true)response_format
- ('json'|'markdown', optional) - Output format
ā ļø Destructive - Always run file_organizer_analyze_duplicates first and review recommendations before using.
---
Files are automatically sorted into these categories:
| Category | Extensions |
| ----------------- | ------------------------------------------------------------------------------------------ |
| Executables | .exe, .msi, .bat, .cmd, .sh |.mp4
| Videos | , .avi, .mkv, .mov, .wmv, .flv, .webm, .m4v |.pdf
| Documents | , .doc, .docx, .txt, .rtf, .odt, .md, .tex |.ppt
| Presentations | , .pptx, .odp, .key |.xls
| Spreadsheets | , .xlsx, .csv, .ods |.jpg
| Images | , .jpeg, .png, .gif, .bmp, .svg, .ico, .webp |.mp3
| Audio | , .wav, .flac, .aac, .ogg, .wma, .m4a |.zip
| Archives | , .rar, .7z, .tar, .gz, .bz2, .xz |.py
| Code | , .js, .ts, .java, .cpp, .c, .html, .css, .php, .rb, .go, .json |test
| Tests | , spec, .test.ts, .spec.ts |debug
| Logs | , *.log |script
| Scripts | , .sh, .bat |.dmg
| Installers | , .pkg, .deb, .rpm, .apk |.epub
| Ebooks | , .mobi, .azw, .azw3 |.ttf
| Fonts | , .otf, .woff, .woff2 |
| Others | Everything else |
---
`
User: "Claude, help me clean up my Downloads folder at C:/Users/[YOUR_USERNAME]/Downloads"
Claude follows these steps:
1. Scans directory ā Shows 1,247 files, 15.3 GB
2. Categorizes files ā Videos: 234 (8.2 GB), Documents: 567 (2.1 GB)
3. Finds duplicates ā Found 45 duplicate groups, wasted 2.3 GB
4. Shows largest files ā old_backup.zip: 5.2 GB
5. Previews organization ā Shows planned moves and conflicts
6. Asks for confirmation
7. Organizes files ā ā
Organized 1,247 files into 8 category folders
Result: Clean, organized Downloads folder with duplicates identified
`
---
`
User: "Claude, organize my project folder at ~/myproject"
Claude:
1. Scans the project ā 423 files across multiple subdirectories
2. Identifies file types ā Code (289), Assets (87), Docs (47)
3. Suggestions organization ā Preserves src/ structure, organizes root files
4. Previews changes ā Shows (47) items to organize
5. Executes ā Moves config files, readmes, screenshots to proper folders
Result: Clean project structure with organized documentation and assets
`
---
`
User: "Claude, find and analyze duplicates in C:/Users/[YOUR_USERNAME]/Documents"
Claude:
1. Scans for duplicates ā Finds 23 duplicate groups
2. Analyzes each group ā Scores files by location, name quality, age
3. Suggests which to keep ā Keeps "/Documents/Important/file.pdf"
4. Suggests which to delete ā Delete "/Downloads/file (1).pdf"
5. Shows wasted space ā Total: 1.8 GB can be reclaimed
User can manually delete or ask Claude to organize to remove duplicates
`
---
`
User: "Claude, show me the 20 largest files taking up space in my Downloads folder"
Claude:
1. Analyzes directory size ā Total: 45.2 GB
2. Finds largest files:
- old_backup_2023.zip: 12.3 GB (2 years old)
- movie_collection.mkv: 8.7 GB
- presentation_final.pptx: 890 MB
3. Suggests cleanup ā Archive or delete old backups
4. Shows duplicates in large files ā Some large files have copies
Result: Clear visibility into space usage with actionable insights
`
---
`
User: "Claude, automatically organize my Downloads folder every day at 9am"
Claude:
1. Sets up watch directory ā
file_organizer_watch_directory({
directory: "/Users/john/Downloads",
schedule: "0 9 *",
min_file_age_minutes: 5
})
2. Confirms setup ā "Downloads folder will be organized daily at 9:00 AM"
3. Shows current watches ā Lists all watched directories
User: "Also watch my Desktop folder every hour"
Claude:
4. Adds second watch ā
file_organizer_watch_directory({
directory: "/Users/john/Desktop",
schedule: "0 ",
max_files_per_run: 50
})
Result: Automatic background organization with smart scheduling
`
---
The server uses a Secure by Default approach. Access is restricted to a specific whitelist of user directories. All system directories are blacklisted.
The server automatically detects and allows access to these safe user locations:
| Platform | Allowed Directories |
| ----------- | ------------------------------------------------------------------------------------------------------- |
| Windows | Desktop, Documents, Downloads, Pictures, Videos, Music, OneDrive, Projects, Workspace |Desktop
| macOS | , Documents, Downloads, Movies, Music, Pictures, iCloud Drive, Projects |Desktop
| Linux | , Documents, Downloads, Music, Pictures, Videos, ~/dev, ~/workspace |
_> Note: Only directories that actually exist on your system are enabled._
To prevent accidents, the following are always blocked, even if added to config:
- Windows: C:\Windows, Program Files, AppData, $Recycle.Bin/System
- macOS: , /Library, /Applications, /private, /usr/etc
- Linux: , /usr, /var, /root, /sys, /procnode_modules
- Global: , .git, .vscode, .idea, dist, build
You can customize behavior by editing the user configuration file.
Config Location:
- Windows: %APPDATA%\file-organizer-mcp\config.json$HOME/Library/Application Support/file-organizer-mcp/config.json
- macOS: $HOME/.config/file-organizer-mcp/config.json
- Linux:
How to Add Directories:
1. Open config.jsoncustomAllowedDirectories
2. Add paths to :
`json`
{
"customAllowedDirectories": ["C:\\Users\\Name\\My Special Folder", "D:\\Backups"]
}
> š” Tip: You can copy a folder path directly from your file explorer's address bar and paste it into customAllowedDirectories.
3. Restart Claude Desktop.
Set your preferred default conflict resolution strategy:
`json`
{
"conflictStrategy": "rename"
}
Available strategies:
- "rename" (default) - Renames new file (e.g., file (1).txt)"skip"
- - Keeps existing file, skips new one"overwrite"
- - Replaces existing file (creates backup first)
Simple schedule configuration (for basic hourly/daily/weekly):
`json`
{
"autoOrganize": {
"enabled": true,
"schedule": "daily"
}
}
For advanced cron-based scheduling, use the file_organizer_watch_directory tool.
| Attack Type | Protection Mechanism | Status |
| ----------------------- | ------------------------------------ | ------------ |
| Unauthorized Access | Whitelist + Blacklist Enforcement | ā
Protected |
| Path Traversal | 8-Layer Validation Pipeline | ā
Protected |
| Symlink Attacks | Real Path Resolution | ā
Protected |
| DoS | Resource Limits (Files, Depth, Size) | ā
Protected |
---
1. ā
Check config file path is correct
2. ā
Verify Node.js v18+ is installed: node --versionclaude_desktop_config.json
3. ā
Restart Claude Desktop completely
4. ā
Check path in is correct
1. ā
Windows: Run Claude Desktop as Administrator
2. ā
Mac/Linux: Check folder permissions: ls -la
3. ā
Ensure write permissions in target directory
1. ā
Verify dry_run mode is NOT enabled
2. ā
Check files aren't locked by other programs
3. ā
Ensure sufficient disk space
4. ā
Review error messages in operation summary
---
- ā ļø Organizes files in root directory only, not subdirectories (by default)
- ā ļø Existing category folders won't be reorganized (prevents loops)
- ā
File extensions are case-insensitive
- ā
Original modification dates are preserved
- ā
Hidden files (starting with .) are automatically skipped
- ā
Maximum 10,000 files processed per operation (security limit)
- ā
Maximum 10 directory levels scanned (security limit)
- ā
Rollback support for undo operations
---
Contributions are welcome! Please read CONTRIBUTING.md for guidelines.
`bash``
git clone https://github.com/kridaydave/File-Organizer-MCP.git
cd File-Organizer-MCP
npm install
npm run build
npm test
šØ Security vulnerabilities: Email technocratix902@gmail.com
š Bugs/features: GitHub Issues
---
- API.md - Complete tool reference
- ARCHITECTURE.md - Technical architecture and design patterns
- CONTRIBUTING.md - Contribution guidelines
- MIGRATION.md - v2 to v3 upgrade guide
- CHANGELOG.md - Version history
---
MIT License - see LICENSE file for details
---
- Anthropic - For the Model Context Protocol specification
- NetworkChuck - For the MCP tutorial that inspired this project
- The MCP Community - For feedback and support
---
- MCP Registry: View Listing
- NPM Package: View on NPM
- Issues: GitHub Issues
- MCP Spec: Model Context Protocol
---
> _Built with ā¤ļø for the MCP community_