The Filesystem MCP Server provides a Node.js implementation of the Model Context Protocol for filesystem operations, allowing AI assistants to read, write, and manipulate files and directories on your system through a secure, controlled interface.
You can install and run the Filesystem MCP Server using either Docker or NPX.
To run the server with Docker, mount your directories to /projects
inside the container:
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 \
mcp/filesystem \
/projects
The optional ro
flag makes directories read-only.
You can run the server directly with NPX:
npx -y @modelcontextprotocol/server-filesystem /path/to/dir1 /path/to/dir2
The server supports two methods for controlling which directories can be accessed:
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. MCP clients can dynamically update the allowed directories through the Roots protocol.
How it works:
Note: The server requires at least one allowed directory to operate.
Add this configuration to your claude_desktop_config.json
:
Using 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/dir,dst=/projects/other/dir,ro",
"mcp/filesystem",
"/projects"
]
}
}
}
Using NPX:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/username/Desktop",
"/path/to/other/allowed/dir"
]
}
}
}
You can configure the MCP server in VS Code using one of these methods:
Method 1: User Configuration (Recommended)
Open the Command Palette (Ctrl + Shift + P
) and run MCP: Open User Configuration
. Add the server configuration to your user mcp.json
file.
Method 2: Workspace Configuration
Add the configuration to .vscode/mcp.json
in your workspace.
Using Docker:
{
"servers": {
"filesystem": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--mount", "type=bind,src=${workspaceFolder},dst=/projects/workspace",
"mcp/filesystem",
"/projects"
]
}
}
}
Using NPX:
{
"servers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"${workspaceFolder}"
]
}
}
}
The server provides the following tools for file operations:
Each tool accepts specific parameters and provides structured output to help AI assistants work with your filesystem in a controlled, predictable manner.
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