MCP File Organizer
Enables AI-driven file organization by listing and moving files into structured folders by extension and modification date, based on natural language requests, without reading file contents.
README
MCP File Organizer — demo for the techblog post "MCP in Practice"
A demo illustrating MCP through the "AI File Organization Assistant" use case: an MCP Server exposing 2 file-management tools (list_files, move_file — no read_file; the server never reads file contents, only file name/extension/modification date), and an MCP Client/Agent using Gemini (via @google/genai, with built-in MCP support through mcpToTool) to decide which tool to call based on the user's natural-language request. folder is any absolute path on the machine (not limited to the demo's storage/inbox — it can point to a real folder such as Downloads), and results always land in <folder>/organized/<extension>/<year>/<month>/<day>/. The demo dataset is 500 mock files accumulated over 365 days, reorganized by extension and then by year/month/day of last modification.
Setup
npm install
Generating mock data
npm run generate-mock # generates 500 mock files into storage/inbox, with mtimes spread across the last 365 days
Rerun this command anytime to generate a fresh dataset.
Running the real Agent (requires a Gemini API key)
client/client.ts is the real Agent: it exposes the MCP client to Gemini via mcpToTool, letting Gemini decide on its own which tool to call and with what arguments (automatic function calling), with no hardcoded rules. It reads the key from GEMINI_API_KEY, or GOOGLE_API_KEY, or API_KEY (in that priority order); it reads the model from MODEL if the value starts with gemini-, otherwise it falls back to the default gemini-2.5-flash.
# PowerShell
$env:GEMINI_API_KEY = "AIza..."
npm run agent
# bash
export GEMINI_API_KEY="AIza..."
npm run agent
These variables can also be set in a .env file in the project directory; npm run agent automatically loads .env if it exists (using Node's --env-file-if-exists flag).
To try it on a real folder instead of storage/inbox, pass an absolute path as an argument, e.g. npm run agent -- "C:\Users\you\Downloads".
Safety when using real data
server.ts already guards against several cases before touching the filesystem:
foldermust be an absolute path — a relative path is rejected immediately, never silently resolved against the server process's cwd.namemust be a bare file name (no/,\, or..) — blocks traversal outsidefolder.to_folderis resolved and then re-checked to ensure it stays within<folder>/organized/— blocks traversal outside via...move_filerefuses if the destination already exists (never silently overwrites); passdry_run: trueto preview what would be moved without touching real files.- Set the
ALLOWED_ROOTSenvironment variable (a list of absolute paths, delimited by;on Windows or:on Unix — followingpath.delimiter) to restrictfolderto those roots only. If unset, the demo keeps its original behavior: accepting any absolute folder — fine for demo purposes, butALLOWED_ROOTSshould be set when pointing at real data.
Structure
server/server.ts MCP Server: list_files, move_file — folder is any absolute path, never reads file contents
client/generate-mock-inbox.ts Generates 500 mock files into storage/inbox
client/client.ts MCP Client + Agent, using Gemini via @google/genai
storage/ Generated by running generate-mock, not committed to the repo
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。