Back to MCP Catalog

Filesystem MCP Server

File SystemsTypeScript
Access and manipulate files and directories with comprehensive filesystem operations
Available Tools

read_file

Read complete contents of a file with UTF-8 encoding

path

read_multiple_files

Read multiple files simultaneously, with failed reads not stopping the entire operation

paths

write_file

Create new file or overwrite existing file with specified content

pathcontent

edit_file

Make selective edits to a file using advanced pattern matching and formatting with options for dry run preview

patheditsdryRun

create_directory

Create new directory or ensure it exists, creating parent directories if needed

path

list_directory

List directory contents with [FILE] or [DIR] prefixes

path

move_file

Move or rename files and directories

sourcedestination

search_files

Recursively search for files/directories using patterns with exclusion options

pathpatternexcludePatterns

get_file_info

Get detailed file/directory metadata including size, timestamps, type, and permissions

path

list_allowed_directories

List all directories the server is allowed to access

The Filesystem MCP provides a secure interface for AI assistants to interact with your local filesystem. It enables reading, writing, and editing files, creating and managing directories, searching for content, and retrieving file metadata - all while maintaining strict access controls to only the directories you explicitly allow. With powerful features like advanced file editing with pattern matching, directory traversal, and detailed file information retrieval, this MCP gives AI assistants the ability to help with file management tasks, code editing, and document manipulation while maintaining security through sandboxed access.

Overview

The Filesystem MCP server provides a secure way for AI assistants to interact with your local filesystem. It implements the Model Context Protocol (MCP) to enable file operations while maintaining strict access controls.

Installation

You can install and run the Filesystem MCP server using either NPX or Docker. Both methods allow you to specify which directories the server is allowed to access.

Installation with Claude Desktop

Add the following configuration to your claude_desktop_config.json file:

Using NPX:

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/path/to/allowed/directory",
        "/path/to/another/allowed/directory"
      ]
    }
  }
}

Using Docker:

{
  "mcpServers": {
    "filesystem": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "--mount", "type=bind,src=/path/to/allowed/directory,dst=/projects/allowed",
        "--mount", "type=bind,src=/path/to/another/directory,dst=/projects/another,ro",
        "mcp/filesystem",
        "/projects"
      ]
    }
  }
}

Note: When using Docker, all directories must be mounted to /projects by default. You can add the ro flag to make a directory read-only.

Installation with VS Code

Add the following to your VS Code User Settings (JSON) file or to .vscode/mcp.json in your workspace:

Using NPX:

{
  "mcp": {
    "servers": {
      "filesystem": {
        "command": "npx",
        "args": [
          "-y",
          "@modelcontextprotocol/server-filesystem",
          "${workspaceFolder}"
        ]
      }
    }
  }
}

Using Docker:

{
  "mcp": {
    "servers": {
      "filesystem": {
        "command": "docker",
        "args": [
          "run",
          "-i",
          "--rm",
          "--mount", "type=bind,src=${workspaceFolder},dst=/projects/workspace",
          "mcp/filesystem",
          "/projects"
        ]
      }
    }
  }
}

Security Considerations

The Filesystem MCP server only allows operations within directories explicitly specified in the configuration. This sandboxing approach ensures that AI assistants cannot access files outside of the allowed directories.

When using Docker, you can further restrict access by mounting directories with the ro (read-only) flag, which prevents the server from making any modifications to those directories.

Building from Source

If you prefer to build the Docker image yourself:

docker build -t mcp/filesystem -f src/filesystem/Dockerfile .

Usage Examples

Once installed, the AI assistant can use the Filesystem MCP to perform various operations:

  1. Reading file contents:

    • Ask the assistant to "Show me the contents of file.txt"
  2. Editing files:

    • Ask the assistant to "Replace all occurrences of 'foo' with 'bar' in file.txt"
  3. Directory operations:

    • Ask the assistant to "List all files in the current directory"
    • Ask the assistant to "Create a new directory called 'test'"
  4. Searching:

    • Ask the assistant to "Find all JavaScript files containing 'function'"
  5. File information:

    • Ask the assistant to "Get information about file.txt"

Related MCPs

Text Editor
File SystemsPython

Line-oriented text file editor optimized for LLM tools

Box File Access
File SystemsTypeScript

Access, search, and read files from your Box account

Filesystem Access
File SystemsJava

Access and manipulate files on your local filesystem

About Model Context Protocol

Model Context Protocol (MCP) allows AI models to access external tools and services, extending their capabilities beyond their training data.

Generate Cursor Documentation

Save time on coding by generating custom documentation and prompts for Cursor IDE.