Read-Only MCP Filesystem Access: A Safer Knowledge Folder for OpenClaw
A personal agent that summarizes your notes does not need permission to rewrite them. That sounds obvious, but “please only read these files” is an instruction to a model—not a filesystem access policy.
The MCP reference servers’ v2.3.0 release adds a useful way to close that gap: the filesystem server can run with --read-only, and --confine-roots can stop a compatible client's Roots from widening the directories selected by the operator. The actual npm package in this release is @modelcontextprotocol/server-filesystem version 2.2.0. Do not confuse the repository release number with the package version. [1]
For OpenClaw users who connect this MCP server, these controls make a practical pattern easier: expose a small knowledge folder for reading, while keeping generated output in a separate writable workspace. They are upstream MCP server features, not a claim that every OpenClaw installation or Clawly plan already configures them.
What read-only actually enforces
With --read-only, the server registers only tools annotated readOnlyHint: true. Write-capable tools are absent from tools/list; calling an omitted tool directly fails as an unknown tool. This is server-side filtering, not merely hiding a button in the client. The versioned documentation and implementation PR describe the same behavior. [2][3]
There are three important limits:
- The mode applies to the whole server. It is not a separate permission switch for each directory.
- It does not restrict other tools. An agent with shell access or another writable file integration may still have a different route to the same files.
- Read-only is not confidential. Anything the agent can read can enter its context and potentially its responses. Keep secrets and unrelated personal records outside the exposed directory.
The goal is a smaller, testable capability—not a declaration that the entire agent is sandboxed.
Start with one narrow reader
For a locally installed filesystem server, the documented command can be combined with both controls:
mcp-server-filesystem --read-only --confine-roots /srv/agent-knowledge
This is a server launch example, not an OpenClaw configuration command. Replace the path with an existing, deliberately curated folder on the host running the MCP process. Configure your MCP integration to launch the reviewed package version with these arguments, using the setup format supported by your client. [2]
A good first folder contains copied documentation and a few harmless test notes. A poor first folder is your entire home directory, which may include credentials, browser profiles, private messages, and configuration backups.
Keep the server process's operating-system permissions narrow as well. Where applicable, a read-only container bind mount provides another boundary. Do not grant the process write access merely because the MCP tool list is filtered.
Why --confine-roots belongs in the design
The versioned server documentation describes a compatibility distinction: a client using the older, 2025-era Roots mechanism can replace the server's command-line allowed directories. With --confine-roots, those client-provided roots can narrow access but cannot widen it beyond the command-line directories. The corresponding implementation PR confirms this opt-in behavior. [2][4]
For example, if the operator allows /srv/agent-knowledge:
- A client root inside that folder can narrow the exposed area.
- A broader root is constrained to the allowed folder.
- A root outside the allowed folders is ignored and logged.
The flag needs explicit command-line directories to have an effect. It is not a substitute for selecting them. The same documentation says newer 2026-07-28 connections do not use the older Roots exchange; their command-line directories remain the allowlist. Check the behavior of the client and server you actually deploy rather than assuming all connections negotiate the same protocol era. [2]
If the agent also needs to write, separate the paths
A useful arrangement is:
Knowledge reader
/srv/agent-knowledge
read-only tools; confined roots
Draft writer
/srv/agent-drafts
write tools; confined roots
Use separate server instances and distinct directories. The writer should not expose a parent directory containing the knowledge folder. Apply --confine-roots to the writer too when older Roots-capable clients are in use; otherwise, client Roots could undermine the intended separation. The upstream README explicitly warns about this case. [2]
Also review shell tools, native file tools, and other MCP servers available to the same agent. If any can write to the protected folder, the overall workflow is not read-only even though the reader server is.
For higher-assurance separation, run the writer under an identity that cannot modify the knowledge folder. Avoid shared writable files or hard-linked copies across the two areas: different paths can still refer to the same underlying file.
Verify the boundary before adding real notes
Run these checks in a disposable fixture directory, through the same MCP client connection the agent will use. These are recommended acceptance tests, not a claim that we ran them against your installation.
| Check | Expected evidence |
|---|---|
| Discover the reader's tools | Read/list tools appear; write_file, edit_file, and other write-capable tools do not. |
| Read an allowed fixture | The expected harmless text is returned. |
Call write_file directly on the reader |
The server rejects the unknown tool; the fixture remains unchanged. |
| Read a fixture outside the allowed directory | Access is refused. |
| Read through an in-folder symlink to an outside fixture | Access is refused. |
| Advertise a broader root from an older Roots-capable client | Effective access stays inside the command-line boundary. |
| Write a new fixture through the separate writer | The draft is created, but the knowledge folder remains inaccessible to that writer. |
Record the package version, launch arguments, discovered tool names, and observed errors. Inspect list_allowed_directories and the server's effective-directory logs after connection, not just the launch configuration. Re-run the checks after reconnecting or changing client Roots. [2]
If a negative test unexpectedly succeeds, stop the rollout. Check for a second writable integration, an overly broad directory, missing flags, or a different server process than the one you intended to test. Do not compensate by adding a stronger prompt.
The practical takeaway
November's MCP filesystem update is useful because it moves one boundary out of natural-language instructions and into the server's exposed capabilities. Start with a narrow reader, confine any legacy client Roots, and keep draft-writing authority separate.
A successful setup should prove both halves of the contract: the agent can read the notes it needs, and the available execution paths cannot modify the notes it should only read.
Sources
Protect your AI agent with Clawly
Deploy your OpenClaw agent in an isolated, hardened container with encrypted credentials and managed updates. No DevOps required.
Deploy Your Agent