You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
text: `Here are ${count} resource links to resources available in this server (see full output in tool response if your client does not support resource_link yet):`,
754
+
});
755
+
756
+
// Return resource links to actual resources from ALL_RESOURCES
Copy file name to clipboardExpand all lines: src/filesystem/README.md
+51-1Lines changed: 51 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,8 +9,58 @@ Node.js server implementing Model Context Protocol (MCP) for filesystem operatio
9
9
- Move files/directories
10
10
- Search files
11
11
- Get file metadata
12
+
- Dynamic directory access control via [Roots](https://modelcontextprotocol.io/docs/concepts/roots)
13
+
14
+
## Directory Access Control
15
+
16
+
The server uses a flexible directory access control system. Directories can be specified via command-line arguments or dynamically via [Roots](https://modelcontextprotocol.io/docs/concepts/roots).
17
+
18
+
### Method 1: Command-line Arguments
19
+
Specify Allowed directories when starting the server:
20
+
```bash
21
+
mcp-server-filesystem /path/to/dir1 /path/to/dir2
22
+
```
23
+
24
+
### Method 2: MCP Roots (Recommended)
25
+
MCP clients that support [Roots](https://modelcontextprotocol.io/docs/concepts/roots) can dynamically update the Allowed directories.
26
+
27
+
Roots notified by Client to Server, completely replace any server-side Allowed directories when provided.
28
+
29
+
**Important**: If server starts without command-line arguments AND client doesn't support roots protocol (or provides empty roots), the server will throw an error during initialization.
30
+
31
+
This is the recommended method, as this enables runtime directory updates via `roots/list_changed` notifications without server restart, providing a more flexible and modern integration experience.
32
+
33
+
### How It Works
34
+
35
+
The server's directory access control follows this flow:
36
+
37
+
1.**Server Startup**
38
+
- Server starts with directories from command-line arguments (if provided)
39
+
- If no arguments provided, server starts with empty allowed directories
40
+
41
+
2.**Client Connection & Initialization**
42
+
- Client connects and sends `initialize` request with capabilities
43
+
- Server checks if client supports roots protocol (`capabilities.roots`)
0 commit comments