GF

Golang Filesystem Server

Created 6 months ago

MCP Filesystem Server provides secure access to the local filesystem via the Model Context Protocol.

development filesystem MCP server docker

What is Golang Filesystem Server?

Secure file operations with configurable access controls built with Go!

Documentation

MCP Filesystem Server

This MCP server provides secure access to the local filesystem via the Model Context Protocol (MCP).

Components# Resources

  • file:// - Name: File System - Description: Access to files and directories on the local file system

Tools## File Operations

  • read_file - Read the complete contents of a file from the file system
  • 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 file system
  • modify_file - Update file by finding and replacing text using string matching or regex

Directory Operations

  • list_directory - Get a detailed listing of all files and directories in a specified path
  • create_directory - Create a new directory or ensure a directory exists
  • tree - Returns a hierarchical JSON representation of a directory structure

Search and Information

  • search_files - Recursively search for files and directories matching a pattern
  • search_within_files - Search for text within file contents across directory trees
  • get_file_info - Retrieve detailed metadata about a file or directory
  • list_allowed_directories - Returns the list of directories that this server is allowed to access

Features

  • Secure access to specified directories
  • Path validation to prevent directory traversal attacks
  • Symlink resolution with security checks
  • MIME type detection
  • Support for text, binary, and image files
  • Size limits for inline content and base64 encoding

Getting Started# Installation

Using Go Install

 go install github.com/mark3labs/mcp-filesystem-server@latest

Usage## As a standalone server

 mcp-filesystem-server /path/to/allowed/directory [/another/allowed/directory ...]

As a library in your Go project

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)
 }
}

Usage with Model Context Protocol

{
 "mcpServers": {
 "filesystem": {
 "command": "mcp-filesystem-server",
 "args": ["/path/to/allowed/directory", "/another/allowed/directory"]
 }
 }
}

Docker## Running with Docker

docker run -i --rm ghcr.io/mark3labs/mcp-filesystem-server:latest /path/to/allowed/directory

Docker Configuration with MCP

{
 "mcpServers": {
 "filesystem": {
 "command": "docker",
 "args": [ "run", "-i", "--rm", "ghcr.io/mark3labs/mcp-filesystem-server:latest", "/path/to/allowed/directory" ]
 }
 }
}

If you need changes made inside the container to reflect on the host filesystem, you can mount a volume. This allows the container to access and modify files on the host system. Here's an example:

{
 "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" ]
 }
 }
}

License

See the LICENSE file for details.

Server Config

{
  "mcpServers": {
    "golang-filesystem-server-server": {
      "command": "npx",
      "args": [
        "golang-filesystem-server"
      ]
    }
  }
}

Links & Status

Repository: github.com
Hosted: Yes
Global: No
Official: Yes

Project Info

Hosted Featured
Created At: May 23, 2025
Updated At: Aug 07, 2025
Author: Mark3 Labs
Category: community
License: See the LICENSE file for details.
Tags:
development filesystem MCP