The Filesystem MCP Server implements the Model Context Protocol for filesystem operations, providing secure file access with granular permission controls. It enables various file and directory operations within allowed directories while enforcing strict security boundaries.
To install the Filesystem MCP Server, you need to have Bun installed:
curl -fsSL https://bun.sh/install | bash
# Install dependencies
bun install
# Build the project (required for Node runtimes)
bun run build
The server can be configured in several ways. Paths may include environment variables like $HOME
, ${CUSTOM}
, or %USERPROFILE%
.
# Using Node with built JavaScript
node /path/to/mcp-filesystem/dist/index.js $HOME/allowed-directory
# Using Bun to run TypeScript directly
bun /path/to/mcp-filesystem/index.ts $HOME/allowed-directory
Run directly from the public repository:
# Using Bun
bunx github:rawr-ai/mcp-filesystem $HOME/allowed-directory
# Using NPX
npx github:rawr-ai/mcp-filesystem $HOME/allowed-directory
Run in an isolated container environment:
docker run --rm -v $HOME/allowed-directory:/data mcp/filesystem /data
The server implements a comprehensive security model with granular controls:
Operations are strictly limited to directories specified during startup via args
. All operations must remain within allowed directories, with path validation ensuring no directory traversal.
--readonly
: Enforces read-only mode (default if no flags are specified)--full-access
: Enables all operations (create, edit, move, delete)--allow-create
: Allow creation of new 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
: Prevents traversal of symlinks{
"tool": "read_file",
"args": {
"path": "/path/to/file.txt",
"maxBytes": 10000
}
}
{
"tool": "create_file",
"args": {
"path": "/path/to/new_file.txt",
"content": "File content goes here"
}
}
{
"tool": "modify_file",
"args": {
"path": "/path/to/existing_file.txt",
"content": "New file content"
}
}
Make selective edits using pattern matching:
{
"tool": "edit_file",
"args": {
"path": "/path/to/file.txt",
"edits": [
{
"oldText": "text to replace",
"newText": "replacement text"
}
],
"dryRun": true,
"maxBytes": 10000
}
}
{
"tool": "create_directory",
"args": {
"path": "/path/to/new_directory"
}
}
{
"tool": "list_directory",
"args": {
"path": "/path/to/directory"
}
}
{
"tool": "directory_tree",
"args": {
"path": "/path/to/directory"
}
}
{
"tool": "move_file",
"args": {
"source": "/path/to/source.txt",
"destination": "/path/to/destination.txt"
}
}
{
"tool": "delete_file",
"args": {
"path": "/path/to/file.txt"
}
}
{
"tool": "delete_directory",
"args": {
"path": "/path/to/directory",
"recursive": true
}
}
{
"tool": "search_files",
"args": {
"path": "/path/to/directory",
"pattern": "search_term",
"excludePatterns": ["node_modules", ".git"]
}
}
{
"tool": "find_files_by_extension",
"args": {
"path": "/path/to/directory",
"extension": "txt",
"excludePatterns": ["temp"]
}
}
{
"tool": "get_file_info",
"args": {
"path": "/path/to/file.txt"
}
}
{
"tool": "get_permissions",
"args": {}
}
{
"tool": "list_allowed_directories",
"args": {}
}
{
"tool": "xml_to_json",
"args": {
"xmlPath": "/path/to/file.xml",
"jsonPath": "/path/to/output.json",
"maxResponseBytes": 100000,
"options": {
"ignoreAttributes": false,
"preserveOrder": true,
"format": true,
"indentSize": 2
}
}
}
{
"tool": "xml_query",
"args": {
"path": "/path/to/file.xml",
"query": "//tagname",
"includeAttributes": true,
"maxResponseBytes": 200000
}
}
{
"tool": "regex_search_content",
"args": {
"path": "/path/to/directory",
"regex": "pattern to search",
"filePattern": "*.js",
"maxDepth": 3,
"maxFileSize": 10485760,
"maxResults": 50
}
}
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","--full-access","/Users/username/Desktop","/path/to/other/allowed/dir"]}'
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",
"--full-access",
"/Users/username/Desktop",
"/path/to/other/allowed/dir"
]
}
}
}
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",
"--full-access",
"/Users/username/Desktop",
"/path/to/other/allowed/dir"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect