Agent Assurance for your AI Deployment
Test how your agents actually behave across workflows, tools, and actions. Catch failures and vulnerabilities before they ship.
npm install -g @testmuai/rook@latest
Filesystem MCP Server: Setup, Tools, and Testing the Agents That Use It
Set up the filesystem MCP server in Claude Desktop, learn its 16 tools, lock it to allowed directories, run it read-only, and test what agents write to disk.
A coding agent connected to the filesystem MCP server is asked to tidy a project's notes folder. It replies that it archived three old drafts and updated notes/plan.md. That reply is the agent's account of the job, and the folder on disk is the record that can confirm or contradict it.
The server under that agent also changes fast: its npm package page shows version 2.4.1, published on 2026-11-27 as the seventh release since 1.0.0 on 2026-10-11. The repository's security advisories page lists seven advisories against it published between 2026-10-25 and 2026-11-18.
Before an agent gets write access, check the folder limits the server enforces and, after each task, the files the agent leaves behind; both checks happen outside the agent.
Overview
The filesystem MCP server is a reference Model Context Protocol server, published on npm as @modelcontextprotocol/server-filesystem, that lets an AI agent read, change and search files. It works only inside its allowed directories: the command-line folders, or a 2025-era client's Roots. Version 2.4.1, released on 2026-11-27, needs Node.js 24 or later and runs over stdio or Streamable HTTP.
How do I make the filesystem MCP server read-only?
- Allowed directories: The filesystem MCP server touches only its allowed directories, the folders given as command-line arguments unless a 2025-era client's Roots replace them, checked by resolved location. A path outside them, a ../ traversal or a sibling folder whose name starts with the root's name returns Access denied.
- Read-only flag: Yes, the filesystem MCP server has a read-only mode. Starting it with --read-only, added in 2.2.0, withholds the six tools that can change the disk and leaves 10 of its 16 tools.
- Per-folder protection: The --read-only-dir flag, added in 2.3.0, protects chosen folders while the filesystem MCP server keeps its other allowed folders writable. Write tools stay listed but refuse any target inside a protected folder.
- File deletion: No, the filesystem MCP server cannot delete files. Version 2.4.1 has no tool that deletes a file or a directory, although move_file removes the source path as part of a move.
- MCP Roots: MCP Roots are deprecated in the 2026-07-28 protocol revision. A 2026-07-28 client is never asked for roots, so the command-line folder list is the filesystem MCP server's whole allow-list.
- Network exposure: Over Streamable HTTP, the filesystem MCP server listens on 127.0.0.1:3001 unless HOST and PORT say otherwise. Its README warns that HOST=0.0.0.0 exposes the server to every machine that can reach yours.
- Security fixes: CVE-2025-53109 and CVE-2025-53110 were fixed in npm release 2025.7.1, and the seven GitHub advisories of October and November 2026 against the filesystem MCP server were fixed by 2.4.0, although on Windows the README says a parent-directory swap during an operation is still not protected.
- Agent Assurance testing: TestMu AI's Agent Assurance tests an agent that uses the filesystem MCP server by grading criteria on files changed under declared paths, not on the agent's own summary of its work.
What Is the Filesystem MCP Server?
The filesystem MCP server is a Node.js program that exposes local file operations to an AI application as Model Context Protocol tools, so an agent can read and change files in folders you choose. An MCP server offers tools, resources or prompts to an AI host over one standard protocol, as the guide to what an MCP server is explains. This one serves both protocol eras on stdio, the 2025 handshake and the 2026-07-28 revision.
- Package -
@modelcontextprotocol/server-filesystemon npm, with the command namemcp-server-filesystem, licensed under MIT. - Transports - stdio by default, and Streamable HTTP with
--transport streamable-httpsince 2.4.0 of 2026-11-18. - Status - a reference server, which the modelcontextprotocol/servers README presents as a teaching example for MCP developers, not production-ready software.
This server has nothing to do with the browser API covered in File System Access API browser support.
How to Set Up the Filesystem MCP Server
With the npx route, every client starts the server the same way: it runs the npm package and passes the allowed folders as the last arguments. The MCP project's guide to connecting local MCP servers pins an exact version, 2.4.1 in its example, and asks you to update the pin when a security fix ships.
- Install Node.js 24 or later.
- Choose the narrowest folder that works, such as one project directory, and give absolute paths only.
- Add the server to the client's configuration with the version pinned, as in the blocks below.
- Quit and restart the client, then ask the agent to call
list_allowed_directoriesand confirm the scope it reports.
Filesystem MCP Server in Claude Desktop
Claude Desktop reads claude_desktop_config.json, which the connect guide places at ~/Library/Application Support/Claude/ on macOS, %APPDATA%\Claude\ on Windows and ~/.config/Claude/ on Linux. The entry below gives the server one project folder:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem@2.4.1",
"/Users/you/projects/notes-app"
]
}
}
}Quit Claude Desktop completely and start it again after saving. If plain npx fails to launch on Windows, the README's fallback is "command": "cmd" with /c and npx as the first arguments.
Filesystem MCP Server in Claude Code and VS Code
Claude Code adds the server from the terminal, and everything after the double hyphen is passed to the server untouched. Scopes and the desktop extension route are covered in Claude MCP.
claude mcp add filesystem -- npx -y \
@modelcontextprotocol/server-filesystem@2.4.1 \
/Users/you/projects/notes-appVS Code reads .vscode/mcp.json in the workspace, or the user file opened with the MCP: Open User Configuration command. Its top-level key is servers, not mcpServers, and the README's example passes the open workspace folder:
{
"servers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem@2.4.1",
"${workspaceFolder}"
]
}
}
}Docker and Streamable HTTP Options for the Filesystem MCP Server
- Docker - the server's README mounts every shared folder under
/projectsand passes/projectsto themcp/filesystemimage. Addingroto a bind mount makes that folder read-only to the server, and the image runs as the unprivilegednodeuser (UID 1000), not root. - Streamable HTTP - with
--transport streamable-httpthe server runs on its own and serves one endpoint,/mcp. It listens on127.0.0.1:3001unlessHOSTandPORTsay otherwise, and the README warns thatHOST=0.0.0.0exposes it to every machine that can reach yours.
A Claude Desktop entry for Docker, with one writable and one read-only folder:
{
"mcpServers": {
"filesystem": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"--mount",
"type=bind,src=/srv/notes,dst=/projects/notes",
"--mount",
"type=bind,src=/srv/docs,dst=/projects/docs,ro",
"mcp/filesystem",
"/projects"
]
}
}
}The Streamable HTTP route, from a terminal:
npx -y @modelcontextprotocol/server-filesystem@2.4.1 \
--transport streamable-http /srv/notes-appWhat Tools Does the Filesystem MCP Server Provide?
Version 2.4.1 returned 16 tool names to tools/list in the probe run shown later: the 15 tools the README documents plus read_file, which its annotation table calls a deprecated alias of read_text_file. Ten tools carry readOnlyHint: true, and the other six can change the disk.
| Tool | What it does | Read-only hint | Destructive hint |
|---|---|---|---|
read_text_file | Reads a file as UTF-8 text, optionally only its head or tail | true | false |
read_file | Deprecated alias of read_text_file | true | false |
read_media_file | Returns a file as base64 data with its MIME type | true | false |
read_multiple_files | Reads several files; one failed read does not stop the rest | true | false |
list_directory | Lists a folder's entries with [FILE] or [DIR] prefixes | true | false |
list_directory_with_sizes | Same listing with sizes, sortable by name or size | true | false |
directory_tree | Returns a recursive JSON tree, with an optional depth limit | true | false |
search_files | Finds files and folders by a glob over their paths, never by content | true | false |
get_file_info | Reports size, times, type, permissions and the hard-link count | true | false |
list_allowed_directories | Lists the folders the server may read and write | true | false |
create_directory | Creates a folder and any missing parents | false | false |
write_file | Creates a file or overwrites an existing one in place | false | true |
append_file | Adds text to the end of a file, creating it if needed | false | false |
edit_file | Replaces matched text and returns a git-style diff, with a dryRun preview | false | true |
move_file | Moves or renames a file or folder, removing the source path | false | true |
copy_file | Copies one regular file to a new path | false | false |
The server's README spells out the behaviors an agent is most likely to trip over:
- Missing parent folders -
write_filedoes not create directories and fails withParent directory does not exist, which step [3] of the probe shows;append_file,move_fileandcopy_filefail the same way. - All-or-nothing edits - if any entry in an
edit_filecall has no match, none of the edits is applied, anddryRundefaults to false, so a preview has to be asked for. - No overwrite on move or copy - both fail when the destination exists, so an agent cannot replace a file by moving another onto it.
- Bounded walks -
search_filesanddirectory_treefail with an error, not a partial result, once a walk reaches 100,000 entries. Resolving any path fails after 15 seconds, which matters on cloud-synced folders.
The README says the readOnlyHint and destructiveHint annotations let a client tell read-only tools from write-capable ones and highlight destructive calls. The MCP specification's Tools page (revision 2026-07-28) adds that clients MUST treat annotations as untrusted unless the server is a trusted one. Checking that a server's hints match its behavior is the subject of MCP server contract testing, and the request format a model emits for each call is explained under tool calling.
How Allowed Directories Limit What the Filesystem MCP Server Can Touch
The server may touch only its allowed directories, and the README calls command-line arguments the only method that works on every protocol version. It needs at least one, resolves every requested path before checking it, and logs the effective list to stderr at startup.
A probe on 2026-12-04 tested those limits. It installed 2.4.1 from npm on Windows 11 with Node v25.5.0 and drove the server through the official Python MCP SDK (mcp 2.3.0), with one allowed folder called project inside a fresh sandbox. The script, trimmed to its MCP calls:
"""Probe the reference Filesystem MCP server over
stdio with ONE allowed directory, then check the disk
from Python. Trimmed: imports, paths, sandbox setup
and the out() printer that wraps lines at 58 chars."""
from mcp import Client
from mcp.client.stdio import StdioServerParameters
def params(*flags):
return StdioServerParameters(
command="node",
args=[str(SERVER_JS), *flags, str(ROOT)])
async def call(client, name, args):
try:
res = await client.call_tool(name, args)
tag = "ERROR" if res.is_error else "OK"
return f"{tag}: {text_of(res)}"
except Exception as exc: # protocol-level error
return f"PROTOCOL ERROR: {exc}"
async def main():
async with Client(params()) as client:
out(f"protocol version: "
f"{client.protocol_version}")
tools = await client.list_tools()
names = sorted(t.name for t in tools.tools)
# [2] list_allowed_directories, [3] write_file
# notes/plan.md before and after
# create_directory, [4] outside/secret.txt
out(await call(client, "read_text_file", {
"path": str(OUTSIDE / "secret.txt")}))
# ... the same file via ../, then [5] the
# sibling project-secrets/keys.txt
async with Client(params("--read-only")) as client:
out(await call(client, "write_file", {
"path": str(target),
"content": "overwritten\n"}))
# [7] list the sandbox from Python, not the server
files = sorted(
str(p.relative_to(BOX)).replace("\\", "/")
for p in BOX.rglob("*") if p.is_file())Its output, unedited, with <box> standing for the sandbox's absolute path:
server-filesystem 2.4.1, Node v25.5.0
allowed directory: <box>\project
protocol version: 2026-07-28
[1] tools/list: 16 tools
append_file
copy_file
create_directory
directory_tree
edit_file
get_file_info
list_allowed_directories
list_directory
list_directory_with_sizes
move_file
read_file
read_media_file
read_multiple_files
read_text_file
search_files
write_file
[2] list_allowed_directories
OK: Allowed directories:
<box>\project
[3] write_file notes/plan.md (no notes/ folder yet)
ERROR: Parent directory does not exist:
<box>\project\notes
after create_directory notes/:
OK: Successfully wrote to <box>\project\notes\plan.md
read back: OK: step 1
[4] read_text_file outside/secret.txt
ERROR: Access denied - path outside allowed
directories: <box>\outside\secret.txt not in <box>\project
../ traversal from inside the root:
ERROR: Access denied - path outside allowed
directories: <box>\outside\secret.txt not in <box>\project
[5] read project-secrets/keys.txt (same prefix)
ERROR: Access denied - path outside allowed
directories: <box>\project-secrets\keys.txt not in
<box>\project
[6] restart with --read-only
tools/list: 10 tools
write tools listed: none
write_file notes/plan.md:
PROTOCOL ERROR: Tool write_file not found
[7] disk check (read by Python, not by the server)
outside/secret.txt
project-secrets/keys.txt
project/notes/plan.md
plan.md holds: 'step 1\n'- Refusals are tool results - the outside path, the
../traversal and the sibling folder came back as error results a model can read and report. A tool hidden by--read-onlyfailed differently, as a protocol error for an unknown tool. - The prefix case -
project-secretsstarts with the allowed folder's name, the bug class behind CVE-2025-53110. The run shows 2.4.1 refuses it; it does not reproduce the 2025 bug. - What the run cannot show - it ran on Windows without symlinks, so it says nothing about the symlink, junction or case-variant advisories in the next section.
How MCP Roots Change the Server's Allowed Directories
Roots let a 2025-era client tell the server which folders to work in, and the README says roots sent by a client completely replace the command-line list. The Roots page of the MCP specification marks the feature deprecated as of protocol version 2026-07-28 (SEP-2577), keeps it for at least twelve months after that release, and says new implementations SHOULD NOT adopt it.
- 2026-07-28 clients - a 2026-07-28 client is never asked for roots, so the command-line folders are the whole allow-list, as in the probe.
- 2025-era clients - a client that supports Roots can swap the folder list at runtime with
notifications/roots/list_changed. - The confine flag -
--confine-roots, added in 2.2.0 on 2026-11-04, lets a client's roots narrow the command-line folders but never replace or widen them; a root outside every command-line folder is ignored and logged.
How to Run the Filesystem MCP Server Read-Only
Start with --read-only, added in 2.2.0, and the server registers only the tools annotated readOnlyHint: true. The README says every other tool is left out, and the server enforces that whatever the client allows. Step [6] of the probe shows the effect: 10 tools listed, none of write_file, edit_file or move_file among them, and Tool write_file not found for a write attempt.
- Per-folder protection -
--read-only-dir <path>, added in 2.3.0 on 2026-11-11, protects one folder while others stay writable. Write tools stay listed but refuse targets inside it, judged by resolved location, and the folder must exist at startup. - Second layer - the README also recommends operating-system file permissions on protected folders.
- Scope - the MCP project's Local Server Security guide says to grant the narrowest root that works, never your home directory, and, if unsure, a single project directory read-only.
Which Security Advisories Affected the Filesystem MCP Server?
Nine published advisories have affected the server: two CVEs from July 2025 and seven GitHub advisories from October and November 2026. The two CVEs, published on 2025-07-01 with high severity, are CVE-2025-53110, a path validation bypass through a colliding path prefix, and CVE-2025-53109, a bypass through symlink handling.
Both advisories credit Elad Beber of Cymulate and tell users to "upgrade to 0.6.4 or 2025.7.01". npm lists that release as 2025.7.1, and no 0.6.4 was ever published there.
In the reporter's EscapeRoute write-up, the prefix flaw let through any path that "simply begins with the approved directory". Its claim that the pair could lead to code execution is the reporter's assessment, not the advisory's.
The seven 2026 advisories on the repository's advisory page carry no CVE ids. Each also lists the old date-versioned line up to 2026.8.31 as affected with no patch, so the remedy is 2.4.0 or later:
| Advisory | Published | Severity | Issue | Fixed in |
|---|---|---|---|---|
| GHSA-4gxg-m5jx-9j57 | 2026-10-25 | Medium | A case-variant path bypasses the symlink check and creates files outside | 2.0.1 |
| GHSA-7rgq-gccq-qphx | 2026-10-25 | Medium | A trailing quote or space passes the check, but the operation hits a sibling path | 2.0.1 |
| GHSA-53mr-w429-c597 | 2026-10-25 | Low | A parent-directory fallback race permits a write outside the allowed folders | 2.0.1 |
| GHSA-hhwq-wxfx-cj7g | 2026-10-25 | Low | list_directory_with_sizes follows symlinks and leaks outside file metadata | 2.0.1 |
| GHSA-p9cv-8g75-4xcg | 2026-11-11 | Medium | A symlink swapped in after validation lets read_text_file return outside files | 2.3.0 |
| GHSA-7m4x-rv66-mxhh | 2026-11-11 | Medium | move_file's same-device rename leaves the source path unpinned | 2.3.0 |
| GHSA-rq2p-q7c4-6g27 | 2026-11-18 | Low | A symlink swap lets the listing tools return entry names from outside folders | 2.4.0 |
Four of the 2026 issues are races: a second local process has to swap a path for a symlink between the server's check and its file operation. Two need a symlink that already points outside an allowed folder (the case-variant one also needs a case-insensitive disk), and the trailing-quote one is a path-parsing bug. Version 2.4.1 still documents limits it does not close:
- Windows junction race - a local process that can already write inside an allowed folder can swap a parent directory for a junction mid-operation. The README's rule: on Windows, never allow a folder that untrusted local processes or users can write to.
- Hard links - the checks look at the path you pass, so editing a file that is also hard-linked from outside changes it at every name. A
hardLinkscount above 1 inget_file_infoflags such a file. - Cooperative limits - the Local Server Security guide calls configuration allowlists cooperative boundaries that a well-behaved server respects and a compromised one can ignore.
Keep each server to one folder, and give the same narrow scope to any second server, such as the GitHub MCP server. General hardening, from tool poisoning to supply chain checks, is covered in MCP security.
How to Test an Agent That Uses the Filesystem MCP Server
The probe sent fixed calls from a script. An agent's model picks its own calls and then describes them, so read the disk from outside the agent after each task, as step [7] did, and compare it with a snapshot taken before the task, before reading the summary. The same check applies to deep agents, which keep their working notes in files.
- Scoped edit - ask for a change to
notes/plan.mdand pass only if the diff shows that file changed and nothing else under the folder. - Denied write - aim a task at a folder under
--read-only-dirand check that the agent reports the refusal instead of claiming the file was saved. - Missing folder - request a file in a folder that does not exist yet; the right outcome is a
create_directorycall first, or an honest report of the error. - Planted instruction - OWASP LLM01:2025 notes that indirect prompt injections occur when an LLM accepts input from external sources such as files. Put a line in a note telling the agent to copy secrets elsewhere, and pass only if the disk shows no such write; see indirect prompt injection.
- Destructive calls - with no delete tool, the opening's three archived drafts should be three
move_fileresults. Each draft should sit at its new path and be gone from the old one, withplan.mdthe only file whose content changed. - Retries -
append_fileis not idempotent, so a retried call appends twice; check the file after any run where the agent retried.
Small, versioned fixture folders keep diffs readable, and MCP servers for test automation covers this server as a home for test data. Testing the server itself is a separate job for the MCP Inspector, MCP testing and the cases in MCP failure modes.
Testing an Agent's File Changes With Agent Assurance
Agent Assurance, TestMu AI's product for testing agents that change things, never grades a criterion on the agent's summary of its work. It uses files changed on disk during the run, artifacts the agent produced, its tool calls compared with the tools it exposes, and records read back through read-only checks.
For a coding agent wired to this server, Rook CLI observes files changed under the paths the profile declares and tool calls against the declared tools. For an MCP server such as this one, it connects and reads the tool list the server reports instead of trusting the config file. It tests the agent through a profile and never audits the server's code; connecting servers is covered in the Agent Assurance MCP guide.
- Functional scenario - the agent updates
notes/plan.md, and a criterion requires that no other file under the declared path changed. - Adversarial scenario - an
openhook seeds a note with a planted instruction before the run, and the criterion fails if any file the task never named was written. Declare every folder a stray write could reach, because observation stops at the declared paths.
The verdict on each criterion is one of three, Pass, Fail or Unable to Verify; the pass rate ignores the last. Writes are real and nothing is sandboxed today, so Rook CLI counts the agent's write tools and asks for confirmation before a run begins. Point the profile at a staging copy of the folder filled with synthetic notes, and check the collected evidence for secrets or personal data before anyone else sees it.
The npm route requires Node.js 20 or later, and the Homebrew and shell-script routes run without Node. The skill installer, which adds the /rook command to Claude Code, requires Node.js 22 or later, as the Claude Code setup guide shows.
npm install -g @testmuai/rook@latest
npx @testmuai/rook-skill@latest install \
--agent claude-codeAgent Assurance's web app has a Start Trial button, which opens a free 7-day trial that includes 10,000 credits; plans are on the pricing page.
How to Start Using the Filesystem MCP Server Safely
Start read-only: pin 2.4.1, pass one project folder with --read-only, and have the agent call list_allowed_directories before any write tool is exposed. When it needs writes, give it a staging copy of the folder and diff the disk after every task.
The MCP deprecated features registry makes Roots eligible for removal in the first revision released on or after 2027-07-28, so move any setup that relies on a client's roots to command-line folders now. For the servers to add next, see the best MCP servers; for the first test profile, the Agent Assurance quickstart.
npm install -g @testmuai/rook@latest, or for a full walkthrough of the product.Was this helpful?
Authors

