The Filesystem MCP Server is a Node.js server implementing the Model Context Protocol for filesystem operations. It provides a secure way to perform file and directory operations within specified directories, offering both command-line and dynamic directory access control.
You can run the Filesystem MCP server using Docker:
docker run -i --rm \
--mount type=bind,src=/Users/username/Desktop,dst=/projects/Desktop \
--mount type=bind,src=/path/to/other/dir,dst=/projects/other/dir,ro \
--mount type=bind,src=/path/to/file.txt,dst=/projects/path/to/file.txt \
mcp/filesystem \
/projects
Note: All directories must be mounted to /projects
. Adding the ro
flag makes the directory read-only.
Alternatively, you can run it directly using NPX:
npx -y @modelcontextprotocol/server-filesystem /path/to/dir1 /path/to/dir2
The server uses a flexible directory access control system through two methods:
Specify allowed directories when starting the server:
mcp-server-filesystem /path/to/dir1 /path/to/dir2
This method enables runtime directory updates without server restart:
roots/list
notifications/roots/list_changed
Note: The server requires at least ONE allowed directory to operate.
Add this to your claude_desktop_config.json
:
{
"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",
"mcp/filesystem",
"/projects"
]
}
}
}
Or using NPX:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/username/Desktop",
"/path/to/other/allowed/dir"
]
}
}
}
For manual installation, add the following to your User Settings (JSON) file in VS Code:
{
"mcp": {
"servers": {
"filesystem": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--mount", "type=bind,src=${workspaceFolder},dst=/projects/workspace",
"mcp/filesystem",
"/projects"
]
}
}
}
}
Or using NPX:
{
"mcp": {
"servers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"${workspaceFolder}"
]
}
}
}
}
read_file: Read complete contents of a file
path
(string)read_multiple_files: Read multiple files simultaneously
paths
(string[])write_file: Create new file or overwrite existing
path
(string), content
(string)edit_file: Make selective edits with pattern matching
path
(string): File to editedits
(array): List of edit operations
oldText
(string): Text to search fornewText
(string): Text to replace withdryRun
(boolean): Preview changes without applyingcreate_directory: Create new directory or ensure it exists
path
(string)list_directory: List directory contents
path
(string)move_file: Move or rename files and directories
source
(string), destination
(string)search_files: Recursively search for files/directories
path
(string): Starting directorypattern
(string): Search patternexcludePatterns
(string[]): Exclude patternsget_file_info: Get detailed file/directory metadata
path
(string)list_allowed_directories: List all directories the server can access
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "filesystem" '{"command":"npx","args":["-y","@modelcontextprotocol/server-filesystem","${workspaceFolder}"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"${workspaceFolder}"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"${workspaceFolder}"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect