File Systems·
beginner
·14 min read·Apr 4, 2026·Updated Oct 10, 2026
By Rad Tome·Lead AI Systems Architect·How we verify this

Filesystem MCP Server Configuration Guide

Configure the official Filesystem MCP server for Claude Desktop, Cursor, and Codex CLI: Sandboxed directories, path traversal security, and tools.

filesystemfileslocal-storagefile-managementmcpsandboxingdeveloper-toolsclaude-desktop
Config Target: claude_desktop_config.json
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "C:/Projects"
      ]
    }
  }
}
Interactive Tool
1-Click Export

Generate & Test Filesystem MCP Server Config

One-click export with environment variables & path locators for Claude Desktop, Cursor, Windsurf, and OpenAI Codex CLI.

Open in Generator

Filesystem MCP Server Configuration Guide

The official Filesystem Model Context Protocol (MCP) server provides AI hosts with controlled read, write, and directory inspection access to explicitly designated local storage directories. For developers using Claude Desktop, Cursor, and OpenAI Codex CLI, scoped filesystem access serves as the baseline primitive for codebase refactoring, log analysis, and automated project builds.

Granting LLM agents direct file access requires strict isolation. Without rigorous sandbox boundaries, an agent can follow symlinks outside target folders, expose credentials (.env, ~/.ssh/id_rsa), or corrupt host filesystems. The official server enforces boundary restrictions directly at the protocol layer.

The sections below walk through the sandboxed execution model, host configuration JSON/TOML, tool calling semantics, and production error mitigation.


1. System Architecture and Sandboxed Execution

The Filesystem MCP server executes as a dedicated child process communicating with the AI host over Standard Input and Output (stdio). At startup, the server receives a list of authorized directory paths via its command-line arguments. These paths form a closed sandbox boundary.

diagram

Security Boundary Check

Path Traversal Escape

Inside Allowed Root

AI Host: Claude Desktop / Cursor / Codex CLI

stdio JSON-RPC Pipe

Filesystem MCP Server Process

Canonical Path Resolver: realpath

Within Authorized Sandbox?

-32004 Access Denied

Local Filesystem IO

Core Security Invariants

  1. ▸Explicit Directory Boundaries: The server only permits operations inside the exact directories passed to its command-line arguments. If an authorized path is /home/user/workspace, any request targeting /home/user/documents is immediately rejected.
  2. ▸Canonical Realpath Resolution: To prevent symlink escapes and directory traversal attacks (such as ../../etc/passwd), the server resolves symlinks using fs.realpathSync() and verifies that the canonical target resides within an allowed root.
  3. ▸Pure Data IO: The filesystem server provides file reading, editing, and listing tools. It possesses no shell execution capabilities, preventing command injection vulnerabilities.

2. Environment Prerequisites and Software Matrix

Verify that your workstation satisfies the following software requirements:

ComponentMinimum VersionInstallation CheckPurpose
Node.js>= 18.0.0 (20+ recommended)node -vJavaScript runtime environment
npm / npx>= 9.0.0npx -vPackage runner for executing MCP servers
@modelcontextprotocol/server-filesystemLatest releasePackage registryOfficial reference filesystem server

Create a designated sandbox directory for development:

bash
# macOS / Linux
mkdir -p ~/projects/mcp-sandbox

# Windows PowerShell
New-Item -ItemType Directory -Force -Path "$HOME\projects\mcp-sandbox"

3. Multi-Host Configuration Snippets

Configure your AI clients to launch the Filesystem server over stdio. Provide absolute paths to your allowed directories.

Claude Desktop Configuration (claude_desktop_config.json)

On macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
On Windows: %APPDATA%\Claude\claude_desktop_config.json

json
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/Users/developer/projects/mcp-sandbox",
        "/Users/developer/documents/specs"
      ]
    }
  }
}

[!IMPORTANT] On Windows, format paths using forward slashes (e.g. C:/Users/developer/projects/mcp-sandbox) or double backslashes (C:\\Users\\developer\\projects\\mcp-sandbox). Single backslashes act as escape characters in JSON and will invalidate the file.

Cursor IDE Configuration (.cursor/mcp.json)

json
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "./src",
        "./tests"
      ]
    }
  }
}

OpenAI Codex CLI Configuration (~/.codex/config.toml)

toml
[mcp_servers.filesystem]
command = "npx"
args = [
  "-y",
  "@modelcontextprotocol/server-filesystem",
  "/home/developer/projects/mcp-sandbox"
]

4. Exposed Tools and Capability Reference

The Filesystem MCP server exposes an extensive suite of granular file management tools:

