Back to catalog
Golang Filesystem Server MCP Server
This MCP server provides secure access to the local filesystem through the Model Context Protocol, offering comprehensive file and directory operations with path validation and security controls.
Get this MCP server
This MCP server provides secure access to the local filesystem through the Model Context Protocol, offering comprehensive file and directory operations with path validation and security controls.
Installation
Go Install
go install github.com/mark3labs/mcp-filesystem-server@latest
Standalone Server
mcp-filesystem-server /path/to/allowed/directory [/another/allowed/directory ...]
Docker
docker run -i --rm ghcr.io/mark3labs/mcp-filesystem-server:latest /path/to/allowed/directory
Go Library
package main
import (
"log"
"os"
"github.com/mark3labs/mcp-filesystem-server/filesystemserver"
)
func main() {
// Create a new filesystem server with allowed directories
allowedDirs := []string{"/path/to/allowed/directory", "/another/allowed/directory"}
fs, err := filesystemserver.NewFilesystemServer(allowedDirs)
if err != nil {
log.Fatalf("Failed to create server: %v", err)
}
// Serve requests
if err := fs.Serve(); err != nil {
log.Fatalf("Server error: %v", err)
}
}
Configuration
MCP Configuration
{
"mcpServers": {
"filesystem": {
"command": "mcp-filesystem-server",
"args": ["/path/to/allowed/directory", "/another/allowed/directory"]
}
}
}
Docker MCP Configuration
{
"mcpServers": {
"filesystem": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"ghcr.io/mark3labs/mcp-filesystem-server:latest",
"/path/to/allowed/directory"
]
}
}
}
Docker with Volume Mount
{
"mcpServers": {
"filesystem": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--volume=/allowed/directory/in/host:/allowed/directory/in/container",
"ghcr.io/mark3labs/mcp-filesystem-server:latest",
"/allowed/directory/in/container"
]
}
}
}
Available Tools
| Tool | Description |
|---|---|
read_file |
Read the complete contents of a file from the filesystem |
read_multiple_files |
Read the contents of multiple files in a single operation |
write_file |
Create a new file or overwrite an existing file with new content |
copy_file |
Copy files and directories |
move_file |
Move or rename files and directories |
delete_file |
Delete a file or directory from the filesystem |
modify_file |
Update a file by searching and replacing text using string search or regex |
list_directory |
Get a detailed listing of all files and directories at the specified path |
create_directory |
Create a new directory or ensure that a directory exists |
tree |
Returns a hierarchical JSON representation of the directory structure |
search_files |
Recursively search for files and directories matching a pattern |
search_within_files |
Search for text in file contents within directory trees |
get_file_info |
Get detailed metadata about a file or directory |
list_allowed_directories |
Returns the list of directories this server is allowed to access |
Features
- Secure access to designated directories
- Path validation to prevent directory traversal attacks
- Symbolic link resolution with security checks
- MIME type detection
- Support for text, binary, and image files
- Size limits for embedded content and base64 encoding
Notes
This server provides file:// resources for accessing files and directories in the local filesystem. Built with Go and supports customizable allowed directories for enhanced security.
