A comprehensive Model Context Protocol (MCP) Server that provides powerful file system operations through standardized tools. This server enables AI assistants and other MCP clients to interact with the file system safely and efficiently.
- Read/Write Files: Read content from files or create new files with custom content
- Append Content: Add content to existing files without overwriting
- Delete Files: Remove files from the file system
- Copy Files: Duplicate files to new locations
- Move/Rename Files: Relocate or rename files
- Create Directories: Make new directories with automatic parent creation
- Delete Directories: Remove directories with optional recursive deletion
- List Directory Contents: Browse files and folders with filtering options
- File Name Search: Find files by name patterns with wildcard support
- Content Search: Search for text within files across directories
- Regex Search: Advanced pattern matching using regular expressions
- Recursive Searching: Search through subdirectories
- File Metadata: Get detailed information about files and directories
- Path Validation: Check if files or directories exist
- Directory Size: Calculate total size of directories including subdirectories
- Working Directory: Get and set current working directory
- .NET 8.0: Built on the latest .NET platform
- C# 12.0: Using modern C# language features
- Model Context Protocol: Implements MCP server specification
- JSON Serialization: Structured responses for easy integration
- Docker Support: Ready for containerized deployment
- .NET 8.0 SDK or later
- Compatible MCP client (Claude Desktop, VS Code with MCP extension, etc.)
git clone https://github.com/jihadkhawaja/MCP.FileSystem.git
cd MCP.FileSystem
dotnet build
dotnet run --project MCP.FileSystem
docker build -t mcp-filesystem .
docker run -it mcp-filesystem
Add to your Claude Desktop configuration:
{
"mcpServers": {
"MCP.FileSystem": {
"command": "dotnet",
"args": ["run", "--project", "path/to/MCP.FileSystem.csproj"]
}
}
}
Configure in your MCP settings:
"servers": {
"MCP.FileSystem": {
"type": "stdio",
"command": "dotnet",
"args": [
"run",
"--project",
"path/to/MCP.FileSystem.csproj"
]
}
}
Tool | Description | Parameters |
---|---|---|
ReadFile |
Read content from a file | filePath |
WriteFile |
Write content to a file | filePath , content , overwrite? |
AppendToFile |
Append content to a file | filePath , content |
DeleteFile |
Delete a file | filePath |
CopyFile |
Copy a file | sourcePath , destinationPath , overwrite? |
MoveFile |
Move/rename a file | sourcePath , destinationPath , overwrite? |
Tool | Description | Parameters |
---|---|---|
CreateDirectory |
Create a directory | directoryPath |
DeleteDirectory |
Delete a directory | directoryPath , recursive? |
ListDirectory |
List directory contents | directoryPath , searchPattern? , includeSubdirectories? |
Tool | Description | Parameters |
---|---|---|
SearchFiles |
Search for files by pattern | directoryPath , searchPattern? , includeSubdirectories? , maxResults? |
SearchInFiles |
Search for text in files | directoryPath , searchText , filePattern? , includeSubdirectories? , caseSensitive? , maxResults? |
SearchInFilesRegex |
Search using regex patterns | directoryPath , regexPattern , filePattern? , includeSubdirectories? , caseSensitive? , maxResults? |
Tool | Description | Parameters |
---|---|---|
GetFileInfo |
Get file/directory metadata | path |
PathExists |
Check if path exists | path |
GetCurrentDirectory |
Get current working directory | - |
SetCurrentDirectory |
Set current working directory | path |
GetDirectorySize |
Calculate directory size | directoryPath |
All tools return structured JSON responses:
{
"success": true,
"message": "File written successfully",
"path": "/path/to/file.txt",
"size": 1024
}
{
"error": "File not found",
"path": "/path/to/nonexistent.txt"
}
{
"success": true,
"searchPath": "/search/directory",
"matches": [
{
"file": "/path/to/match.txt",
"fileName": "match.txt",
"lineNumber": 42,
"line": "Found matching content here",
"matchPosition": 6
}
],
"count": 1,
"truncated": false
}
- Path Validation: All file paths are validated to prevent directory traversal attacks
- Error Handling: Comprehensive error handling prevents information leakage
- Permission Respect: Operations respect file system permissions
- Sandboxing: Consider running in a containerized environment for additional security
- Fork the repository
- Create a 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
Microsoft.Extensions.Hosting
(9.0.7) - Application hosting frameworkModelContextProtocol
(0.3.0-preview.2) - MCP server implementationMicrosoft.VisualStudio.Azure.Containers.Tools.Targets
(1.22.1) - Docker support
This project is licensed under the MIT License - see the LICENSE file for details.
- Initial release with comprehensive file system operations
- Support for file and directory operations
- Advanced search capabilities with regex support
- Docker deployment support
- Complete MCP server implementation
For questions, issues, or contributions, please visit the GitHub repository or open an issue.
Note: This MCP server provides powerful file system access. Ensure you understand the security implications and run it in appropriate environments with proper access controls.