The Filesystem MCP Server provides functionality for filesystem operations through the Model Context Protocol. It allows you to perform common file and directory operations like reading, writing, creating, listing, moving, and searching files within specified directories.
You can use the Filesystem MCP Server either via Docker or directly with NPX. Both methods require you to specify which directories the server is allowed to access.
The Docker method requires mounting directories to /projects
within the container:
docker 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
Note that adding the ro
flag makes a directory read-only.
Alternatively, use NPX to run the server directly:
npx -y @modelcontextprotocol/server-filesystem \
/Users/username/Desktop \
/path/to/other/allowed/dir
To use the Filesystem MCP Server with Claude Desktop, add the configuration to your claude_desktop_config.json
file.
{
"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"
]
}
}
}
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/username/Desktop",
"/path/to/other/allowed/dir"
]
}
}
}
The server exposes several filesystem operations through the file://system
resource:
read_file: Read complete contents of a file
{"path": "/path/to/file.txt"}
read_multiple_files: Read multiple files simultaneously
{"paths": ["/path/to/file1.txt", "/path/to/file2.txt"]}
write_file: Create new file or overwrite existing
{
"path": "/path/to/file.txt",
"content": "New file content"
}
edit_file: Make selective edits using pattern matching
{
"path": "/path/to/file.txt",
"edits": [
{
"oldText": "text to replace",
"newText": "replacement text"
}
],
"dryRun": true
}
create_directory: Create new directory
{"path": "/path/to/new/directory"}
list_directory: List directory contents
{"path": "/path/to/directory"}
move_file: Move or rename files and directories
{
"source": "/path/to/source",
"destination": "/path/to/destination"
}
search_files: Recursively search for files/directories
{
"path": "/path/to/search",
"pattern": "*.txt",
"excludePatterns": ["node_modules/**"]
}
get_file_info: Get detailed file/directory metadata
{"path": "/path/to/file.txt"}
list_allowed_directories: List all directories the server can access
{}
The server only allows operations within directories explicitly specified through the args
parameter during initialization. Be cautious when using tools like write_file
and move_file
as they can overwrite existing content.
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 > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.