Skip to content

Commit be9d4b6

Browse files
cliffhallclaude
andcommitted
docs(filesystem): state the read-only rule instead of listing the write tools
The list would go stale as write tools are added independently; the rule (every tool not annotated readOnlyHint: true is hidden) does not. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent 331a6c0 commit be9d4b6

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎.changeset/632-filesystem-read-only.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"@modelcontextprotocol/server-filesystem": minor
33
---
44

5-
Add a `--read-only` command-line flag. With it the server registers only the tools annotated `readOnlyHint: true`, so `write_file`, `edit_file`, `create_directory` and `move_file` are not listed and cannot be called, on both protocol eras and whether the directories come from the command line or a client's Roots. `--` now ends the options, so a directory named like an option can still be given after it.
5+
Add a `--read-only` command-line flag. With it the server registers only the tools annotated `readOnlyHint: true`, so every tool that writes (such as `write_file` and `edit_file`) is not listed and cannot be called, on both protocol eras and whether the directories come from the command line or a client's Roots. `--` now ends the options, so a directory named like an option can still be given after it.

‎src/filesystem/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Add `--read-only` to serve only the tools that cannot change the filesystem:
3232
mcp-server-filesystem --read-only /path/to/dir1 /path/to/dir2
3333
```
3434

35-
The server then registers only the tools annotated `readOnlyHint: true` (see [Tool annotations](#tool-annotations-mcp-hints)): `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` and the deprecated `read_file`. Every write tool (`write_file`, `edit_file`, `create_directory`, `move_file`) is left out, so a client never lists it and a call to it fails as an unknown tool. The server enforces this, whatever the client is configured to allow, and it works the same with `npx` as with Docker. It applies on both protocol eras, and to directories that come from a client's Roots.
35+
The server then registers only the tools annotated `readOnlyHint: true` in the [Tool annotations](#tool-annotations-mcp-hints) table, the ones that read and list. Every tool not annotated `readOnlyHint: true`, that is every tool that writes (such as `write_file` and `edit_file`), is left out, so a client never lists it and a call to it fails as an unknown tool. A tool added later follows the same rule through its annotation. The server enforces this, whatever the client is configured to allow, and it works the same with `npx` as with Docker. It applies on both protocol eras, and to directories that come from a client's Roots.
3636

3737
The flag may appear anywhere among the arguments. `--` ends the options, so a directory literally named `--read-only` can be given after it.
3838

0 commit comments

Comments
 (0)