Zenaique

The filesystem MCP server gives agents file access. How does it stop them from reading everything on disk?

Flashcard·Easy·4.0 · 0·~30s·Asked atDeepseekDifyReliance Jio·Relevant atAnthropic
Attempt it
TL;DR

The filesystem server restricts access via a directory allowlist on the command line; every path is resolved and checked against those roots, and the MCP protocol itself provides no isolation.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine giving a helper access to a few specific drawers in a filing cabinet, but nothing else. When you start the filesystem MCP server, you hand it a list of folders it is allowed to touch. The server can read files, write files, list folders, and search, but only inside those approved folders. If the helper asks for something from a drawer you did not approve, the server says no. The important part is that only the server enforces this rule. The MCP protocol itself does not know anything about files or folders. And the server runs as you, using your permissions. If you accidentally said 'every drawer in the building is fine,' the helper could go anywhere you could go. So you keep the list narrow.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

The filesystem MCP server is the first server most people install when they connect MCP to Claude Desktop or Cursor. It is also the clearest illustration of where MCP's security boundaries do and do not live, because the answer to 'how does it stop agents from reading everything?' exposes the full trust model.

This deep dive covers the allowlist mechanism, the tool surface, why the MCP protocol itself provides no isolation, the symlink resolution subtlety, and the patterns for hardening a deployment beyond the default.

The directory allowlist: the entire sandbox

The sandboxing model is a path check inside the server's own code, and nothing else.

At launch, the server takes one or more directories as command-line arguments: npx @modelcontextprotocol/server-filesystem /path/one /path/two. These are the allowed roots. Inside the server, every incoming tool call's path argument is resolved. Resolution means turning .. into actual parent traversal, following symlinks to their real targets, and normalizing casing on case-insensitive platforms. The resolved path is then checked against each allowed root. If it falls inside one of the roots, the operation proceeds. If not, the server returns a structured error.

A few subtleties matter. Symlink escapes are blocked because the check uses the resolved path, not the symbolic source. A symlink inside the allowed directory that points to /etc/passwd is rejected because /etc/passwd is outside the roots. Relative paths are joined to the server's working directory before resolution. Empty paths or null bytes are rejected at the input layer.

There is no per-tool ACL. If a directory is in the allowlist, every tool (read, write, edit, delete, move) can act on every file inside it. Finer-grained restrictions require writing a custom server.

The tool surface
Why the protocol provides no isolation
Why the allowlist lives on the command line
Hardening beyond the default
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • Claude Desktop users scope a filesystem server entry to `~/Documents/notes` so the agent can read and edit notes without touching anything else on disk.
  • Cursor users add a filesystem server scoped to a single project directory in `.cursor/mcp.json`, giving the agent file access beyond the editor's built-in tools.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow does the filesystem server prevent symlink escapes?
A

Every path argument is resolved (following symlinks to their real targets) before the allowlist check. A symlink pointing outside the allowed roots is rejected based on the resolved target, not the symbolic source.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Assuming the MCP protocol provides built-in sandboxing. It does not. The filesystem server's own path check plus the directories you allow on launch are the entire boundary.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Name the package and repository where the filesystem server lives.

  • List the headline tools the server exposes (read, write, edit, list, search).

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
What is the Model Context Protocol (MCP) and what problem does it solve?
MCQ·Easy