Skip to content
Back to search

mcp-filesystem-server

Go server implementing Model Context Protocol (MCP) for filesystem operations.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/mark3labs--mcp-filesystem-server/badge.svg)](/listings/mark3labs--mcp-filesystem-server)

HTML

<a href="/listings/mark3labs--mcp-filesystem-server"><img src="/api/listings/mark3labs--mcp-filesystem-server/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Installation

Using Go Install

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

Usage

As a standalone server

Start the MCP server with allowed directories:

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

To integrate this server with apps that support MCP:

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

Docker

Running with Docker

You can run the Filesystem MCP server using Docker:

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

Docker Configuration with MCP

To integrate the Docker image with apps that support 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"
      ]
    }
  }
}

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 201 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # MCP Filesystem Server
  2. This MCP server provides secure access to the local filesystem via the Model Context Protocol (MCP).
  3. ## Components
  4. ### Resources
  5. - **file://**
  6. - Name: File System
  7. - Description: Access to files and directories on the local file system
  8. ### Tools
  9. #### File Operations
  10. - **read_file**
  11. - Read the complete contents of a file from the file system
  12. - Parameters: `path` (required): Path to the file to read
  13. - **read_multiple_files**
  14. - Read the contents of multiple files in a single operation
  15. - Parameters: `paths` (required): List of file paths to read
  16. - **write_file**
  17. - Create a new file or overwrite an existing file with new content
  18. - Parameters: `path` (required): Path where to write the file, `content` (required): Content to write to the file
  19. - **copy_file**
  20. - Copy files and directories
  21. - Parameters: `source` (required): Source path of the file or directory, `destination` (required): Destination path
  22. - **move_file**
  23. - Move or rename files and directories
  24. - Parameters: `source` (required): Source path of the file or directory, `destination` (required): Destination path
  25. - **delete_file**
  26. - Delete a file or directory from the file system
  27. - Parameters: `path` (required): Path to the file or directory to delete, `recursive` (optional): Whether to recursively delete directories (default: false)
  28. - **modify_file**
  29. - Update file by finding and replacing text using string matching or regex
  30. - Parameters: `path` (required): Path to the file to modify, `find` (required): Text to search for, `replace` (required): Text to replace with, `all_occurrences` (optional): Replace all occurrences (default: true), `regex` (optional): Treat find pattern as regex (default: false)
  31. #### Directory Operations
  32. - **list_directory**
  33. - Get a detailed listing of all files and directories in a specified path
  34. - Parameters: `path` (required): Path of the directory to list
  35. - **create_directory**
  36. - Create a new directory or ensure a directory exists
  37. - Parameters: `path` (required): Path of the directory to create
  38. - **tree**
  39. - Returns a hierarchical JSON representation of a directory structure
  40. - Parameters: `path` (required): Path of the directory to traverse, `depth` (optional): Maximum depth to traverse (default: 3), `follow_symlinks` (optional): Whether to follow symbolic links (default: false)
  41. #### Search and Information
  42. - **search_files**
  43. - Recursively search for files and directories matching a pattern
  44. - Parameters: `path` (required): Starting path for the search, `pattern` (required): Search pattern to match against file names
  45. - **search_within_files**
  46. - Search for text within file contents across directory trees
  47. - Parameters: `path` (required): Starting directory for the search, `substring` (required): Text to search for within file contents, `depth` (optional): Maximum directory depth to search, `max_results` (optional): Maximum number of results to return (default: 1000)
  48. - **get_file_info**
  49. - Retrieve detailed metadata about a file or directory
  50. - Parameters: `path` (required): Path to the file or directory
  51. - **list_allowed_directories**
  52. - Returns the list of directories that this server is allowed to access
  53. - Parameters: None
  54. ## Features
  55. - Secure access to specified directories
  56. - Path validation to prevent directory traversal attacks
  57. - Symlink resolution with security checks
  58. - MIME type detection
  59. - Support for text, binary, and image files
  60. - Size limits for inline content and base64 encoding
  61. ## Getting Started
  62. ### Installation
  63. #### Using Go Install
  64. ```bash
  65. go install github.com/mark3labs/mcp-filesystem-server@latest
  66. ```
  67. ### Usage
  68. #### As a standalone server
  69. Start the MCP server with allowed directories:
  70. ```bash
  71. mcp-filesystem-server /path/to/allowed/directory [/another/allowed/directory ...]
  72. ```
  73. #### As a library in your Go project
  74. ```go
  75. package main
  76. import (
  77. "log"
  78. "os"
  79. "github.com/mark3labs/mcp-filesystem-server/filesystemserver"
  80. )
  81. func main() {
  82. // Create a new filesystem server with allowed directories
  83. allowedDirs := []string{"/path/to/allowed/directory", "/another/allowed/directory"}
  84. fs, err := filesystemserver.NewFilesystemServer(allowedDirs)
  85. if err != nil {
  86. log.Fatalf("Failed to create server: %v", err)
  87. }
  88. // Serve requests
  89. if err := fs.Serve(); err != nil {
  90. log.Fatalf("Server error: %v", err)
  91. }
  92. }
  93. ```
  94. ### Usage with Model Context Protocol
  95. To integrate this server with apps that support MCP:
  96. ```json
  97. {
  98. "mcpServers": {
  99. "filesystem": {
  100. "command": "mcp-filesystem-server",
  101. "args": ["/path/to/allowed/directory", "/another/allowed/directory"]
  102. }
  103. }
  104. }
  105. ```
  106. ### Docker
  107. #### Running with Docker
  108. You can run the Filesystem MCP server using Docker:
  109. ```bash
  110. docker run -i --rm ghcr.io/mark3labs/mcp-filesystem-server:latest /path/to/allowed/directory
  111. ```
  112. #### Docker Configuration with MCP
  113. To integrate the Docker image with apps that support MCP:
  114. ```json
  115. {
  116. "mcpServers": {
  117. "filesystem": {
  118. "command": "docker",
  119. "args": [
  120. "run",
  121. "-i",
  122. "--rm",
  123. "ghcr.io/mark3labs/mcp-filesystem-server:latest",
  124. "/path/to/allowed/directory"
  125. ]
  126. }
  127. }
  128. }
  129. ```
  130. 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:
  131. ```json
  132. {
  133. "mcpServers": {
  134. "filesystem": {
  135. "command": "docker",
  136. "args": [
  137. "run",
  138. "-i",
  139. "--rm",
  140. "--volume=/allowed/directory/in/host:/allowed/directory/in/container",
  141. "ghcr.io/mark3labs/mcp-filesystem-server:latest",
  142. "/allowed/directory/in/container"
  143. ]
  144. }
  145. }
  146. }
  147. ```
  148. ## License
  149. See the [LICENSE](LICENSE) file for details.

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.