File Organizer MCP
An intelligent MCP server that analyzes folder contents to automatically categorize files and suggest meaningful naming conventions based on file types and content. It enables users to organize messy directories into structured topic-based folders through automated analysis, renaming, and file movement tools.
README
File Organizer
A Python utility to analyze folders and suggest organized file structures using AI classification. The classifier can use OpenAI, a custom LLM endpoint, or interactive prompts.
Features
- Analyze a folder and suggest categories for files using AI.
- Subcategorize files with AI-determined categories (e.g., Python, Flask, PostgreSQL, etc.).
- Produce a suggested folder structure and AI-suggested filenames.
- Support for OpenAI, custom LLM endpoints, or interactive manual classification.
- Graceful fallback: when AI unavailable, optionally ask user for input via CLI/Inspector.
Quick start
Prerequisites: Python 3.9+ and pip.
Install dependencies:
python -m pip install -r requirements.txt
Run tests:
python -m pytest -q
Using the classifier
Option 1: OpenAI (recommended)
- Get an OpenAI API key from platform.openai.com.
- Run with AI:
$env:OPENAI_API_KEY = 'sk-your-key-here'
python main.py /path/to/folder
Option 2: Custom LLM endpoint
If you have a custom LLM service, configure it:
$env:EXTERNAL_LLM_URL = 'https://your-llm-api.example.com/classify'
$env:EXTERNAL_LLM_API_KEY = 'your-api-key'
python main.py /path/to/folder
Your endpoint should accept JSON:
{
"filename": "example.py",
"file_type": ".py",
"content_preview": "def hello(): ..."
}
And return JSON:
{
"category": "Code",
"confidence": 0.95,
"subcategory": "Python",
"suggested_name": "hello_world.py"
}
Option 3: Interactive mode (manual classification)
For testing or when you prefer to classify files manually:
$env:INTERACTIVE_MODE = 'true'
python main.py /path/to/folder
The system will prompt you for each file's category, confidence, subcategory, and suggested name.
Option 4: No AI (auto-categorizes as "Uncategorized")
python main.py /path/to/folder
All files will be categorized as "Uncategorized" without any AI or interactive prompts.
Project layout
services/— core services (FileAnalysisService,FileOrganizationService).models/— dataclasses forFileMetadata,FolderOrganization,OrganizationResult.tests/— unit tests (run withpytest).utils/— helpers and validators.
Contributing
- Fork the repo and create a branch for your feature/bugfix.
- Run tests and add new tests for your changes.
- Open a pull request describing the change.
License
This repository does not include a license file. Add one if you intend to publish or share the project publicly (e.g. MIT).
File Organizer MCP
An intelligent MCP (Model Context Protocol) server that analyzes folders, automatically categorizes files, suggests meaningful names, and organizes them into topic-based folder structures.
Features
- Folder Analysis: Scan a folder and analyze its contents
- Intelligent Categorization: Automatically categorize files by type (Documents, Images, Code, Data, etc.)
- Smart Naming: Suggest improved, meaningful filenames based on content and context
- Folder Organization: Create organized folder structures by topics
- File Organization: Option to move and rename files according to suggested structure
- Metadata Extraction: Extract tags and metadata from files for better organization
- Confidence Scoring: Get confidence scores for suggested categorizations
Installation
pip install -e .
Configuration
Edit settings.py to customize:
- Maximum file size to analyze
- File extensions to consider as text
- Category detection keywords
- Maximum folder name length
Usage
As an MCP Server
Start the server:
python main.py
Available Tools
1. analyze_folder
Analyze a folder to understand its contents and suggest organization.
Parameters:
folder_path(string, required): Absolute path to the folder to analyze
Returns:
- Suggested folder structure
- File categorization
- Renamed suggestions for each file
- Confidence scores
Example:
{
"folder_path": "/path/to/folder"
}
2. organize_files
Organize files into topic-based folders with suggested names.
Parameters:
folder_path(string, required): Absolute path to the folder to organizecreate_folders(boolean, optional): Whether to create the folder structure (default: false)move_files(boolean, optional): Whether to actually move files to new folders (default: false)apply_naming(boolean, optional): Whether to rename files with suggested names (default: false)
Returns:
- Created folders list
- Moved files list
- Any errors encountered
- Summary statistics
3. get_structure
Get the suggested folder structure for an analyzed folder.
Parameters:
folder_path(string, required): Absolute path to the folder
Returns:
- Suggested structure with categories and file counts
Project Structure
file-organizer-mcp/
├── main.py # MCP server entry point
├── settings.py # Configuration settings
├── pyproject.toml # Project metadata
├── requirements.txt # Python dependencies
├── README.md # This file
├── models/
│ ├── __init__.py
│ ├── result.py # OperationResult model
│ └── file_models.py # File and organization models
├── services/
│ ├── __init__.py
│ ├── file_analysis_service.py # File analysis logic
│ └── file_organization_service.py # File organization logic
├── utils/
│ ├── __init__.py
│ ├── errors.py # Custom exceptions
│ ├── paths.py # Path utilities
│ └── validate.py # Validation utilities
└── tests/
├── __init__.py
├── test_file_analysis_service.py
├── test_file_organization_service.py
└── test_integration.py
Categories
The server automatically recognizes and organizes into these categories:
- Documents: PDFs, Word docs, text files, reports
- Images: Photos, graphics, icons, screenshots
- Videos: Video files and recordings
- Audio: Music files, podcasts, audio recordings
- Code: Source code files in various languages
- Data: Datasets, databases, CSV, SQL files
- Configuration: Config files, settings, environment files
- Archives: Compressed files (zip, rar, etc.)
- Backup: Backup and old version files
- README: Documentation and guide files
Example Workflow
-
Analyze a folder:
result = analyze_folder("/path/to/messy/folder") -
Review the suggested structure
-
Organize with folders created but files not moved (safe preview):
organize_files("/path/to/messy/folder", create_folders=True, move_files=False) -
If satisfied, actually move files:
organize_files("/path/to/messy/folder", create_folders=True, move_files=True)
Testing
Run tests:
pytest tests/
Error Handling
The server provides detailed error handling:
InvalidPathError: When folder path is invalidFileAccessError: When files cannot be accessedAnalysisError: When file analysis failsOrganizationError: When organization fails
Limitations
- Maximum file size for analysis: 10 MB (configurable)
- Maximum files per folder: 1000 (configurable)
- Text file preview: First 500 characters only
- Folder name length: Maximum 200 characters
Contributing
Feel free to submit issues and enhancement requests!
License
MIT License
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。