Filesystem MCP server

Read, write, and manipulate local files through a controlled API.
Back to servers
Provider
Mark III Labs
Release date
Nov 28, 2024
Language
Go
Stats
241 stars

The Filesystem MCP Server implements the Model Context Protocol for performing filesystem operations. It allows you to read and write files, manage directories, search for files, and get detailed file information through a standardized interface that can be used with AI assistants like Claude.

Installation

To install the Filesystem MCP Server, use Go's package manager:

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

Configuration

The server only allows operations within directories explicitly specified during startup. This is an important security feature to prevent unrestricted filesystem access.

Configuration with Claude Desktop

To use this server with Claude Desktop, add the following to your claude_desktop_config.json file:

{
  "mcpServers": {
    "filesystem": {
      "command": "mcp-filesystem-server",
      "args": [
        "/Users/username/Desktop",
        "/path/to/other/allowed/dir"
      ]
    }
  }
}

Replace the paths in the args array with the directories you want to allow access to.

Available Tools

File Operations

Reading Files

To read the contents of a file:

read_file
Input: path (string) - The path to the file

To read multiple files simultaneously:

read_multiple_files
Input: paths (string[]) - Array of file paths

Note: Failed reads won't stop the entire operation when reading multiple files.

Writing Files

To create a new file or overwrite an existing one:

write_file
Inputs:
- path (string): File location
- content (string): File content

Use this tool with caution as it will overwrite existing files.

Directory Operations

Creating Directories

To create a new directory:

create_directory
Input: path (string) - The path to create

This will create parent directories if needed and succeed silently if the directory already exists.

Listing Directory Contents

To list the contents of a directory:

list_directory
Input: path (string) - The directory path

Results include file or directory indication with [FILE] or [DIR] prefixes.

Moving Files and Directories

To move or rename files and directories:

move_file
Inputs:
- source (string): Original location
- destination (string): New location

This operation will fail if the destination already exists.

Search and Information

Searching for Files

To search for files recursively:

search_files
Inputs:
- path (string): Starting directory
- pattern (string): Search pattern

The search is case-insensitive and returns full paths to all matches.

Getting File Information

To retrieve detailed metadata about a file or directory:

get_file_info
Input: path (string) - The path to examine

Returns size, creation time, modified time, access time, type, and permissions.

Directory Visualization

Tree Structure

To generate a hierarchical representation of a directory:

tree
Inputs:
- path (string): Directory to traverse
- depth (number): Maximum depth (default: 3)
- follow_symlinks (boolean): Whether to follow symbolic links (default: false)

Returns a formatted JSON with file/directory hierarchy including metadata.

System Information

Listing Allowed Directories

To see which directories the server has access to:

list_allowed_directories
No input required

Returns all directories that the server is configured to access.

How to add this MCP server to 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 > MCP and click "Add new global MCP server".

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

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

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