The Filesystem MCP Server provides file system operations through the Model Context Protocol, allowing you to read, write, manipulate files and directories with strong access control mechanisms.
You can install and use the Filesystem MCP Server using either Docker or NPX.
For Claude Desktop, 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",
"--mount", "type=bind,src=/path/to/file.txt,dst=/projects/path/to/file.txt",
"mcp/filesystem",
"/projects"
]
}
}
}
For Claude Desktop, add this to your claude_desktop_config.json
:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/username/Desktop",
"/path/to/other/allowed/dir"
]
}
}
}
The server provides flexible directory access control through two methods:
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. This is the recommended method as it enables runtime directory updates without server restart.
You can configure the MCP server in VS Code using one of these methods:
Add the configuration to your user-level MCP configuration file by opening the Command Palette (Ctrl + Shift + P
) and running MCP: Open User Configuration
.
{
"servers": {
"filesystem": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--mount", "type=bind,src=${workspaceFolder},dst=/projects/workspace",
"mcp/filesystem",
"/projects"
]
}
}
}
{
"servers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"${workspaceFolder}"
]
}
}
}
Reads a file as text with optional head/tail limits.
// Example: Read first 10 lines of a file
{
"path": "/path/to/file.txt",
"head": 10
}
Reads an image or audio file and returns base64 data with MIME type.
{
"path": "/path/to/image.jpg"
}
Creates or overwrites a file.
{
"path": "/path/to/file.txt",
"content": "Hello, world!"
}
Makes selective edits with pattern matching and formatting.
{
"path": "/path/to/file.js",
"edits": [
{
"oldText": "function hello() {",
"newText": "function helloWorld() {"
}
],
"dryRun": true
}
Creates a new directory or ensures it exists.
{
"path": "/path/to/new/directory"
}
Lists directory contents with [FILE] or [DIR] prefixes.
{
"path": "/path/to/directory"
}
Lists directory contents with sizes and summary statistics.
{
"path": "/path/to/directory",
"sortBy": "size"
}
Moves or renames files and directories.
{
"source": "/path/to/source",
"destination": "/path/to/destination"
}
Recursively searches for files/directories matching patterns.
{
"path": "/path/to/start",
"pattern": "*.js",
"excludePatterns": ["node_modules/**"]
}
Gets a recursive JSON tree structure of directory contents.
{
"path": "/path/to/directory",
"excludePatterns": ["node_modules/**", "*.log"]
}
Gets detailed file/directory metadata.
{
"path": "/path/to/file.txt"
}
Lists all directories the server is allowed to access.
{}
The read_multiple_files
tool allows reading multiple files at once:
{
"paths": [
"/path/to/file1.txt",
"/path/to/file2.txt"
]
}
Always use dryRun: true
first to preview changes:
{
"path": "/path/to/file.js",
"edits": [
{
"oldText": "const oldVariable",
"newText": "const newVariable"
}
],
"dryRun": true
}
Then apply changes by setting dryRun: false
or omitting it.
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