Niketan77/mcp-filesystem-server
If you are the rightful owner of mcp-filesystem-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The MCP Filesystem Server is a comprehensive implementation of the Model Context Protocol (MCP) for managing filesystem operations with AI-enhanced file editing capabilities.
create_file
Create a new file with specified content.
edit_file
Edit a file using manual input or AI-powered prompts.
delete_file
Delete a specified file from the system.
read_file
Read and retrieve the content of a specified file.
MCP Filesystem Server
A complete Model Context Protocol (MCP) server implementation for filesystem operations with AI-powered file editing capabilities.
Demo Video:
https://drive.google.com/file/d/18sCyVpAekMkDgUfsKi423VfPN6Rbuj9T/view?usp=drive_link
π Description
This project was built to fulfill the following requirements:
Implemented:
- Implement a Model Context Protocol (MCP) server for filesystem operations
- Create file management tools supporting create, edit, and delete operations
- Develop an MCP client that communicates using proper MCP protocol
- Build a simple frontend application for user interaction
- Enable folder upload functionality for batch file management
- Implement a prompt box for AI-powered file editing using natural language
π― Project Overview
This implementation demonstrates a complete MCP ecosystem:
- True MCP Protocol: JSON-RPC 2.0 compliant server with proper tool registration
- AI Integration: Mixtral-8x7B-Instruct model for intelligent file editing
- Modern Frontend: Clean, responsive web interface with professional UX
- File Management: Complete CRUD operations for filesystem management
- Download System: Individual file downloads and bulk ZIP export
ποΈ Technical Architecture
MCP Protocol Implementation
βββββββββββββββ ββββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββ
βWeb Frontend β ββ β Flask Bridge β ββ β MCP Client β ββ β MCP Server β ββ β AI Service β
β β β β β β β β β β
βFile Upload β β REST API β βJSON-RPC 2.0 β β File Ops β β AI Editing β
βUser Actions β β CORS Enabled β β Protocol β β Tool Reg. β β Mixtral-8x7Bβ
βNotificationsβ β File Serving β β stdio comm β β Validation β β Together AI β
βββββββββββββββ ββββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββ
Component Breakdown
-
MCP Server (
server/mcp_server.py
)- True JSON-RPC 2.0 protocol implementation
- Tool registration and capability advertisement
- File operation handlers with validation
- AI integration for intelligent editing
-
MCP Client (
server/mcp_client.py
)- Protocol-compliant communication layer
- Request/response handling with proper error management
- Subprocess communication via stdio
-
Flask Bridge (
server/mcp_bridge.py
)- REST API endpoints for frontend communication
- File upload/download handling
- CORS configuration for cross-origin requests
- Error handling and response formatting
-
Frontend (
frontend/
)- Modern HTML5/CSS3/JavaScript interface
- Responsive design with professional styling
- Real-time file management and notifications
π Project Structure
mcp-filesystem-server/
βββ run.py # Main entry point
βββ requirements.txt # Dependencies
βββ .env.example # Environment configuration
βββ server/
β βββ mcp_server.py # Core MCP server (JSON-RPC 2.0)
β βββ mcp_client.py # MCP protocol client
β βββ mcp_bridge.py # Flask bridge for frontend
β βββ tools/ # MCP tool implementations
βββ frontend/ # Web interface
β βββ index.html # Main UI
β βββ scripts/app.js # Frontend logic
β βββ styles/main.css # Styling
βββ uploaded_files/ # File storage directory
βββ test_mcp.py # MCP protocol tests
π Quick Start Guide
Prerequisites
- Python 3.7+ installed on your system
- pip package manager
- Together AI API key (optional, for AI editing features)
Installation Steps
-
Clone the repository:
git clone https://github.com/Niketan77/mcp-filesystem-server.git cd mcp-filesystem-server
-
Create a virtual environment (recommended):
# Windows python -m venv venv venv\Scripts\activate # macOS/Linux python3 -m venv venv source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
# Copy the example environment file cp .env.example .env # Edit .env and add your Together AI API key (optional) # TOGETHER_AI_API_KEY=your_api_key_here
-
Run the server:
python run.py
-
Access the application:
- Open your browser and navigate to:
http://localhost:5000
- The frontend interface will load automatically
- Open your browser and navigate to:
Getting Together AI API Key (Optional)
- Visit Together AI and sign up
- Navigate to your dashboard and generate an API key or (https://api.together.ai/settings/api-keys)
- create key and copy it
- Add the key to your
.env
file:TOGETHER_AI_API_KEY=your_actual_api_key_here
π§ MCP Tools Available
The server implements these MCP tools:
Tool | Description | Parameters |
---|---|---|
create_file | Create a new file | filename , content |
edit_file | Edit file (manual or AI) | filename , content /prompt , use_ai |
delete_file | Delete a file | filename |
read_file | Read file content | filename |
π§ͺ Testing & Verification
Automated Tests
Run the comprehensive MCP protocol test suite:
python test_mcp.py
This test verifies:
- β MCP server startup and initialization
- β Tool discovery and registration (5 tools)
- β File creation, reading, editing, and deletion
- β AI-powered editing functionality
- β JSON-RPC 2.0 protocol compliance
- β Error handling and edge cases
Manual Testing
- Upload Test: Upload various file types and folder structures
- Edit Test: Use AI prompts to modify files
- Download Test: Test individual and bulk downloads
- UI Test: Verify notifications, responsive design, and user flow
Expected Test Output
π¬ MCP Filesystem Server Test Suite
π§ͺ Testing MCP Filesystem Server...
==================================================
1. Starting MCP server... β
2. Testing tool discovery... β
Found 5 tools
3. Testing file creation... β
4. Testing file reading... β
5. Testing file listing... β
6. Testing manual file editing... β
7. Testing AI-powered editing... β
8. Testing file deletion... β
9. Verifying file deletion... β
==================================================
π All MCP tests passed successfully!
οΏ½ How to Use
1. Upload Files
- Folder Upload: Click "Click to select folder" to upload entire directory structures
- Individual Files: Use "Click to select individual files" for specific files
- Drag & Drop: Simply drag files or folders onto the upload areas
2. File Management
- Browse Files: View all uploaded files in the file browser
- File Count: See total number of files in the header
- Delete Files: Remove individual files or delete all files at once
3. Edit Files with AI
- Click "Edit" on any file to open the editor
- Enter a natural language prompt describing your desired changes:
- "Add comments to this code"
- "Fix any syntax errors"
- "Convert this to TypeScript"
- "Optimize this function for performance"
- Click "Apply AI Edit" and watch the AI modify your file
- Review and save the changes
4. Manual File Editing
- Open any file in the editor
- Modify content directly in the text area
- Click "Save" to apply changes
5. Download Files
- Individual Files: Click the download icon (π₯) next to any file
- Bulk Download: Use "π¦ Download All as ZIP" to get all files in a ZIP archive
- Current File: Download the currently open file from the editor
π¨ Features Showcase
File Operations
- Smart Upload: Handles both folders and individual files
- File Type Support: Text files, code files, configuration files, and more
- Size Validation: Configurable file size limits (default: 10MB)
- Progress Feedback: Real-time upload and operation status
AI Integration
- Natural Language Editing: Describe changes in plain English
- Mixtral Model: Powered by Mixtral-8x7B-Instruct for high-quality results
- Context Aware: AI understands file types and provides appropriate modifications
Supported File Types
The application supports text-based files including:
Category | Extensions |
---|---|
Code Files | .py , .js , .ts , .html , .css , .java , .cpp , .c , .h , .php , .rb , .go , .rs |
Data Files | .txt , .md , .csv , .json , .xml , .yaml , .yml , .toml |
Config Files | .ini , .cfg , .conf , .env , .gitignore , .dockerignore |
Scripts | .sh , .bat , .ps1 , .fish , .zsh |
Documentation | .rst , .tex , .wiki |
Logs | .log , .out , .err |
Configuration Limits
Setting | Default | Description |
---|---|---|
File Size | 10MB | Maximum individual file size |
Upload Limit | Unlimited | No limit on number of files |
AI Timeout | 30s | Maximum time for AI operations |
Session Storage | Local | Files stored in uploaded_files/ |
π€ Contributing
We welcome contributions! Here's how to get started:
Development Setup
- Fork the repository
- Clone your fork:
git clone https://github.com/Niketan77/mcp-filesystem-server.git
- Create a virtual environment:
python -m venv venv
- Install dependencies:
pip install -r requirements.txt
- Create a feature branch:
git checkout -b feature-name
Making Changes
- Backend: Modify files in
server/
directory - Frontend: Update files in
frontend/
directory - Tests: Add tests for new features
- Documentation: Update README if needed
Pull Request Process
- Run tests:
python test_mcp.py
- Commit changes:
git commit -m "Add feature description"
- Push to fork:
git push origin feature-name
- Create pull request with detailed description
Code Style
- Follow PEP 8 for Python code
- Use meaningful variable names
- Add comments for complex logic
- Maintain consistent indentation
β If you find this project helpful, please consider giving it a star on GitHub!