mcp-filesystem
Provides advanced filesystem operations for AI-assisted development, including batch file reading, renaming, moving, project structure display, and command execution with Python virtual environment auto-activation.
README
MCP Filesystem Server
A comprehensive Model Context Protocol (MCP) server providing advanced filesystem operations with intelligent features for AI-assisted development workflows.
Features
🔧 Core Tools
batch_read- Read multiple files efficiently in a single operationrename_file- Rename files with safety checksmove_file- Move files with automatic directory creationcheck_structure- Display project structure with smart filteringrun_command- Execute commands with Python virtual environment auto-activation
🚀 Advanced Capabilities
- Smart Virtual Environment Detection - Automatically activates Python
.venvwhen detected - Cross-Platform Support - Works on Windows, macOS, and Linux
- Intelligent Filtering - Uses
.checkignorefiles + built-in patterns for clean structure views - Command Prohibition - Prevents file management command overlap between tools
- Enhanced Quote Handling - Proper execution of complex commands with quoted arguments
- Clean Output Format - Focused, minimal output for better AI integration
Quick Start
Installation
npm install
npm run build
Configuration
Create .cursor/mcp.json in your project:
{
"mcpServers": {
"filesystem": {
"command": "node",
"args": [
"/absolute/path/to/dist/index.js"
],
"env": {}
}
}
}
Tool Documentation
📄 batch_read
Read multiple files concurrently with automatic encoding detection.
{
projectPath: "C:/project",
relativePaths: ["src/index.ts", "package.json", "README.md"]
}
Features:
- Concurrent file reading for performance
- UTF-8 and binary (base64) support
- Empty file detection (
[EMPTY]indicator) - Graceful error handling for missing files
🔄 rename_file
Safely rename files with conflict detection.
{
projectPath: "C:/project",
currentPath: "src/oldname.js",
newName: "newname.js"
}
Safety Features:
- Source file existence validation
- Destination conflict prevention
- Clear success/error feedback
📁 move_file
Move files with automatic directory creation.
{
projectPath: "C:/project",
sourcePath: "src/component.tsx",
destinationPath: "src/components/component.tsx"
}
Features:
- Automatic parent directory creation
- Conflict detection and prevention
- Cross-directory moves
🌳 check_structure
Display clean project structure with intelligent filtering.
{
projectPath: "C:/project"
}
Smart Filtering:
- Built-in ignore patterns (node_modules, .git, dist, etc.)
- Custom
.checkignorefile support - Empty directory detection
- Clean tree visualization
.checkignore Format
# Comments start with #
temp/
*.tmp
*.log
debug/
💻 run_command
Execute development commands with Python virtual environment auto-activation.
{
projectPath: "C:/project",
command: "npm test"
}
Features:
- Auto venv activation - Detects
.venvand activates automatically - Cross-platform - Windows and Unix support
- Quote handling - Proper execution of complex quoted commands
- Command prohibition - Blocks file management commands (use dedicated tools)
Prohibited Commands:
- File reading:
cat,type,more, etc. → Usebatch_read - File moving:
mv,move,ren→ Userename_file/move_file - File listing:
dir,ls,tree→ Usecheck_structure
Examples
Python Development Workflow
// Check project structure
{ projectPath: "C:/python-project" }
// Read configuration files
{
projectPath: "C:/python-project",
relativePaths: ["requirements.txt", "setup.py", "src/main.py"]
}
// Run tests (auto-activates .venv)
{
projectPath: "C:/python-project",
command: "pytest tests/ -v"
}
// Install packages (in venv)
{
projectPath: "C:/python-project",
command: "pip install requests"
}
Node.js Development Workflow
// Build project
{
projectPath: "C:/node-project",
command: "npm run build"
}
// Run tests
{
projectPath: "C:/node-project",
command: "npm test"
}
// Lint code
{
projectPath: "C:/node-project",
command: "npx eslint src/ --fix"
}
Technical Details
Virtual Environment Detection
The server automatically detects Python virtual environments:
- Windows:
.venv\Scripts\activate.bat - Unix/Linux:
.venv/bin/activate
When detected, all Python commands are executed within the virtual environment context.
Error Handling
All tools provide comprehensive error handling:
- File not found - Clear error messages with full paths
- Permission denied - Specific access error reporting
- Command failures - Exit codes and stderr capture
- Validation errors - Pre-execution checks prevent issues
Performance
- Concurrent operations - Multiple files read simultaneously
- Smart filtering - Reduces unnecessary filesystem traversal
- Efficient command execution - Minimal overhead for command operations
Development
Building
npm run build
Testing
npm run dev # Build and start
Project Structure
src/
├── index.ts # Main MCP server implementation
package.json # Dependencies and scripts
tsconfig.json # TypeScript configuration
.checkignore # Structure filtering patterns
README.md # This documentation
License
MIT License
Contributing
Contributions welcome! Please ensure all tools maintain the clean, focused output format and comprehensive error handling standards.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。