Filesystem MCP in Claude Code: one folder, an explicit allow-list
The filesystem server gives Claude Code file tools bound to the directories it is given on the command line, and it can be told to write nowhere at all. One flag, --confine-roots, is what actually holds it to that list.
That makes it the clearest example of what an MCP server is for, and also the one most often added for no reason. Claude Code already reads and writes the project it is in. This server earns its place when the folder you need is somewhere else.
Sources read November 25, 2026. By the Omniscio team. Updated .
What it gives Claude Code
The README lists the server's jobs plainly: read and write files, create, list and delete directories, move files and directories, search files, and get file metadata. The tools behind that are read_text_file, read_media_file, read_multiple_files, list_directory, list_directory_with_sizes, directory_tree, search_files, get_file_info, list_allowed_directories, create_directory, write_file, append_file, edit_file, move_file and copy_file.
Claude Code already answers the roots request with its launch directory plus every directory added with --add-dir, so a session can already see the project and anything else you deliberately handed it. That also means its roots can replace the directories you passed to the server: on the older protocol they do replace them unless you start it with --confine-roots, which keeps its roots inside your list. The filesystem server is for the case the working directories do not cover: a shared drive, a folder of reference material, a second repository you do not want to add wholesale.
Each tool carries annotations that say whether it reads, writes, repeats safely or destroys, and every one declares that it reaches no outside world — this server only touches the local filesystem.
The allow-list is also the security model: the README states the server may touch only its allowed directories, and on Windows a path naming an NTFS alternate data stream is refused even inside one.
The command
Run this in your terminal, not inside a session, with the directories you want to allow:
claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem --confine-roots /path/to/project-notesEverything after the double dash belongs to the server, and the trailing paths are its arguments. That is why the double dash is not optional here: without it, Claude Code would try to read the paths as its own options. --confine-roots is the flag that matters most in a Claude Code session, because Claude Code sends roots and, on the older protocol, those replace the list you pass unless the server is confined to it.
Options go with the directories and may sit before, between or after them. The two that change the server's behaviour most are --read-only, which leaves only the tools that read and list, and --read-only-dir <path>, which makes one listed directory read-only while the others stay writable:
claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem --read-only /path/to/reference
claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem --read-only-dir /path/to/reference /path/to/workspaceA third, --confine-roots, keeps a client's own roots inside the directories you gave: a root outside them is ignored and logged. It only matters for a client on the older roots protocol — which is the one Claude Code uses to answer the roots request.
The .mcp.json equivalent
The README's own entry, which is what project scope writes:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/username/Desktop",
"/path/to/other/allowed/dir"
]
}
}
}The same array takes the flags, in the same place they would go on the command line:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "--read-only", "/path/to/reference"]
}
}
}On Windows the README launches npx through cmd /c instead, with the same arguments after it.
The HTTP form exists too, for a server started once and connected to by URL: npx -y @modelcontextprotocol/server-filesystem --transport streamable-http /path serves http://127.0.0.1:3001/mcp, and the entry becomes "type": "http" with that URL. Over HTTP the directories must be on the command line, because the server cannot ask the client for roots.
Which scope to use
Local is the default: your configuration, this project only. Project scope writes .mcp.json at the repository root, and user scope makes it available in every project.
Local is the right default for this server, and for a specific reason: the arguments are absolute paths on one machine. A committed .mcp.json with /Users/ada/reference in it is wrong for everyone else. Use project scope only when the paths are portable — a folder inside the repository, or one built from a ${VAR} the file expands per machine.
A project-scoped server is approved on first use, so a fresh clone shows it as pending until someone runs claude interactively in that folder.
The auth step
There is none. The server runs on your machine, takes no token, and has no sign-in. The permission it needs is the allow-list you gave it on the command line. The only things that change it are another directory in that list and, for a client on the older roots protocol, the roots it sends — which --confine-roots pins back to the command line.
That is also why the read-only flags carry the weight here. On a folder you only want Claude to consult, --read-only removes every write tool from the server's list, and the server enforces that whatever the client is configured to allow.
Confirm it connected
claude mcp list
claude mcp get filesystemThe list prints a status beside the name, such as ✔ Connected, ! Needs authentication or ✘ Failed to connect, and ⏸ Pending approval (run claude to approve) for a project server nobody has approved. A local server never needs authentication, so a failure status means Claude Code could not reach it. claude mcp get filesystem prints the entry and an Issue: line when the connection failed.
Inside a session, /mcp lists the tools with their full names in the form mcp__filesystem__read_text_file. The first check worth running is the server's own list_allowed_directories: it returns exactly what the server will touch, which is a faster answer than reasoning about the command.
Then ask for a directory listing of one of them and confirm the names come back. That proves three things at once — the connection, the path, and the read permission.
The failure people hit
The one that looks like a crash is a server with no directory. The README is explicit: with no command-line arguments and a client on the older 2025-era protocol that does not support roots, it logs the reason to stderr, closes the connection and exits with status 1. A client that supports roots but sends none keeps the connection with no allowed directories, and a client on the newer 2026-07-28 protocol answers every tool call with an error saying so. Either way the fix is the path, not a retry.
The second is Node. The README asks for Node.js 24 or later when the server runs through npx, so a machine on an older runtime has a server that starts and then fails, and the version on the path Claude Code uses is the one that counts.
The third is a write that is refused when you expected it to work: a file inside a --read-only-dir fails with an access-denied error naming that directory, and a path outside the allowed directories is refused because every operation is restricted to them. That is the server enforcing the list, not a broken connection.
The message each of these prints belongs to the MCP errors guide, and the add command's flags and scopes are covered in full in Add an MCP server to Claude Code.
Sources
Every line on this page rests on one of these. The date beside each one is the day we read it.
- modelcontextprotocol/servers: filesystem, for the package name and npx form, the Node.js 24 floor, the allow-list and the exit-with-status-1 behaviour, the read-only and confine-roots flags, the tool list and annotations, the JSON blocks, the Windows
cmd /cform, the HTTP transport and its limits, and the Windows path restrictions. Read November 25, 2026. - Anthropic: Connect Claude Code to tools via MCP, for the double dash, the roots answer with the launch directory and
--add-dir, the scope table and approval prompt, the health statuses and the tool-name pattern. Read November 25, 2026.
Common questions
What is the command to add the filesystem MCP server to Claude Code?
claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem --confine-roots /path/to/dir. The directories after the package name are the allow-list, and --confine-roots stops a client's roots from replacing it.
Do I need the filesystem server if Claude Code already reads files?
Only when the folder you need is outside the session's working directories. Claude Code answers the roots request with its launch directory plus anything added with --add-dir, so a folder inside those needs no server at all.
How do I stop the filesystem server writing?
Add --read-only anywhere among the arguments. The server then registers only the tools that read and list, so a write tool is never listed and a call to it fails as an unknown tool.
Why did the filesystem server exit as soon as it started?
It was started with no directory and a client that does not send roots. The server requires at least one allowed directory, so in that case it logs the reason, closes the connection and exits with status 1; a roots-capable client that sends none keeps the connection with no allowed directories.
Does the filesystem server need Node.js?
Yes. The README states Node.js 24 or later when the server runs through npx or from source, so the Node version Claude Code can see decides whether it starts.
Every session, one window
Omniscio runs several agent sessions side by side in one window, each with its own context and its own diff view. Any model, any harness — Claude Code, Codex, OpenCode, Devin, Pi, and Hermes all supported.