Priyankaa078/MCP-Server-implementation
If you are the rightful owner of MCP-Server-implementation 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 File System Server is a Model Context Protocol server designed to facilitate file system operations through a web-based interface, integrating AI assistance for natural language processing.
create_file
Creates a new file with specified content.
read_file
Reads the contents of an existing file.
update_file
Updates an existing file with new content.
delete_file
Deletes a file from the filesystem.
list_files
Lists files and directories in a specified directory.
MCP File System Server
A Model Context Protocol (MCP) server that provides file system operations with a simple web-based frontend.
Features
- File Operations: Create, read, update, delete files
- Directory Operations: List directory contents
- Web Interface: Simple frontend for file management
- AI Assistant: Natural language processing for file operations
- File Upload: Drag and drop file upload functionality
Installation
- Clone the repository
git clone <your-repo-url>
cd mcp-filesystem-server
- Install dependencies
npm install @modelcontextprotocol/sdk
- Make the server executable
chmod +x server.js
Usage
Running the MCP Server
node server.js
The server will run on stdio and can be integrated with MCP-compatible clients.
Using the Web Interface
- Open
index.html
in your web browser - Select the operation you want to perform
- Fill in the required fields
- Click "Execute Operation"
Available Operations
- Create File: Create a new file with specified content
- Read File: Read the contents of an existing file
- Update File: Modify the contents of an existing file
- Delete File: Remove a file from the filesystem
- List Files: List all files in a directory
API Reference
Tools
create_file
Creates a new file with specified content.
Parameters:
filepath
(string): Path where the file should be createdcontent
(string): Content to write to the file
read_file
Reads the contents of an existing file.
Parameters:
filepath
(string): Path to the file to read
update_file
Updates/edits an existing file with new content.
Parameters:
filepath
(string): Path to the file to updatecontent
(string): New content for the file
delete_file
Deletes a file from the filesystem.
Parameters:
filepath
(string): Path to the file to delete
list_files
Lists files and directories in a specified directory.
Parameters:
dirpath
(string): Path to the directory to list
Web Interface Features
File Operations Panel
- Operation Selection: Dropdown to choose between create, read, update, delete, and list operations
- Dynamic Fields: Form fields change based on selected operation
- Execute Button: Runs the selected operation with provided parameters
File Upload & AI Assistant Panel
- Drag & Drop Upload: Drop files directly onto the upload area
- File Browser: Click to browse and select files
- AI Prompt Input: Natural language interface for file operations
- Process with AI: Interprets natural language requests and suggests operations
Output Panel
- Real-time Results: Shows operation results and error messages
- Formatted Output: Displays file contents and operation status
- Clear Function: Button to clear the output area
Configuration
The server is configured with the following capabilities:
{
name: 'filesystem-mcp-server',
version: '0.1.0',
capabilities: {
tools: {}
}
}
Error Handling
The server implements comprehensive error handling:
- File System Errors: Catches and reports file access issues
- Path Validation: Ensures directory structure exists before file creation
- MCP Error Codes: Uses standard MCP error codes for consistent error reporting
- Graceful Shutdown: Handles SIGINT for clean server shutdown
Dependencies
@modelcontextprotocol/sdk
: MCP SDK for server implementationfs/promises
: Node.js file system operationspath
: Path manipulation utilities
Security Considerations
- Path Traversal: Be cautious with file paths to prevent directory traversal attacks
- File Permissions: Ensure the server has appropriate permissions for file operations
- Input Validation: Validate file paths and content before processing
- Access Control: Consider implementing access controls for sensitive directories
Development
Running in Development Mode
node server.js
Testing with the Web Interface
- Start the MCP server in one terminal
- Open
index.html
in a web browser - Test various file operations through the interface
Extending Functionality
To add new file operations:
- Add the tool definition in
setupToolHandlers()
- Implement the handler method
- Add the case in the switch statement
- Update the web interface if needed
Troubleshooting
Common Issues
Server won't start:
- Check that Node.js is installed
- Verify MCP SDK is installed:
npm list @modelcontextprotocol/sdk
File operations fail:
- Check file system permissions
- Verify file paths are correct
- Ensure target directories exist
Web interface not connecting:
- The web interface uses a simulated MCP client for demo purposes
- For real MCP integration, connect through an MCP-compatible client