Filesystem MCP server

Provides secure, controlled filesystem operations within a project's root directory, enabling safe file listing, reading, writing, and searching with robust path validation.
Back to servers
Setup instructions
Provider
shtse8
Release date
Apr 04, 2025
Language
TypeScript
Package
Stats
5.6K downloads
6 stars

The Filesystem MCP Server is a Node.js implementation of the Model Context Protocol that provides secure file system access for AI agents like Claude. It allows AI assistants to read, write, and manipulate files within a defined project directory while maintaining security and optimizing token usage.

Installation Options

Using npx/bunx (Recommended)

The simplest installation method is through your MCP host configuration file (like Roo/Cline's mcp_settings.json):

For npx:

{
  "mcpServers": {
    "filesystem-mcp": {
      "command": "npx",
      "args": ["@sylphlab/filesystem-mcp"],
      "name": "Filesystem (npx)"
    }
  }
}

For bunx:

{
  "mcpServers": {
    "filesystem-mcp": {
      "command": "bunx",
      "args": ["@sylphlab/filesystem-mcp"],
      "name": "Filesystem (bunx)"
    }
  }
}

Note: The server uses its Current Working Directory as the project root. Ensure your MCP Host launches the command with the cwd set to your project's root directory.

Using Docker

For containerized environments, use the official Docker image:

{
  "mcpServers": {
    "filesystem-mcp": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-v",
        "/path/to/your/project:/app",
        "sylphlab/filesystem-mcp:latest"
      ],
      "name": "Filesystem (Docker)"
    }
  }
}

Remember to replace /path/to/your/project with your actual project path.

Features and Usage

The Filesystem MCP Server provides a comprehensive set of file manipulation tools for AI agents:

File and Directory Operations

Exploring and Inspecting Files

  • List files and directories (including recursively)
  • Get detailed status for multiple items

Example agent interaction:

<use_mcp_tool>
  <server_name>filesystem-mcp</server_name>
  <tool_name>list_files</tool_name>
  <arguments>{"path": "src", "recursive": true}</arguments>
</use_mcp_tool>

Reading and Writing Content

  • Read, write, or append to multiple files
  • Automatically creates parent directories when needed

Example for reading:

<use_mcp_tool>
  <server_name>filesystem-mcp</server_name>
  <tool_name>read_content</tool_name>
  <arguments>{"paths": ["src/index.ts", "package.json"]}</arguments>
</use_mcp_tool>

Example for writing:

<use_mcp_tool>
  <server_name>filesystem-mcp</server_name>
  <tool_name>write_content</tool_name>
  <arguments>{
    "operations": [
      {"path": "src/new-file.js", "content": "console.log('Hello world');"}
    ]
  }</arguments>
</use_mcp_tool>

Editing and Searching Files

  • Make precise edits (insert, replace, delete) with preserved indentation
  • Search files using regex with context
  • Perform search and replace across multiple files

Example for searching:

<use_mcp_tool>
  <server_name>filesystem-mcp</server_name>
  <tool_name>search_files</tool_name>
  <arguments>{
    "pattern": "function\\s+main",
    "paths": ["src/**/*.ts"],
    "context_lines": 2
  }</arguments>
</use_mcp_tool>

File Management

  • Create multiple directories (with parent directories)
  • Delete files/directories recursively
  • Move/rename/copy files and directories
  • Change permissions and ownership

Example for creating directories:

<use_mcp_tool>
  <server_name>filesystem-mcp</server_name>
  <tool_name>create_directories</tool_name>
  <arguments>{"paths": ["new-dir/nested", "another-dir"]}</arguments>
</use_mcp_tool>

Benefits and Advantages

Security and Efficiency

  • Project Root Confinement: All operations are restricted to the project directory
  • Batch Operations: Reduces AI-server communication and saves tokens
  • Detailed Error Reporting: Status reports for each operation in a batch
  • Direct API Usage: More efficient than spawning shell processes

Performance

The server is optimized for AI agent interactions through:

  • Reduced communication overhead via batch operations
  • Efficient direct API calls instead of shell commands
  • Detailed result formatting that minimizes token usage

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-mcp" '{"command":"npx","args":["@sylphlab/filesystem-mcp"],"name":"Filesystem (npx)"}'

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-mcp": {
            "command": "npx",
            "args": [
                "@sylphlab/filesystem-mcp"
            ],
            "name": "Filesystem (npx)"
        }
    }
}

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-mcp": {
            "command": "npx",
            "args": [
                "@sylphlab/filesystem-mcp"
            ],
            "name": "Filesystem (npx)"
        }
    }
}

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