mcp filesystem
Node.js server implementing Model Context Protocol (MCP) for filesystem operations with comprehensive permission controls, allowing secure file and directory manipulation with granular access restrictions.
Node.js server implementing Model Context Protocol (MCP) for filesystem operations with comprehensive permission controls, allowing secure file and directory manipulation with granular access restrictions.
Node.js server implementing Model Context Protocol (MCP) for filesystem operations with comprehensive permission controls and enhanced functionality.
Note: The server will only allow operations within directories specified via args
and according to the configured permissions.
file://system
: File system operations interfacepath
(string)Reads complete file contents with UTF-8 encoding
read_multiple_files
paths
(string[])Failed reads won t stop the entire operation
create_file
path
(string): File locationcontent
(string): File contentRequires create
permission
modify_file
path
(string): File locationcontent
(string): New file contentRequires edit
permission
edit_file
path
(string): File to editedits
(array): List of edit operationsoldText
(string): Text to search for (exact match)newText
(string): Text to replace withdryRun
(boolean): Preview changes without applying (default: false)edit
permissionBest Practice: Always use dryRun first to preview changes
create_directory
path
(string)Requires create
permission
list_directory
path
(string)Returns detailed listing of files and directories
directory_tree
path
(string)Each entry includes name, type, and children (for directories)
move_file
source
(string): Source pathdestination
(string): Destination pathRequires move
permission
delete_file
path
(string)Requires delete
permission
delete_directory
path
(string): Directory to deleterecursive
(boolean): Whether to delete contents (default: false)Requires delete
permission
search_files
path
(string): Starting directorypattern
(string): Search patternexcludePatterns
(string[]): Exclude patterns (glob format supported)Returns full paths to matches
find_files_by_extension
path
(string): Starting directoryextension
(string): File extension to findexcludePatterns
(string[]): Optional exclude patternsReturns full paths to matching files
get_file_info
path
(string)Returns:
get_permissions
Returns:
list_allowed_directories
Returns array of allowed directory paths
xml_to_json
xmlPath
(string): Source XML filejsonPath
(string): Destination JSON fileoptions
(object): Optional settingsignoreAttributes
(boolean): Skip XML attributes (default: false)preserveOrder
(boolean): Maintain property order (default: true)format
(boolean): Pretty print JSON (default: true)indentSize
(number): JSON indentation (default: 2)read
permission for XML fileRequires create
or edit
permission for JSON file
xml_to_json_string
xmlPath
(string): Source XML fileoptions
(object): Optional settingsignoreAttributes
(boolean): Skip XML attributes (default: false)preserveOrder
(boolean): Maintain property order (default: true)read
permission for XML fileReturns JSON string representation
xml_query
path
(string): Path to the XML filequery
(string, optional): XPath query to executestructureOnly
(boolean, optional): Return only tag structuremaxBytes
(number, optional): Maximum bytes to read (default: 1MB)includeAttributes
(boolean, optional): Include attribute info (default: true)//tagname
//tagname[@attr="value"]
//tagname/text()
Returns JSON representation of query results or structure
xml_structure
path
(string): Path to the XML filedepth
(number, optional): How deep to analyze (default: 2)includeAttributes
(boolean, optional): Include attribute analysismaxBytes
(number, optional): Maximum bytes to read (default: 1MB)The server implements a comprehensive security model with granular permission controls:
args
Default Behavior: If no permission flags are specified, the server runs in read-only mode. To enable any write operations, you must use either --full-access
or specific --allow-*
flags.
Add appropriate configuration to either claude_desktop_config.json
(for Claude Desktop) or .cursor/mcp.json
(for Cursor):
In .cursor/mcp.json
:
{
"mcpServers": {
"my-filesystem": {
"command": "node",
"args": [
"/path/to/mcp-filesystem/dist/index.js",
"~/path/to/allowed/directory",
"--full-access"
]
}
}
}
For Claude Desktop with Docker:
{
"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",
"--readonly", // For read-only access
"--no-follow-symlinks", // Optional: prevent symlink following
"/projects"
]
}
}
}
For either Claude Desktop or Cursor with NPX:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"--full-access", // For full read/write access
"/Users/username/Desktop",
"/path/to/other/allowed/dir"
]
}
}
}
You can configure the server with various permission combinations:
"args": [
"/path/to/mcp-filesystem/dist/index.js",
"~/path/to/allowed/directory",
"--readonly" // Read-only mode
]
"args": [
"/path/to/mcp-filesystem/dist/index.js",
"~/path/to/allowed/directory",
"--full-access", // Full read/write access
"--no-follow-symlinks" // Don t follow symlinks
]
"args": [
"/path/to/mcp-filesystem/dist/index.js",
"~/path/to/allowed/directory",
"--allow-create", // Selective permissions
"--allow-edit" // Only allow creation and editing
]
Note: --readonly
takes precedence over all other permission flags, and --full-access
enables all operations unless --readonly
is specified.
When specifying multiple directories, permission flags apply globally to all directories:
"args": [
"/path/to/mcp-filesystem/dist/index.js",
"~/first/directory", // Both directories have the same
"~/second/directory", // permission settings (read-only)
"--readonly"
]
If you need different permission levels for different directories, create multiple server configurations:
{
"mcpServers": {
"readonly-filesystem": {
"command": "node",
"args": [
"/path/to/mcp-filesystem/dist/index.js",
"~/sensitive/directory",
"--readonly"
]
},
"writeable-filesystem": {
"command": "node",
"args": [
"/path/to/mcp-filesystem/dist/index.js",
"~/sandbox/directory",
"--full-access"
]
}
}
}
Read-only access:
npx -y @modelcontextprotocol/server-filesystem --readonly /path/to/dir
Full access:
npx -y @modelcontextprotocol/server-filesystem --full-access /path/to/dir
Specific permissions:
npx -y @modelcontextprotocol/server-filesystem --allow-create --allow-edit /path/to/dir
No symlink following:
npx -y @modelcontextprotocol/server-filesystem --full-access --no-follow-symlinks /path/to/dir
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.