mcp-filesystem-server

MCP.Pizza Chef: mark3labs

The mcp-filesystem-server is a Go server implementing the Model Context Protocol (MCP) to provide structured, secure filesystem operations to LLMs and AI agents. It supports reading and writing files, creating, listing, and deleting directories, moving files and directories, searching files, and retrieving file metadata. The server restricts operations to specified directories for security and scoped access. It exposes a file system interface via the MCP protocol, enabling models to interact with the filesystem in real-time, facilitating advanced AI workflows that require file manipulation and directory management. This server is ideal for integrating filesystem context into AI-driven applications and agents.

Use This MCP server To

Read and write files within scoped directories Create, list, and delete directories securely Move files and directories programmatically Search files by name or content Retrieve metadata for files and directories Generate directory tree structures for navigation Support multi-file read operations with error tolerance

README

smithery badge

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
  • Generate directory tree structures

Note: The server will only allow operations within directories specified via args.

API

Resources

  • file://system: File system operations interface

Tools

  • read_file

    • Read complete contents of a file
    • Input: path (string)
    • Reads complete file contents with UTF-8 encoding
  • read_multiple_files

    • Read multiple files simultaneously
    • Input: paths (string[])
    • Failed reads won't stop the entire operation
  • write_file

    • Create new file or overwrite existing (exercise caution with this)
    • Inputs:
      • path (string): File location
      • content (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 directory
      • pattern (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
  • tree

    • Returns a hierarchical JSON representation of a directory structure
    • Inputs:
      • path (string): Directory to traverse (required)
      • depth (number): Maximum depth to traverse (default: 3)
      • follow_symlinks (boolean): Whether to follow symbolic links (default: false)
    • Returns formatted JSON with file/directory hierarchy
    • Includes file metadata (name, path, size, modified time)
  • list_allowed_directories

    • List all directories the server is allowed to access
    • No input required
    • Returns:
      • Directories that this server can read/write from

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. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.

mcp-filesystem-server FAQ

How does mcp-filesystem-server ensure security when accessing files?
It restricts all filesystem operations to directories specified via startup arguments, preventing unauthorized access outside these paths.
Can mcp-filesystem-server handle simultaneous file reads?
Yes, it supports reading multiple files at once with the read_multiple_files tool, and failed reads do not stop the entire operation.
What file operations are supported by mcp-filesystem-server?
It supports reading, writing, moving files and directories, creating and deleting directories, searching files, and retrieving file metadata.
How does mcp-filesystem-server integrate with LLMs like OpenAI, Claude, or Gemini?
It exposes filesystem operations via the MCP protocol, allowing LLMs to access and manipulate files securely and in real-time within their environment.
Is there any encoding limitation when reading files?
Yes, files are read with UTF-8 encoding to ensure consistent text handling.
Can I overwrite existing files using mcp-filesystem-server?
Yes, the write_file tool allows creating new files or overwriting existing ones, but caution is advised to avoid data loss.
Does mcp-filesystem-server provide directory structure visualization?
Yes, it can generate directory tree structures to help models understand filesystem organization.
How do I specify which directories mcp-filesystem-server can access?
Directories are specified via command-line arguments when starting the server, defining the scope of accessible filesystem paths.