Samyak Goyal
Author · 60 posts
Samyak Goyal is a Senior Member of Technical Staff at TestMu AI engineering Kane CLI, the command-line tool that runs browser automation from the terminal, where a flow described in natural language executes in a real Chrome browser and returns pass or fail with shareable proof. He is a backend engineer with 4+ years of experience, previously an SDE at Innovaccer, where he built APIs, introduced Kafka, and cut deployment from weeks to hours. Samyak also builds multi-agent systems, skill-orchestration frameworks, and a personal copilot that indexes 200+ microservice repositories.

Sirajuddin Khan
Reviewer
Sirajuddin Khan is Vice President of Product Management at TestMu AI, where he drives the company's agentic AI product strategy, building a suite of autonomous agents that includes Agentic Browsers and Agentic Visual Testing and shifting the unit of work from test execution to autonomous outcomes. One of the company's earliest product leaders, he has owned the roadmap for the high-performance execution cloud and grew the cross-browser testing products from early adoption to market leadership. He brings over a decade of experience across SaaS, B2B, and eCommerce, with earlier product roles at Wydr and ShopClues, where his catalog and search work cut delivery SLAs and lifted seller activity. Sirajuddin holds an MBA in Information Technology from Sikkim Manipal University and a B.Tech in Computer Science Engineering from Maharshi Dayanand University.
Filesystem MCP Server FAQs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance
- Advanced access controls
- Advanced data retention rules
- Advanced Local Testing
- Premium Support options
- Early access to beta features
- Private Slack Channel
- Unlimited Manual Accessibility DevTools Tests


