File Organizer MCP
File Organizer MCP 服务器
版本 3.5.0 | MCP 协议 2024-11-05 | Node.js 18+
一个用于整理文件的模型上下文协议(MCP)服务器。它让 Claude 风格的助手通过一个原子操作来分类、排序、去重和重命名文件,而无需将数十次底层的 read、write 和 rename 调用串联起来。
为什么
一个仅基于 read、write、make 和 delete 构建的文件系统 MCP 服务器,会迫使助手将每一步移动和重命名都规划为单独的步骤。每一步都会消耗令牌,而步骤越多,路径出错的可能性就越大。
File Organizer MCP 用一次调用取代了这些链式操作:
原始方法 | File Organizer MCP |
多次 |
|
数十个推理步骤 | 一个推理步骤 |
高令牌消耗 | 极低的令牌消耗 |
部分失败时容易损坏 | 支持回滚的安全操作 |
Related MCP server: MCP Filesystem Agent v3
快速开始
一键设置
npx file-organizer-mcp --setup该向导会检测已安装的 AI 客户端(Claude Desktop、Cursor、Windsurf、Cline 等),完成配置,并引导你选择文件夹和偏好设置。
系统要求
Node.js 18 或更高版本。
设置完成后
你可以向助手提出如下请求:
“整理我的下载文件夹”
“在我的文档中查找重复文件”
“显示我最大的文件”
安装方式
方式 | 命令 | 使用场景 |
npx |
| 偶尔使用或试用 |
全局 |
| 经常使用,启动更快 |
功能特性
支持 12 种或更多文件类型的分类。
基于 cron 的自动整理和目录监视模式。
通过 SHA-256 内容哈希进行重复检测。
元数据提取:照片的 EXIF、音频的 ID3、文档的主题提取。
智能整理,根据文件类型选择正确的策略。
试运行预览、原子移动和回滚。
路径遍历防护、TOCTOU 缓解和元数据擦除。
支持 Windows、macOS 和 Linux。
工具
核心工具
file_organizer_scan_directory- 列出目录及详细文件信息。directory为必填;include_subdirs控制是否递归。file_organizer_read_file- 通过 8 层路径验证读取文件。path为必填;encoding可为 utf-8、base64 或 binary。file_organizer_organize_smart- 一次处理音乐、照片和文档,为每个文件选择最佳策略。file_organizer_batch_rename- 按模式、正则或编号批量重命名文件。file_organizer_undo_last_operation- 撤销最近一次整理操作。
完整工具列表
file_organizer_analyze_duplicatesfile_organizer_batch_read_filesfile_organizer_categorize_by_typefile_organizer_delete_duplicatesfile_organizer_find_duplicate_filesfile_organizer_find_largest_filesfile_organizer_get_categoriesfile_organizer_inspect_metadatafile_organizer_list_filesfile_organizer_list_watchesfile_organizer_organize_by_contentfile_organizer_organize_filesfile_organizer_organize_musicfile_organizer_organize_photosfile_organizer_preview_organizationfile_organizer_read_filefile_organizer_scan_directoryfile_organizer_set_custom_rulesfile_organizer_smart_suggestfile_organizer_system_organizefile_organizer_undo_last_operationfile_organizer_unwatch_directoryfile_organizer_view_historyfile_organizer_watch_directory
有关参数和返回结构,请参阅 API.md。
文件分类
分类 | 常见扩展名 |
可执行文件 |
|
视频 |
|
文档 |
|
图片 |
|
音频 |
|
压缩包 |
|
代码 |
|
示例工作流
清理下载文件夹
扫描文件夹并查看文件分布和空间使用情况。
识别重复文件和过期文件。
预览移动操作和冲突。
确认后,按类别整理到文件夹中。
结果:文件夹已分类,重复文件被标记,空间被释放。
整理项目
助手扫描项目,将文件分为代码、资源和文档,保持 src/ 目录结构不变,并将松散的配置文件、自述文件和截图移动到相应的文件夹中。
查找并处理重复文件
助手对文件进行哈希处理,将重复项分组,根据位置、名称质量和年龄对每个副本进行评分,并建议保留或删除哪些文件。它会报告浪费的空间。由你决定是否删除。
发现大文件
将其指向一个文件夹,它会按大小列出最大的文件,标记可以归档的旧备份,并指出任何大型重复文件。
整理音乐
它会读取 ID3 标签,并将文件夹重建为 艺术家 / 专辑 / 标题.mp3 的结构。
Before:
Downloads/
song1.mp3
track02.mp3
music_file.mp3
After:
Music/
Coldplay/
A Rush of Blood to the Head/
Clocks.mp3
The Scientist.mp3
Radiohead/
OK Computer/
Paranoid Android.mp3
Karma Police.mp3整理照片
它会从 EXIF 中读取拍摄日期,并将照片分类到 YYYY / MM / DD 文件夹中。
Before:
Pictures/
IMG_001.jpg
photo123.png
DSC_4567.raw
After:
Pictures/
2023/
12/
25/
IMG_001.jpg
31/
photo123.png
2024/
01/
15/
DSC_4567.raw安全审查文件夹
它会提取元数据和内容签名,然后标记敏感元数据,例如 PDF 中的 EXIF GPS 坐标或简历中的个人标识符,并建议编辑或隔离。
设置自动整理
使用 cron 计划注册目录:
{
"directory": "/Users/john/Downloads",
"schedule": "0 9 * * *",
"min_file_age_minutes": 5
}服务器将按该计划整理文件夹。为其他目录添加更多监视。
安全配置
默认情况下,访问仅限于用户目录白名单。系统目录保持阻止状态。
默认允许
如果这些位置在计算机上存在,服务器将启用它们:
平台 | 允许的目录 |
Windows | 桌面、文档、下载、图片、视频、音乐、OneDrive、项目、工作区 |
macOS | 桌面、文稿、下载、影片、音乐、图片、iCloud 云盘、项目 |
Linux | 桌面、文档、下载、音乐、图片、视频、 |
始终阻止
即使你将以下路径添加到配置中,它们也保持阻止状态:
Windows:
C:\Windows、Program Files、AppData、$Recycle.BinmacOS:
/System、/Library、/Applications、/private、/usrLinux:
/etc、/usr、/var、/root、/sys、/proc所有平台:
node_modules、.git、.vscode、.idea、dist、build
自定义配置
编辑用户配置文件:
Windows:
%APPDATA%\file-organizer-mcp\config.jsonmacOS:
$HOME/Library/Application Support/file-organizer-mcp/config.jsonLinux:
$HOME/.config/file-organizer-mcp/config.json
将路径添加到 customAllowedDirectories:
{
"customAllowedDirectories": [
"C:\\Users\\Name\\My Special Folder",
"D:\\Backups"
]
}你可以直接从文件资源管理器的地址栏粘贴文件夹路径。
外部驱动器和网络挂载
默认情况下,主目录之外的路径会被阻止,除非你选择启用。要允许外部卷(例如 macOS 上的 /Volumes/My Drive 或 Linux 上的 /media/user/usb),请将 allowExternalVolumes 设置为 true:
{
"allowExternalVolumes": true,
"customAllowedDirectories": [
"/Volumes/MyExternalDrive",
"/Volumes/Photography Backup"
]
}Windows 驱动器号(如 D:\)无需此标志即可使用。
编辑配置后重新启动客户端。
冲突策略
{
"conflictStrategy": "rename"
}rename(默认)- 向新文件追加后缀,例如file (1).txt。skip- 保留现有文件并跳过新文件。overwrite- 在写入备份后替换现有文件。
旧版自动整理计划
对于简单的每小时、每天或每周计划:
{
"autoOrganize": {
"enabled": true,
"schedule": "daily"
}
}如需更精细的计划,请使用 file_organizer_watch_directory 工具。
防御机制
攻击类型 | 保护措施 |
未授权访问 | 白名单加黑名单强制执行 |
路径遍历 | 8 层验证管道 |
符号链接攻击 | 真实路径解析 |
拒绝服务 | 对文件数量、深度和大小的资源限制 |
故障排除
MCP 服务器未出现
检查配置文件路径是否正确。
确认 Node.js 18 或更高版本:
node --version。完全重新启动客户端。
检查客户端配置文件中的路径。
权限错误
Windows:以管理员身份运行客户端。
macOS/Linux:使用
ls -la检查文件夹权限。确认目标目录可写。
文件未移动
确保未启用
dry_run。关闭可能锁定文件的程序。
检查磁盘空间是否充足。
阅读操作摘要中的错误消息。
架构
服务器运行“先筛选后丰富”的管道:MCP 协议处理程序将每个请求传递到安全筛选(路径验证、敏感文件检测、速率限制),然后是元数据丰富(EXIF、ID3、文档属性),最后是执行操作的服务层。所有文件操作都通过验证的路径进行,并支持回滚。
有关完整图表和设计说明,请参阅 ARCHITECTURE.md。
文档
API.md - 完整工具参考
ARCHITECTURE.md - 设计与架构
CONTRIBUTING.md - 贡献指南
MIGRATION.md - v2 到 v3 升级指南
CHANGELOG.md - 版本历史
SECURITY.md - 安全模型与报告
贡献
阅读 CONTRIBUTING.md,然后克隆并构建:
git clone https://github.com/kridaydave/File-Organizer-MCP.git
cd File-Organizer-MCP
npm install
npm run build
npm test请在 GitHub Issues 上报告错误和功能请求。如发现安全漏洞,请发送电子邮件至 technocratix902@gmail.com。
许可证
MIT。请参阅 LICENSE。
Available Tools
26 toolsfile_organizer_analyze_duplicatesAnalyze Duplicate Files with Smart RecommendationsCRead-onlyIdempotent
Finds duplicate files and suggests which to keep/delete based on location, name quality, and age.
Inputs: directory (required), response_format, auto_select_keep, recommendation_strategy.
file_organizer_batch_read_filesBatch Read Files for LLM ContextARead-onlyIdempotent
Reads contents of all files in a specified folder for LLM context. For text files (documents, code, notes), reads the actual content. For media files (audio, video, images), reads metadata instead of binary content. Provides a comprehensive summary of folder contents.
Inputs: directory (required), max_files, file_types, include_content, +4 more.
file_organizer_batch_renameBatch Rename FilesADestructive
Rename multiple files using rules (find/replace, case, add text, numbering). "dry_run" defaults to true for safety.
Inputs: rules (required), files, dry_run, directory, +1 more.
file_organizer_categorize_by_typeCategorize Files by TypeARead-onlyIdempotent
Categorize files by their type (Executables, Videos, Documents, etc.) and show statistics for each category. Enable use_content_analysis to detect file type mismatches and security threats.
Inputs: directory (required), include_subdirs, response_format, use_content_analysis.
file_organizer_delete_duplicatesDelete Duplicate FilesBDestructive
Permanently deletes specified duplicate files. DESTRUCTIVE. Verifies hash/size before deletion.
Inputs: files_to_delete (required), response_format, create_backup_manifest.
file_organizer_find_duplicate_filesFind Duplicate FilesBRead-onlyIdempotent
Find duplicate files in a directory based on their content (SHA-256 hash). Shows potential wasted space.
Inputs: directory (required), limit, offset, response_format.
file_organizer_find_largest_filesFind Largest FilesARead-onlyIdempotent
Find the largest files in a directory. Useful for identifying space-consuming files and cleanup opportunities.
Inputs: directory (required), top_n, include_subdirs, response_format.
file_organizer_get_categoriesGet Available File CategoriesARead-onlyIdempotent
Returns the list of categories used for file organization
Inputs: response_format.
file_organizer_inspect_metadataInspect File MetadataARead-onlyIdempotent
Inspects a file and returns comprehensive but privacy-safe metadata. For images, extracts EXIF data (date, camera, dimensions). For audio, extracts ID3 tags (artist, album, title). Excludes sensitive data like GPS coordinates.
Inputs: file (required), response_format.
file_organizer_list_filesList Files in DirectoryARead-onlyIdempotent
List all files in a directory with basic information. Returns file names and paths. Does not recurse into subdirectories.
Inputs: directory (required), limit, offset, response_format.
file_organizer_list_watchesList Watched DirectoriesARead-onlyIdempotent
List all directories currently being watched with their schedules.
Inputs: response_format.
file_organizer_organize_by_contentOrganize Documents by ContentADestructive
Organize files based on content analysis. strategy='topic' groups documents (PDF, DOCX, TXT, MD, RTF, ODT) into topic-based folders. strategy='project' groups files across all types (documents, code, images) into detected project folders using shared name tokens, content terms, and identifiers. Use dry_run=true to preview changes.
Inputs: source_dir (required), target_dir (required), dry_run, strategy, +3 more.
file_organizer_organize_filesOrganize FilesCDestructive
Automatically organize files into categorized folders. Enable use_content_analysis to detect file type mismatches and potential security threats. Use dry_run=true to preview changes.
Inputs: directory (required), dry_run, response_format, conflict_strategy, +1 more.
file_organizer_organize_musicOrganize Music FilesBDestructive
Organize music files into structured folders based on metadata (Artist/Album). Supports MP3, FLAC, OGG, WAV, M4A, AAC. Use dry_run=true to preview changes.
Inputs: source_dir (required), target_dir (required), dry_run, structure, +4 more.
file_organizer_organize_photosOrganize Photo FilesADestructive
Organize photos into date-based folders using EXIF metadata. Supports JPG, PNG, TIFF, HEIC, RAW formats. Can group by camera model and strip GPS data for privacy. Use dry_run=true to preview changes.
Inputs: source_dir (required), target_dir (required), dry_run, strip_gps, +5 more.
file_organizer_organize_smartSmart Organize FilesADestructive
Automatically organizes mixed files (music, photos, documents) using the appropriate strategy for each type. Music → Artist/Album structure. Photos → Date-based folders with optional GPS stripping. Documents → Topic-based folders. Use dry_run=true to preview changes.
Inputs: source_dir (required), target_dir (required), dry_run, recursive, +6 more.
file_organizer_preview_organizationPreview File Organization PlanARead-onlyIdempotent
Shows what would happen if files were organized, WITHOUT making any changes. Shows moves, conflicts, and skip reasons.
Inputs: directory (required), response_format, conflict_strategy, show_conflicts_only.
file_organizer_read_fileRead File ContentsARead-onlyIdempotent
Read file contents with security checks. Supports text, binary, and base64 encoding. Automatically detects file type and applies appropriate security validations. Sensitive files (passwords, keys, credentials) are automatically blocked.
Inputs: path (required), limit, offset, encoding, +3 more.
file_organizer_scan_directoryScan Directory for Detailed InfoBRead-onlyIdempotent
Scan directory and get detailed file information including size, dates, and extensions. Supports recursive scanning and security screening.
Inputs: directory (required), limit, offset, max_depth, +3 more.
file_organizer_set_custom_rulesSet Custom Organization RulesB
Customize how files are categorized. Rules persist for the current session.
Inputs: rules (required).
file_organizer_smart_suggestSmart SuggestCRead-onlyIdempotent
Analyze directory health and get actionable suggestions for organization
Inputs: directory (required), max_files, use_cache, sample_rate, +4 more.
file_organizer_system_organizeSystem OrganizeCDestructive
Organize files into OS-standard system directories (Music, Documents, Pictures, Videos)
Inputs: source_dir (required), dry_run, response_format, use_system_dirs, +5 more.
file_organizer_undo_last_operationUndo Last Organization OperationCDestructive
Reverses file moves and renames from a previous organization task.
Inputs: manifest_id, response_format.
file_organizer_unwatch_directoryUnwatch DirectoryBIdempotent
Remove a directory from the watch list.
Inputs: directory (required), response_format.
file_organizer_view_historyView HistoryARead-onlyIdempotent
View the history of file organization operations. Supports filtering by date range, operation type, status, and source. Use privacy_mode to control output detail level.
Inputs: limit, since, until, source, +4 more.
file_organizer_watch_directoryWatch DirectoryAIdempotent
Add a directory to the watch list with a cron-based schedule for automatic organization. When the user specifies a schedule in natural language (e.g., "every day at 10am"), convert it to a standard cron expression. Cron format: "minute hour day month weekday". Common conversions: "every day at 10am" → "0 10 * * ", "every 30 minutes" → "/30 * * * *", "every Monday at 9am" → "0 9 * * 1", "every hour" → "0 * * * *".
Inputs: schedule (required), directory (required), auto_organize, response_format, +2 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 26 tools
There is significant overlap among tools, e.g., organize_files vs organize_smart vs organize_by_content vs system_organize, and find_duplicate_files vs analyze_duplicates. Descriptions help differentiate them, but an agent could easily pick the wrong one for a given task.
All 26 tools follow the consistent 'file_organizer_verb_noun' pattern, with clear verbs like list, scan, organize, read, watch. This is highly predictable and easy to navigate.
With 26 tools, the server is slightly above the 15-25 range. The broad feature set (organizing, watching, metadata, history) justifies many tools, but the count feels bloated, especially with overlapping functions that could be consolidated.
The tool set covers listing, scanning, categorization, duplicate detection, multiple organization strategies, preview, history, watching, renaming, and metadata inspection. Missing direct file deletion (except duplicates) and file editing, but those are outside the organizer's scope. Overall coverage is strong with minor gaps.
Maintenance
Related MCP Connectors
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
An MCP server that provides read access to your cloud storage providers, bank accounts and more.
MCP server for progressive tool usage at any scale (see https://klavis.ai)
Related MCP Servers
- AlicenseBqualityBmaintenanceComprehensive MCP server for filesystem operations, process management, interactive sessions, and async file search. Includes utilities for JSON repair, encoding fixes, duplicate detection, OCR, ZIP archives, and Markdown export.50178 npm6MIT
- AlicenseNot gradedqualityNot gradedmaintenanceA production-ready MCP server enabling Claude and other LLMs to perform intelligent file operations with minimal token usage.MIT
- AlicenseNot gradedqualityCmaintenanceLocal-first MCP server for safely searching, reading, summarizing, tagging, deduplicating, and organizing local files with scoped access, read-only defaults, and dry-run plans.19MIT
- AlicenseCqualityCmaintenanceA full-featured secure MCP server for local file system operations, with built-in image processing, OCR and media tools. Fully compliant with the official Model Context Protocol specification, offering standardized request/response schemas, large-file streaming I/O, multi-transport remote deployment, and comprehensive text search & replace functionality for LLM agent integration.22Apache 2.0