mcp-filesystem-server
by: mark3labs
Go server implementing Model Context Protocol (MCP) for filesystem operations.
📌Overview
Purpose: To provide a Go server that implements the Model Context Protocol (MCP) for efficient and secure filesystem operations.
Overview: The Filesystem MCP Server allows users to perform various filesystem operations, including reading and writing files, managing directories, and retrieving file metadata. It is designed to work within specific directories as defined by user configurations, ensuring secure access.
Key Features:
-
Read/Write Files: Enables reading the complete contents of a file and creating or overwriting existing files, ensuring UTF-8 encoding for text files.
-
Directory Management: Supports creating, listing, and deleting directories, including the ability to create parent directories as needed, ensuring smooth organization of file systems.
-
File Operations: Allows moving or renaming files and directories, alongside functionality for searching files with case-insensitive pattern matching.
-
Metadata Retrieval: Provides detailed metadata for files and directories, including size, creation, modified, and access times, along with type and permissions.
-
Access Control: Restricts operations to specified directories, thereby enhancing security by preventing unauthorized access to other parts of the filesystem.
Filesystem MCP Server
Go server implementing Model Context Protocol (MCP) for filesystem operations.
Features
- Read/write files
- Create/list/delete directories
- Move files/directories
- Search files
- Get file metadata
Note: The server only allows operations within directories specified via args
.
API
Resources
file://system
: File system operations interface
Tools
-
read_file
Reads complete contents of a file (UTF-8 encoded)
Input:path
(string) -
read_multiple_files
Reads multiple files simultaneously
Input:paths
(string[])
Failed reads won't stop the entire operation -
write_file
Create new file or overwrite existing (use with caution)
Inputs:path
(string): File locationcontent
(string): File content
-
create_directory
Create new directory or ensure it exists
Input:path
(string)
Creates parent directories if needed; succeeds silently if directory exists -
list_directory
List directory contents with [FILE] or [DIR] prefixes
Input:path
(string) -
move_file
Move or rename files and directories
Inputs:source
(string)destination
(string)
Fails if destination exists
-
search_files
Recursively search for files/directories
Inputs:path
(string): Starting directorypattern
(string): Search pattern
Case-insensitive matching, returns full paths to matches
-
get_file_info
Get detailed file/directory metadata
Input:path
(string)
Returns:- Size
- Creation time
- Modified time
- Access time
- Type (file/directory)
- Permissions
-
list_allowed_directories
Lists directories that the server is allowed to access
No input required
Usage with Claude Desktop
Install the server:
go install github.com/mark3labs/mcp-filesystem-server
Add this to your claude_desktop_config.json
:
{
"mcpServers": {
"filesystem": {
"command": "mcp-filesystem-server",
"args": [
"/Users/username/Desktop",
"/path/to/other/allowed/dir"
]
}
}
}
License
This MCP server is licensed under the MIT License. You are free to use, modify, and distribute the software, subject to the terms of the MIT License. See the LICENSE file in the project repository for details.