Node.js server implementing Model Context Protocol (MCP) for filesystem operations.
The server uses a flexible directory access control system. Directories can be specified via command-line arguments or dynamically via Roots.
Specify Allowed directories when starting the server:
mcp-server-filesystem /path/to/dir1 /path/to/dir2
MCP clients that support Roots can dynamically update the Allowed directories.
Roots notified by Client to Server, completely replace any server-side Allowed directories when provided.
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.
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.
The server's directory access control follows this flow:
Server Startup
Client Connection & Initialization
initialize request with capabilitiescapabilities.roots)Roots Protocol Handling (if client supports roots)
roots/listnotifications/roots/list_changedFallback Behavior (if client doesn't support roots)
Access Control
list_allowed_directories tool to see current directoriesNote: The server will only allow operations within directories specified either via args or via Roots.
file://system: File system operations interfaceread_file
path (string)read_multiple_files
paths (string[])write_file
path (string): File locationcontent (string): File contentedit_file
path (string): File to editedits (array): List of edit operations
oldText (string): Text to search for (can be substring)newText (string): Text to replace withdryRun (boolean): Preview changes without applying (default: false)create_directory
path (string)list_directory
path (string)move_file
source (string)destination (string)search_files
path (string): Starting directorypattern (string): Search patternexcludePatterns (string[]): Exclude any patterns. Glob formats are supported.get_file_info
path (string)list_allowed_directories
Add this to your claude_desktop_config.json:
Note: you can provide sandboxed directories to the server by mounting them to /projects. Adding the ro flag will make the directory readonly by the server.
Note: all directories must be mounted to /projects by default.
{
"mcpServers": {
"filesystem": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--mount", "type=bind,src=/Users/username/Desktop,dst=/projects/Desktop",
"--mount", "type=bind,src=/path/to/other/allowed/dir,dst=/projects/other/allowed/dir,ro",
"--mount", "type=bind,src=/path/to/file.txt,dst=/projects/path/to/file.txt",
"mcp/filesystem",
"/projects"
]
}
}
}
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/username/Desktop",
"/path/to/other/allowed/dir"
]
}
}
}
For quick installation, click the installation buttons below...
For manual installation, add the following JSON block to your User Settings (JSON) file in VS Code. You can do this by pressing Ctrl + Shift + P and typing Preferences: Open Settings (JSON).
Optionally, you can add it to a file called .vscode/mcp.json in your workspace. This will allow you to share the configuration with others.
Note that the
mcpkey is not needed in the.vscode/mcp.jsonfile.
You can provide sandboxed directories to the server by mounting them to /projects. Adding the ro flag will make the directory readonly by the server.
Note: all directories must be mounted to /projects by default.
{
"mcp": {
"servers": {
"filesystem": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--mount", "type=bind,src=${workspaceFolder},dst=/projects/workspace",
"mcp/filesystem",
"/projects"
]
}
}
}
}
{
"mcp": {
"servers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"${workspaceFolder}"
]
}
}
}
}
Docker build:
docker build -t mcp/filesystem -f src/filesystem/Dockerfile .
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
Start an MCP gateway in seconds. Fully local, no sign up, no manual config. One command to get started: