A redesigned Model Context Protocol server that enables AI models to access filesystems through privacy-preserving path aliases with an optimized 6-function API interface.
A reimagined Model Context Protocol (MCP) server for filesystem access with privacy-preserving path aliases and an optimized LLM-friendly API.
The original MCP file server was functional but not optimized for how LLMs actually interact with filesystems. This project delivers a complete redesign focused on simplicity, privacy, and efficiency.
# Install from source (npm package coming soon) git clone https://github.com/martinschlott/BetterMCPFileServer.git cd BetterMCPFileServer npm install npm run build # Run with aliases BetterMCPFileServer code:~/projects docs:~/documents
That's it! Now Claude can access your files through privacy-preserving aliases like code/src/main.js
instead of /Users/yourusername/projects/src/main.js
.
Traditional file servers expose full system paths:
/home/martin/Documents/PrivateProject/financial-data.txt
Our aliasing system keeps your privacy intact:
projects/financial-data.txt
Benefits:
This project represents a significant redesign of the standard MCP file server interface. While the original implementation provided a functional foundation, we identified several areas for improvement to create a more intuitive, efficient, and LLM-friendly interface.
The original interface used snake_case naming with basic verbs like read_file
and write_file
. We've adopted more idiomatic camelCase naming with clearer, more specific function names:
read_file
→ readFileContent
write_file
→ writeFile
list_directory
→ searchFilesAndFolders
(with pattern="*")These names explicitly communicate their purpose and follow standard programming conventions, making them more intuitive for both AI models and human developers.
Instead of having separate functions for each individual file or directory operation, we've consolidated related operations:
manageFile
with an action
parameter replaces separate move_file
, copy_file
, and delete_file
functionsmanageFolder
handles folder creation, renaming, and deletion in one functionThis approach reduces API surface area while increasing flexibility, making it easier for LLMs to understand the complete range of available operations.
The original interface included lengthy descriptions with redundant information, such as repeatedly stating "Only works within allowed directories" for each function. Our redesigned API features concise descriptions that:
One of the most significant improvements is our path aliasing system. The original approach required:
Our new approach maps aliases to real paths:
~/Documents/MyProjects → projects
~/Documents/Letters → letters
Benefits include:
projects/backend
instead of /home/username/Documents/MyProjects/backend
)We've added strategic combined operations to reduce round-trips and simplify common tasks:
searchFilesAndFolders
with improved description and includeMetadata
option completely replaces the need for a separate readFolderContent
functioneditFile
retains the useful targeted text replacement functionality from the original implementation but with a clearer parameter structureA key achievement of this redesign is reducing the number of tools from 11 to 6 while maintaining full functionality. This simplification:
This redesign follows several core principles:
Our redesigned search function is both powerful and easy to use:
searchFilesAndFolders({
pattern: "**/*.js", // Find all JavaScript files
includeMetadata: true, // Include file sizes and dates (use sparingly)
ignore: ["node_modules", "*.min.js"] // Skip unwanted matches
})
Key patterns:
"*"
- List top-level items (like a simple directory listing)"projects/*.js"
- All JavaScript files in the projects directory"**/*.md"
- All markdown files recursively across all directories⚠️ Pro Tip: Only set includeMetadata: true
when you specifically need file sizes or dates to keep responses efficient.
The BetterMCPFileServer exposes just 6 powerful functions that handle all filesystem operations:
writeFile
Create or update a file with the given content.
writeFile({ filePath: "projects/README.md", content: "# My Project This is a readme file." })
readFileContent
Read the contents of a file.
readFileContent({ filePath: "projects/README.md" })
editFile
Make targeted changes to specific portions of a file.
editFile({ filePath: "projects/README.md", edits: [ { oldText: "# My Project", newText: "# Awesome Project" } ], dryRun: false })
manageFile
Perform actions like move, rename, copy, or delete a file.
manageFile({ action: "move", filePath: "projects/old.js", newFilePath: "projects/new.js" })
manageFolder
Create, rename, or delete a folder.
manageFolder({ action: "create", folderPath: "projects/new-directory" })
searchFilesAndFolders
Search for files and folders using glob patterns.
searchFilesAndFolders({ pattern: "projects/**/*.ts", includeMetadata: false })
// List all available aliases searchFilesAndFolders({ pattern: "*" }) // Result: [ { path: "projects", type: "directory" }, { path: "docs", type: "directory" } ]
// Read a file const content = await readFileContent({ filePath: "projects/README.md" }); // Write a file await writeFile({ filePath: "projects/notes.txt", content: "Important meeting notes." }); // Edit a file await editFile({ filePath: "projects/config.json", edits: [ { oldText: '"version": "1.0.0"', newText: '"version": "1.0.1"' } ] });
// Create a new directory await manageFolder({ action: "create", folderPath: "projects/new-feature" }); // List directory contents const files = await searchFilesAndFolders({ pattern: "projects/src/*" });
# From npm (coming soon) npm install -g BetterMCPFileServer # Not yet available # From source (current method) git clone https://github.com/martinschlott/BetterMCPFileServer.git cd BetterMCPFileServer npm install npm run build npm link # Optional, makes command available globally
Start the server with at least one alias:directory pair:
BetterMCPFileServer alias:directory [alias2:directory2 ...]
Examples:
# Single directory BetterMCPFileServer code:~/projects # Multiple directories BetterMCPFileServer code:~/Development docs:~/Documents/Technical notes:~/Notes
Create a simple shell script for consistent configuration:
#!/bin/bash # start-server.sh BetterMCPFileServer \ code:~/Development/MyProjects \ docs:~/Documents/Technical \ data:~/Data/Samples \ config:~/Configuration
alias:directory
This project was a collaboration between Martin Schlott (concept and design) and AI assistants:
README crafted by Claude 3.7 Sonnet
MIT License
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!