Tool NameParametersDescription
read_filepathReads complete UTF-8 contents of a single file
read_multiple_filespathsBatch reads multiple files in a single turn to save round trips
write_filepath, contentAtomically creates or replaces a file with complete content
edit_filepath, editsPerforms surgical line replacements (diff-based) without rewriting
create_directorypathCreates nested directories recursively
list_directorypathReturns direct children with names and entry types
directory_treepathRecursively maps a tree structure of project directories
move_filesource, destinationMoves or renames files within the sandbox boundaries
search_filespath, patternSearches for files matching glob expressions
get_file_infopathRetrieves file size, creation timestamp, and modification date

5. JSON-RPC 2.0 Wire Payloads

Inspecting the underlying protocol framing helps diagnose communication issues between host and server.

Tool Invocation: Reading a File (tools/call)

json
{
  "jsonrpc": "2.0",
  "id": "fs-read-101",
  "method": "tools/call",
  "params": {
    "name": "read_file",
    "arguments": {
      "path": "/home/developer/projects/mcp-sandbox/package.json"
    }
  }
}

Formatted Response Payload

json
{
  "jsonrpc": "2.0",
  "id": "fs-read-101",
  "result": {
    "content": [
      {
        "type": "text",
        "text": "{\n  \"name\": \"mcp-sandbox\",\n  \"version\": \"1.0.0\",\n  \"type\": \"module\"\n}"
      }
    ]
  }
}

Tool Error Response (Sandbox Violation)

When an agent attempts to read an unauthorized path:

json
{
  "jsonrpc": "2.0",
  "id": "fs-read-102",
  "result": {
    "isError": true,
    "content": [
      {
        "type": "text",
        "text": "Access denied: Path '/etc/passwd' is outside of allowed directories."
      }
    ]
  }
}

6. Common Errors and Production Troubleshooting

When operating the filesystem server across various development workflows, watch for the following operational errors:

Error: Access denied - path outside allowed directories

  • ▸Root Cause: The requested file path is not within the directories specified in the client configuration args.
  • ▸Resolution: Verify that the path provided in the prompt matches the absolute path declared in your config. Remember that relative paths (./) resolve relative to the server working directory, not your current shell directory.

Error: File Truncation on Large Rewrites (write_file)

  • ▸Root Cause: When an AI agent attempts to rewrite a 1,500-line source file using write_file, output token generation limits may cause the response to cut off mid-file, corrupting the code.
  • ▸Resolution: Prompt the agent to use edit_file for targeted line substitutions, or chunk modifications across separate helper modules.

Error: spawn npx ENOENT on Windows or Non-Login Shells

  • ▸Root Cause: The host application could not find npx in the system environment PATH.
  • ▸Resolution: Provide the absolute binary path in command:
    • ▸Windows: C:\\Program Files\\nodejs\\npx.cmd
    • ▸macOS / Linux: /usr/local/bin/npx or /opt/homebrew/bin/npx

7. External Citations and Security Guardrails

Adhere to these operational security best practices when granting filesystem permissions:

Technical Changelog

Weekly Protocol Diffs & Verified Drops

New server guides, benchmarks, and security audits. No spam. Unsubscribe anytime.

Zero marketing spam. 1-click unsubscribe anytime.

Ready to Deploy?

Build your full agent toolstack in the Visual Generator

Combine Filesystem with databases, search APIs, and memory graphs in a single configuration file.

Customize in Generator
Developer Verification & Feedback
0 reports

Did this setup guide work with your AI host?

Help test this configuration across Claude, Cursor, and Codex CLI. Be the first to report:

Filesystem MCP Server Configuration Guide FAQ

What is the Filesystem MCP Server Configuration Guide?

Configure the official Filesystem MCP server for Claude Desktop, Cursor, and Codex CLI: Sandboxed directories, path traversal security, and tools.

How do I configure Filesystem MCP Server Configuration Guide in Claude Desktop or Cursor?

You can copy the configuration JSON from our guide or launch the interactive MCP Codex Config Generator at https://mcp-codex.com/generator to export valid configs in 1 click.

Can I use Filesystem MCP Server Configuration Guide with the OpenAI Codex CLI?

Yes, OpenAI Codex CLI supports Model Context Protocol. You can add it directly to ~/.codex/config.toml or pass arguments to codex mcp add.

RT

Written by Rad Tome

Lead AI Systems Architect & Maintainer, MCP Codex

@RadTome

Specializing in Model Context Protocol (MCP) integrations, autonomous AI agent orchestration, and distributed developer toolchains. Researches and benchmarks production MCP client-server architectures across OpenAI Codex, Claude, and Cursor.

Editorial Integrity: Package names are checked against the npm registry and repositories against the GitHub API. Where a package could not be verified, the guide says so instead of giving you a command to run.