The MCP Filesystem Server implements the Model Context Protocol for filesystem operations with comprehensive permission controls. It provides a secure way to perform file and directory operations with granular permissions, allowing AI assistants and other applications to interact with the filesystem in a controlled manner.
The simplest way to use the server is with npx:
npx -y @modelcontextprotocol/server-filesystem /path/to/allowed/directory
You can also run the server in a Docker container:
docker run -i --rm \
--mount type=bind,src=/Users/username/Desktop,dst=/projects/Desktop \
mcp/filesystem \
/projects
The server requires at least one directory path to operate on, and by default runs in read-only mode:
npx -y @modelcontextprotocol/server-filesystem /path/to/allowed/directory
Control what operations the server can perform:
--readonly
: Enforces read-only mode (default if no permissions specified)--full-access
: Enables all operations (create, edit, move, delete)--allow-create
: Allow creation of files and directories--allow-edit
: Allow modification of existing files--allow-move
: Allow moving/renaming files and directories--allow-delete
: Allow deletion of files and directories--no-follow-symlinks
to disable symlink followingCreate or modify .cursor/mcp.json
in your project:
{
"mcpServers": {
"my-filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"--full-access",
"/path/to/allowed/directory"
]
}
}
}
Modify claude_desktop_config.json
:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"--readonly",
"/Users/username/Desktop",
"/path/to/other/allowed/dir"
]
}
}
}
If you need different permission levels for different directories, create multiple server configurations:
{
"mcpServers": {
"readonly-filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"--readonly",
"~/sensitive/directory"
]
},
"writeable-filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"--full-access",
"~/sandbox/directory"
]
}
}
}
npx -y @modelcontextprotocol/server-filesystem --readonly /path/to/dir
npx -y @modelcontextprotocol/server-filesystem --full-access /path/to/dir
npx -y @modelcontextprotocol/server-filesystem --allow-create --allow-edit /path/to/dir
npx -y @modelcontextprotocol/server-filesystem --full-access --no-follow-symlinks /path/to/dir
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.