Filesystem MCP server

Provides secure, permission-controlled access to local filesystems with granular controls for reading, writing, moving, and searching files while enforcing path validation and directory restrictions.
Back to servers
Setup instructions
Provider
Matei Canavra
Release date
Mar 26, 2025
Language
TypeScript
Stats
3 stars

The Filesystem MCP Server implements the Model Context Protocol for filesystem operations, providing secure file access with granular permission controls. It enables various file and directory operations within allowed directories while enforcing strict security boundaries.

Installation

Prerequisites

To install the Filesystem MCP Server, you need to have Bun installed:

curl -fsSL https://bun.sh/install | bash

Setup and Build

# Install dependencies
bun install

# Build the project (required for Node runtimes)
bun run build

Configuration Options

The server can be configured in several ways. Paths may include environment variables like $HOME, ${CUSTOM}, or %USERPROFILE%.

Local (Node or Bun)

# Using Node with built JavaScript
node /path/to/mcp-filesystem/dist/index.js $HOME/allowed-directory

# Using Bun to run TypeScript directly
bun /path/to/mcp-filesystem/index.ts $HOME/allowed-directory

Git Hosted

Run directly from the public repository:

# Using Bun
bunx github:rawr-ai/mcp-filesystem $HOME/allowed-directory

# Using NPX
npx github:rawr-ai/mcp-filesystem $HOME/allowed-directory

Docker

Run in an isolated container environment:

docker run --rm -v $HOME/allowed-directory:/data mcp/filesystem /data

Permission & Security

The server implements a comprehensive security model with granular controls:

Directory Access Control

Operations are strictly limited to directories specified during startup via args. All operations must remain within allowed directories, with path validation ensuring no directory traversal.

Permission Flags

  • --readonly: Enforces read-only mode (default if no flags are specified)
  • --full-access: Enables all operations (create, edit, move, delete)
  • Individual permission flags:
    • --allow-create: Allow creation of new files and directories
    • --allow-edit: Allow modification of existing files
    • --allow-move: Allow moving/renaming files and directories
    • --allow-delete: Allow deletion of files and directories

Symlink Handling

  • By default, symlinks are followed when both the link and target are within allowed directories
  • --no-follow-symlinks: Prevents traversal of symlinks

Available Tools

File Operations

Read File

{
  "tool": "read_file",
  "args": {
    "path": "/path/to/file.txt",
    "maxBytes": 10000
  }
}

Create File

{
  "tool": "create_file",
  "args": {
    "path": "/path/to/new_file.txt",
    "content": "File content goes here"
  }
}

Modify File

{
  "tool": "modify_file",
  "args": {
    "path": "/path/to/existing_file.txt",
    "content": "New file content"
  }
}

Edit File

Make selective edits using pattern matching:

{
  "tool": "edit_file",
  "args": {
    "path": "/path/to/file.txt",
    "edits": [
      {
        "oldText": "text to replace",
        "newText": "replacement text"
      }
    ],
    "dryRun": true,
    "maxBytes": 10000
  }
}

Directory Operations

Create Directory

{
  "tool": "create_directory",
  "args": {
    "path": "/path/to/new_directory"
  }
}

List Directory

{
  "tool": "list_directory",
  "args": {
    "path": "/path/to/directory"
  }
}

Directory Tree

{
  "tool": "directory_tree",
  "args": {
    "path": "/path/to/directory"
  }
}

File Management

Move File

{
  "tool": "move_file",
  "args": {
    "source": "/path/to/source.txt",
    "destination": "/path/to/destination.txt"
  }
}

Delete File

{
  "tool": "delete_file",
  "args": {
    "path": "/path/to/file.txt"
  }
}

Delete Directory

{
  "tool": "delete_directory",
  "args": {
    "path": "/path/to/directory",
    "recursive": true
  }
}

Search & Find

Search Files

{
  "tool": "search_files",
  "args": {
    "path": "/path/to/directory",
    "pattern": "search_term",
    "excludePatterns": ["node_modules", ".git"]
  }
}

Find Files by Extension

{
  "tool": "find_files_by_extension",
  "args": {
    "path": "/path/to/directory",
    "extension": "txt",
    "excludePatterns": ["temp"]
  }
}

Metadata & Information

Get File Info

{
  "tool": "get_file_info",
  "args": {
    "path": "/path/to/file.txt"
  }
}

Get Permissions

{
  "tool": "get_permissions",
  "args": {}
}

List Allowed Directories

{
  "tool": "list_allowed_directories",
  "args": {}
}

XML Tools

XML to JSON

{
  "tool": "xml_to_json",
  "args": {
    "xmlPath": "/path/to/file.xml",
    "jsonPath": "/path/to/output.json",
    "maxResponseBytes": 100000,
    "options": {
      "ignoreAttributes": false,
      "preserveOrder": true,
      "format": true,
      "indentSize": 2
    }
  }
}

XML Query

{
  "tool": "xml_query",
  "args": {
    "path": "/path/to/file.xml",
    "query": "//tagname",
    "includeAttributes": true,
    "maxResponseBytes": 200000
  }
}

Content Search

Regex Search Content

{
  "tool": "regex_search_content",
  "args": {
    "path": "/path/to/directory",
    "regex": "pattern to search",
    "filePattern": "*.js",
    "maxDepth": 3,
    "maxFileSize": 10485760,
    "maxResults": 50
  }
}

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "filesystem" '{"command":"npx","args":["-y","@modelcontextprotocol/server-filesystem","--full-access","/Users/username/Desktop","/path/to/other/allowed/dir"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "filesystem": {
            "command": "npx",
            "args": [
                "-y",
                "@modelcontextprotocol/server-filesystem",
                "--full-access",
                "/Users/username/Desktop",
                "/path/to/other/allowed/dir"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "filesystem": {
            "command": "npx",
            "args": [
                "-y",
                "@modelcontextprotocol/server-filesystem",
                "--full-access",
                "/Users/username/Desktop",
                "/path/to/other/allowed/dir"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later