Read complete contents of a file with UTF-8 encoding
Read multiple files simultaneously, with failed reads not stopping the entire operation
Create new file or overwrite existing file with specified content
Make selective edits to a file using advanced pattern matching and formatting with options for dry run preview
Create new directory or ensure it exists, creating parent directories if needed
List directory contents with [FILE] or [DIR] prefixes
Move or rename files and directories
Recursively search for files/directories using patterns with exclusion options
Get detailed file/directory metadata including size, timestamps, type, and permissions
List all directories the server is allowed to access
The Filesystem MCP provides a secure interface for AI assistants to interact with your local filesystem. It enables reading, writing, and editing files, creating and managing directories, searching for content, and retrieving file metadata - all while maintaining strict access controls to only the directories you explicitly allow. With powerful features like advanced file editing with pattern matching, directory traversal, and detailed file information retrieval, this MCP gives AI assistants the ability to help with file management tasks, code editing, and document manipulation while maintaining security through sandboxed access.
The Filesystem MCP server provides a secure way for AI assistants to interact with your local filesystem. It implements the Model Context Protocol (MCP) to enable file operations while maintaining strict access controls.
You can install and run the Filesystem MCP server using either NPX or Docker. Both methods allow you to specify which directories the server is allowed to access.
Add the following configuration to your claude_desktop_config.json
file:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/path/to/allowed/directory",
"/path/to/another/allowed/directory"
]
}
}
}
{
"mcpServers": {
"filesystem": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--mount", "type=bind,src=/path/to/allowed/directory,dst=/projects/allowed",
"--mount", "type=bind,src=/path/to/another/directory,dst=/projects/another,ro",
"mcp/filesystem",
"/projects"
]
}
}
}
Note: When using Docker, all directories must be mounted to /projects
by default. You can add the ro
flag to make a directory read-only.
Add the following to your VS Code User Settings (JSON) file or to .vscode/mcp.json
in your workspace:
{
"mcp": {
"servers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"${workspaceFolder}"
]
}
}
}
}
{
"mcp": {
"servers": {
"filesystem": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--mount", "type=bind,src=${workspaceFolder},dst=/projects/workspace",
"mcp/filesystem",
"/projects"
]
}
}
}
}
The Filesystem MCP server only allows operations within directories explicitly specified in the configuration. This sandboxing approach ensures that AI assistants cannot access files outside of the allowed directories.
When using Docker, you can further restrict access by mounting directories with the ro
(read-only) flag, which prevents the server from making any modifications to those directories.
If you prefer to build the Docker image yourself:
docker build -t mcp/filesystem -f src/filesystem/Dockerfile .
Once installed, the AI assistant can use the Filesystem MCP to perform various operations:
Reading file contents:
Editing files:
Directory operations:
Searching:
File information: