MCP-Server-Filesystem
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP-Server-Filesystem find all files matching '*.js' in src"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Server Filesystem
An enhanced Model Context Protocol (MCP) filesystem server that fixes common limitations and adds powerful features missing from standard implementations.
π Key Features
β Fixed Issues
Glob Pattern Search: Properly supports patterns like
*pipeline*,*.js,**/*test*Head + Tail Support: Read first N lines AND last M lines simultaneously (fixes "Cannot specify both head and tail parameters")
Enhanced File Operations: Complete file editing with diff preview
π Core Tools
read_file- Read files with head/tail supportread_multiple_files- Batch file readingwrite_file- Create/overwrite filesdelete_file- NEW Delete files/directories (with recursive option)edit_file- ENHANCED Line-based editing with intelligent syntax validation and diff previewsearch_files- FIXED glob pattern searchlist_directory- Directory listingcreate_directory- Directory creationget_file_info- File metadatamove_file- File/directory movingrun_command- NEW Shell command executionlist_allowed_directories- Security transparency
Related MCP server: File Operations MCP Server
π Quick Start
Installation Options
Option 1: NPM Package (Recommended)
# Install globally
npm install -g @redf0x1/mcp-server-filesystem
# Or use with npx (no installation needed)
npx @redf0x1/mcp-server-filesystem /path/to/your/workspaceOption 2: From Source
git clone https://github.com/redf0x1/mcp-server-filesystem.git
cd mcp-server-filesystem
npm installUsage
With NPX (Recommended):
npx @redf0x1/mcp-server-filesystem /path/to/allowed/directoryDirect execution:
node server-filesystem.js /path/to/allowed/directoryWith npm script:
npm start # Uses ./workspace as defaultMCP Client Configurations
Important: The cwd (current working directory) parameter is required for proper server operation. It ensures the server starts from the correct directory and can resolve relative paths properly.
VS Code with MCP Extension
Add to your mcp.json:
With NPX (Recommended):
{
"servers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@redf0x1/mcp-server-filesystem",
"/home/user/projects",
"/home/user/documents"
]
}
},
"inputs": []
}With local installation:
{
"servers": {
"filesystem": {
"command": "node",
"args": [
"/path/to/server-filesystem.js",
"/home/user/projects",
"/home/user/documents"
],
"cwd": "/path/to/mcp-server-filesystem"
}
},
"inputs": []
}Cursor IDE
Add to your MCP settings:
With NPX:
{
"mcp": {
"servers": {
"enhanced-filesystem": {
"command": "npx",
"args": [
"-y",
"@redf0x1/mcp-server-filesystem",
"/Users/username/workspace",
"/Users/username/scripts"
]
}
}
}
}With local installation:
{
"mcp": {
"servers": {
"enhanced-filesystem": {
"command": "node",
"args": [
"/path/to/server-filesystem.js",
"/Users/username/workspace",
"/Users/username/scripts"
],
"cwd": "/path/to/mcp-server-filesystem"
}
}
}
}Cline (Claude for VSCode)
Configuration in settings:
With NPX:
{
"cline.mcp.servers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@redf0x1/mcp-server-filesystem",
"/workspace/current-project",
"/workspace/shared-libs"
],
"env": {
"NODE_ENV": "development"
}
}
}
}With local installation:
{
"cline.mcp.servers": {
"filesystem": {
"command": "node",
"args": [
"/path/to/server-filesystem.js",
"/workspace/current-project",
"/workspace/shared-libs"
],
"cwd": "/path/to/mcp-server-filesystem",
"env": {
"NODE_ENV": "development"
}
}
}
}Windsurf AI Editor
Add to MCP configuration:
With NPX:
{
"servers": {
"filesystem-enhanced": {
"command": "npx",
"args": [
"-y",
"@redf0x1/mcp-server-filesystem",
"/home/developer/projects",
"/tmp/workspace"
],
"timeout": 30000
}
}
}With local installation:
{
"servers": {
"filesystem-enhanced": {
"command": "node",
"args": [
"/opt/mcp-tools/server-filesystem.js",
"/home/developer/projects",
"/tmp/workspace"
],
"cwd": "/opt/mcp-tools",
"timeout": 30000
}
}
}Generic MCP Client
Standard configuration format:
#### Generic MCP Client
**With NPX (Recommended):**
```json
{
"mcp": {
"servers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@redf0x1/mcp-server-filesystem",
"/path/to/allowed/directory1",
"/path/to/allowed/directory2"
]
}
}
}
}With local installation:
{
"mcp": {
"servers": {
"filesystem": {
"command": "node",
"args": [
"./server-filesystem.js",
"/path/to/allowed/directory1",
"/path/to/allowed/directory2"
],
"cwd": "/path/to/server/directory"
}
}
}
}Docker Integration
For containerized environments:
With NPX:
{
"mcpServers": {
"filesystem": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"--mount", "type=bind,src=/host/projects,dst=/container/projects",
"--mount", "type=bind,src=/host/data,dst=/container/data,ro",
"node:18-alpine",
"sh", "-c",
"npx @redf0x1/mcp-server-filesystem /container/projects /container/data"
]
}
}
}With global installation:
{
"mcpServers": {
"filesystem": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"--mount", "type=bind,src=/host/projects,dst=/container/projects",
"--mount", "type=bind,src=/host/data,dst=/container/data,ro",
"node:18-alpine",
"sh", "-c",
"npm install -g @redf0x1/mcp-server-filesystem && mcp-server-filesystem /container/projects /container/data"
]
}
}
}NPM Global Installation
Install globally for easier access:
npm install -g @redf0x1/mcp-server-filesystem
mcp-server-filesystem /your/project/pathπ οΈ Enhanced Features
1. Smart Head + Tail Reading
Before (Standard):
{
"path": "large-file.txt",
"head": 10,
"tail": 5
}β Error: Cannot specify both head and tail parameters simultaneously
After (Complete):
{
"path": "large-file.txt",
"head": 10,
"tail": 5
}β Result:
Line 1: ...
Line 2: ...
...
Line 10: ...
... (middle content omitted) ...
Line 96: ...
Line 97: ...
...
Line 100: ...2. Fixed Glob Pattern Search
Before (Standard):
{
"path": "/project",
"pattern": "*config*"
}β Only finds exact matches, ignores glob patterns
After (Complete):
{
"path": "/project",
"pattern": "*config*"
}β
Finds: webpack.config.js, app-config.json, config/database.php, etc.
Supported patterns:
*.js- All JavaScript files*test*- Files containing "test"**/*config*- Config files in any subdirectorysrc/**/*.ts- TypeScript files in src/
3. Intelligent File Editing with Syntax Validation
Enhanced validation for multiple file types:
{
"path": "app.ts",
"edits": [
{
"oldText": "const port = 3000;",
"newText": "const port: number = process.env.PORT || 3000;"
}
],
"dryRun": true,
"skipValidation": false
}Supported file types for validation:
JavaScript/JSX - Bracket matching, semicolon checking, control structure validation
TypeScript/TSX - Type annotation validation, interface/type definition checking
JSON - Complete JSON syntax validation
YAML - Indentation, structure, and syntax validation
XML/HTML - Tag matching and structure validation
Smart error handling:
β VALIDATION FAILED for typescript file: app.ts
Error: Unclosed '{' starting at line 15, column 23
π§ SUGGESTED FIXES:
1. Check for missing/extra brackets, braces, or parentheses
2. Verify proper line endings and indentation
3. Ensure all strings are properly quoted
4. Check for missing semicolons (JavaScript/TypeScript)
5. Validate type annotations (TypeScript)
6. Use skipValidation=true only if you're certain the syntax is correct
π TIP: Preview your changes with dryRun=true firstAdvanced features:
Pre-edit validation - Checks syntax before applying changes
Detailed error messages - Specific line/column error reporting
File type detection - Automatic detection based on extension
Smart suggestions - Context-aware fix recommendations
Dry run mode - Preview changes with
dryRun=trueValidation bypass - Use
skipValidation=truefor edge cases
4. Secure Command Execution
{
"command": "npm install lodash",
"workingDirectory": "/workspace/project",
"timeout": 30000,
"includeStderr": true
}Execute shell commands safely within allowed directories:
Git operations:
git status,git add .,git commitPackage management:
npm install,pip install,composer installBuild tools:
webpack build,tsc,makeFile operations:
find,grep,ls -la
Security features:
Commands run only in allowed directories
Configurable timeout protection
Both stdout and stderr capture
Environment isolation
5. Safe File/Directory Deletion
{
"path": "/workspace/temp-file.txt"
}Delete files safely:
{
"path": "/workspace/temp-directory",
"recursive": true
}Delete directories with contents:
Single files: Safe file deletion with validation
Empty directories: Remove empty directories only
Recursive deletion: Remove directories and all contents (use with caution)
Error handling: Clear messages for non-existent or protected files
π Project Structure
mcp-server-filesystem/
βββ server-filesystem.js # Main server file
βββ package.json # Dependencies and scripts
βββ mcp-config.json # MCP configuration example
βββ README.md # This file
βββ workspace/ # Demo workspace
βββ demo.txt # Sample text file
βββ deploy-pipeline.yml # Sample YAML
βββ pipeline-config.js # Sample JS configπ§ Development
Configuration Best Practices
Always specify cwd:
{
"servers": {
"filesystem": {
"command": "node",
"args": ["/absolute/path/to/server-filesystem.js", "/workspace"],
"cwd": "/absolute/path/to/server/directory" // β Required!
}
}
}Why cwd is important:
Ensures server starts from correct directory
Resolves relative paths properly
Prevents "Cannot find module" errors
Required for proper dependency loading
Example working config:
{
"servers": {
"filesystem": {
"command": "node",
"args": [
"/root/server-filesystem/server-filesystem.js",
"/var/www/projects",
"/home/user/documents"
],
"cwd": "/root/server-filesystem"
}
}
}Local Development
npm run dev # Starts server with ./workspaceCommon Usage Examples
Web Development:
node server-filesystem.js /home/user/websites /home/user/configData Science:
node server-filesystem.js /data/datasets /notebooks /scriptsDevOps:
node server-filesystem.js /infrastructure /deployments /monitoringMobile Development:
node server-filesystem.js /android-projects /ios-projects /shared-assetsTesting Tools
Test individual tools using your MCP client or create custom test scripts.
π Security
Path Validation: All operations restricted to allowed directories
Symlink Protection: Prevents symlink-based path traversal
Atomic Operations: File writes use atomic rename for consistency
Input Sanitization: All inputs validated with Zod schemas
Command Isolation: Shell commands run with restricted permissions
π¨ Troubleshooting
Common Issues
Server won't start:
# Check Node.js version
node --version # Should be >=18.0.0
# Verify dependencies
npm install
# Check directory permissions
ls -la /path/to/allowed/directory"Cannot find module" error:
Verify the server file path in your config:
/path/to/server-filesystem.jsEnsure
cwdpoints to the directory containing the server fileCheck file permissions:
ls -la /path/to/server-filesystem.js
Path access denied:
Ensure directories exist and are readable
Check symlink targets are within allowed paths
Verify absolute paths in configuration
Make sure
cwdis set correctly in your MCP configuration
Glob patterns not working:
# β
Correct patterns
"*.js" # All JS files
"**/test/*" # Test files in any subdirectory
"*config*" # Files containing "config"
# β Incorrect patterns
"*.js*" # Too broad
"test" # Too specificPerformance Tips
Use specific glob patterns to reduce search time
Limit the number of allowed directories
Use
head/tailfor large files instead of reading entire contentEnable
excludePatternsin search operations
π Requirements
Node.js: 18.0.0 or higher
Dependencies:
@modelcontextprotocol/sdkminimatch(for glob patterns)diff(for file editing)zod(for validation)
π€ Contributing
Fork the repository
Create your feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
Built on top of the Model Context Protocol
Inspired by the official MCP filesystem server
Enhanced to solve real-world limitations
π What's Different?
This server fixes several critical issues found in standard MCP filesystem implementations:
Issue | Standard Behavior | β Our Solution |
Glob patterns |
| Uses |
Head + Tail | "Cannot specify both parameters" error | Smart combination with separator |
File editing | No diff preview | Git-style diff before applying changes |
Syntax validation | No validation before file write | Intelligent validation for JS/TS/JSON/YAML/XML |
Edit error feedback | Generic "operation failed" messages | Detailed syntax error with line/column info |
Command execution | Not available | Secure shell command execution |
File deletion | Basic | Safe deletion with recursive option and validation |
Error handling | Basic error messages | Detailed context and troubleshooting |
Performance improvements:
Multi-strategy pattern matching for better search results
Atomic file operations for data consistency
Memory-efficient head/tail reading for large files
Safe recursive deletion with proper validation
Debug logging for troubleshooting
Additional features not found in standard implementations:
Combined head+tail reading for file previews
Git-style diff preview before file edits
Intelligent syntax validation for JavaScript, TypeScript, JSON, YAML, XML/HTML
Smart error reporting with line/column precision and fix suggestions
Secure command execution within allowed directories
Multiple glob pattern strategies for comprehensive search
Enhanced error messages with context and solutions
Model-friendly validation feedback to help AI assistants learn from syntax errors
Note: This server addresses specific limitations found in standard MCP filesystem implementations. If you need basic filesystem operations without the enhanced features, consider using the official @modelcontextprotocol/server-filesystem package.
Available Tools
12 toolscreate_directoryA
Create a new directory or ensure a directory exists. Can create multiple nested directories in one operation. If the directory already exists, this operation will succeed silently. Perfect for setting up directory structures for projects or ensuring required paths exist. Only works within allowed directories.
Inputs: path (required).
delete_fileA
Delete a file or directory. Use with extreme caution as this operation cannot be undone. For directories, use the recursive flag to delete non-empty directories and their contents. Only works within allowed directories.
Inputs: path (required), recursive.
edit_fileA
Make line-based edits to a text file with intelligent syntax validation. Each edit replaces exact line sequences with new content. Automatically validates syntax for JavaScript, TypeScript, JSON, YAML, XML/HTML files. Returns detailed error messages if validation fails to help fix syntax issues. Use dryRun=true to preview changes, skipValidation=true to bypass syntax checks. Returns a git-style diff showing the changes made. Only works within allowed directories.
Inputs: path (required), edits (required), dryRun, skipValidation.
get_file_infoA
Retrieve detailed metadata about a file or directory. Returns comprehensive information including size, creation time, last modified time, permissions, and type. This tool is perfect for understanding file characteristics without reading the actual content. Only works within allowed directories.
Inputs: path (required).
list_allowed_directoriesA
Returns the list of directories that this server is allowed to access. Use this to understand which directories are available before trying to access files.
Inputs: no named parameters.
list_directoryA
Get a detailed listing of all files and directories in a specified path. Results clearly distinguish between files and directories with [FILE] and [DIR] prefixes. This tool is essential for understanding directory structure and finding specific files within a directory. Only works within allowed directories.
Inputs: path (required).
move_fileA
Move or rename files and directories. Can move files between directories and rename them in a single operation. If the destination exists, the operation will fail. Works across different directories and can be used for simple renaming within the same directory. Both source and destination must be within allowed directories.
Inputs: source (required), destination (required).
read_fileA
Read the complete contents of a file from the file system. Handles various text encodings and provides detailed error messages if the file cannot be read. Use this tool when you need to examine the contents of a single file. Use the 'head' parameter to read only the first N lines of a file, or the 'tail' parameter to read only the last N lines of a file. Only works within allowed directories.
Inputs: path (required), head, tail.
read_multiple_filesA
Read the contents of multiple files simultaneously. This is more efficient than reading files one by one when you need to analyze or compare multiple files. Each file's content is returned with its path as a reference. Failed reads for individual files won't stop the entire operation. Only works within allowed directories.
Inputs: paths (required).
run_commandA
Execute shell commands and return their output. This tool allows running terminal commands within the allowed directories. Useful for development tasks, file operations, git commands, package management, etc. Commands are executed with a timeout and in a secure environment. Both stdout and stderr are captured.
Inputs: command (required), timeout, includeStderr, workingDirectory.
search_filesA
FIXED VERSION: Recursively search for files and directories matching a glob pattern. Now properly supports glob patterns like 'pipeline', '*.js', '**/test', etc. Searches through all subdirectories from the starting path. The search is case-insensitive and supports advanced glob patterns. Returns full paths to all matching items. Great for finding files when you don't know their exact location. Only searches within allowed directories.
Inputs: path (required), pattern (required), excludePatterns.
write_fileA
Create a new file or completely overwrite an existing file with new content. Use with caution as it will overwrite existing files without warning. Handles text content with proper encoding. Only works within allowed directories.
Inputs: path (required), content (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 12 tools
Each tool targets a distinct filesystem operation: read vs write vs edit vs delete, etc. read_multiple_files and read_file are clearly separated by single vs batch, and write_file vs edit_file are distinguished by full overwrite vs line edits.
All tools follow a consistent snake_case verb_noun pattern (read_file, write_file, create_directory, list_directory, move_file, etc.). Even 'list_allowed_directories' and 'run_command' conform to the pattern.
12 tools is well-scoped for a filesystem server, covering all core file and directory operations without excessive overlap. Each tool serves a distinct purpose, and the count is within the optimal range.
The toolset covers all essential filesystem operations including read, write, edit, delete, move, search, directory management, and metadata. Minor gaps exist such as no dedicated copy tool, but copy can be simulated with read+write or run_command, so agents can work around it.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yoβ¦
Browse and manage files in your Moxt AI workspace from any MCP client.
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
The Remote MCP server acts as a standardized bridge between LLM applications (like Claude, ChatGPT, and Cursor) and external services, enabling AI agents to access external tools and resources. Its primary capability is providing a centralized search tool to discover other MCP servers and their respective tools. Unlike local implementations, it runs remotely with OAuth authentication and permission controls for security.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that provides file system operations, analysis, and manipulation capabilities through a standardized tool interface.6MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables enhanced file system operations including reading, writing, copying, moving files with streaming capabilities, directory management, file watching, and change tracking.22MIT
- AlicenseAqualityFmaintenanceA Model Context Protocol server that provides secure and intelligent interaction with files and filesystems, offering smart context management and token-efficient operations for working with large files and complex directory structures.2167MIT
- AlicenseAqualityDmaintenanceA Model Context Protocol server that provides AI agents with secure access to local filesystem operations, enabling reading, writing, and managing files through a standardized interface.1068 npm54Apache 2.0