AI Engineering7 min read

    Filesystem MCP Server: A Safe Setup for Founders

    Set up the filesystem MCP server so an AI can read your files without seeing everything. Read-only mode, folder limits and one setting most guides miss.

    James Killick

    The filesystem MCP server lets an AI app read, search and edit files in the folders you choose. You name those folders when you start it. For a safe setup, do three things: pick one small folder, turn on read-only mode, and add --confine-roots. That last one is the setting most guides skip.

    Here's the setup, and why each part matters.

    What is the filesystem MCP server?

    It's one of the reference servers kept by the MCP project. It gives an AI tools to read files, list folders, search for files and, unless you stop it, write and move them. The server may only touch its allowed directories (filesystem server README).

    New to MCP? Start with what is an MCP server.

    One warning first. The MCP project says its reference servers are examples to learn from, not production-ready solutions. It tells you to check your own security needs (MCP servers repo). So go small and careful.

    What you need

    • Node.js 24 or newer. The server's README says Node 24 or later when you run it with npx.
    • An MCP client. This guide uses Claude Code.
    • One folder you're happy for an AI to read. A folder of notes or a project works well.

    Step 1: Pick the folder

    Pick the smallest folder that does the job. Good: /Users/you/Documents/client-notes. Bad: your whole home folder, or anything with passwords, .env files or tax records in it.

    Rule of thumb: if you wouldn't hand the folder to a new contractor on day one, don't allow it.

    Step 2: Add the server in read-only mode

    The server takes its allowed folders as command-line arguments. The README calls this the method that works on every protocol version. It also has a --read-only flag. In that mode the server lists only the tools that can't change anything, and a call to a write tool fails as an unknown tool.

    With Claude Code, the pattern is claude mcp add --transport stdio <name> -- <command>. Everything after the double dash runs your server (Claude Code docs).

    claude mcp add --transport stdio filesystem -- npx -y @modelcontextprotocol/server-filesystem@2.3.0 --read-only --confine-roots /Users/you/Documents/client-notes
    

    Swap in your own folder path. We pinned version 2.3.0, which we tested.

    Step 3: Understand --confine-roots

    This is the part that matters.

    Some AI apps tell the server which folder they're working in. This is called "roots". The README says that for 2025-era clients, the roots a client sends completely replace the folders you named. It also says the roots method is deprecated as of the 2026-07-28 protocol version.

    Claude Code can send roots. Its docs say it answers the roots request with the folder you launched it from, plus any extra folders you've added to the session (Claude Code docs).

    So here's what can go wrong. You allow client-notes. You start Claude Code in a much bigger folder. The roots message arrives. Your small folder gets replaced by the big one.

    The --confine-roots flag stops that. The README says the client's roots can then narrow your folders but never replace or widen them.

    We tested this. We ran the server with a fake client that reported a wider folder, one level above the folder we allowed.

    SetupRead a file in a different folder
    No flagWorked. The wider folder replaced the one we named
    --confine-roots"Access denied - path outside allowed directories"

    We didn't run Claude Code itself for this test. We simulated a client that sends a wider root. But it shows why the flag is worth adding.

    Step 4: Check what the AI can see

    Start Claude Code and ask: "List the allowed directories with the filesystem server." Make sure only your one folder shows.

    Then ask it to read a file outside that folder. It should be refused. We tried this against the server directly and got "Access denied - path outside allowed directories".

    In read-only mode we also checked the tool list. The write tools were gone: write_file, edit_file, move_file, copy_file, create_directory and append_file weren't listed. Ten read tools were left, such as read_text_file, list_directory, search_files and get_file_info.

    What not to expose

    • Secrets. .env files, API keys, password exports. If it's in the folder, the AI can read it.
    • Your whole home folder. Bigger folders mean more to leak by mistake.
    • Client files. Keep other people's private data out unless you have a reason and permission.

    One more habit: treat the text inside files as untrusted. A file can contain instructions that look like they came from you. In read-only mode, an AI that follows a bad instruction still can't change or delete your files.

    When you need write access

    Sometimes you want the AI to save files, like a draft or a summary. Do it on purpose:

    1. Make a new, empty folder just for the AI's output.
    2. Give it write access to that folder only. The README has a --read-only-dir option that marks folders read-only while others stay writable.
    3. Keep your real files in a separate, read-only folder.

    For defence in depth, the README also suggests setting read-only permissions at the operating system level.

    Where to go next

    Want to go further? Read the best MCP servers for founders for other servers worth adding. Or build your own with our Node.js MCP server guide. For the full build picture, there's how to build an MCP server, and MCP vs API explains how they fit together. Using the Claude app instead of Claude Code? The README has a Claude Desktop setup, and setting up Claude Desktop for a small team covers the app.

    FAQ

    What is the filesystem MCP server used for?

    Letting an AI app read and search files on your computer, and optionally write them. You choose the folders it may use.

    Is the filesystem MCP server safe?

    It's as safe as the folders you give it. Use a small folder, turn on --read-only and add --confine-roots. The MCP project also says its reference servers aren't production-ready.

    Does it work on Windows?

    The README has a setup for Windows, which launches npx through cmd /c. Check it for the exact config.

    Your next step

    Pick one small folder. Run the claude mcp add command above, then ask Claude to list its allowed directories.