Filesystem MCP — Claude Code MCP server: what it does and install
Local file operations server with directory restrictions, secret shielding, and diff previews. Keeps sensitive credentials and unapproved edits safe.
claude mcp add --env FS_ALLOWED_DIRS=<FS_ALLOWED_DIRS> --transport stdio filesystem-mcp -- npx -y @j0hanz/filesystem-mcpWhat Filesystem MCP does
This server gives the assistant 14 tools to inspect, query, and modify code. Operations stay locked to selected folders, keeping the rest of the disk off limits. The server automatically hides .env files, private keys, and cloud tokens. Overwriting existing files via create or deleting populated folders pauses for user confirmation.
File searching uses an RE2 regular expression engine that avoids catastrophic backtracking. Listing and search actions honor .gitignore entries and bypass paths like node_modules. Text replacements execute on exact matches, with an optional dryRun diff check. If editing must be completely prevented, the --read-only flag strips all modifying tools.
Running this server requires Node.js 24 or newer. Communication works over standard input-output or streamable HTTP, with zero telemetry and no outbound network calls.
What it helps with
- restrict assistant access to specific project folders
- hide environment files and private encryption keys
- search codebases using RE2 regular expressions
- apply unified diff patches directly
- inspect line-by-line differences between two files
Example prompts for the agent
- Find all TODO comments across the project and group them by file.
- Replace getUser with fetchUser in all .ts files, but show the diff first.
How to install Filesystem MCP
Platform CLI
claude mcp add --env FS_ALLOWED_DIRS=<FS_ALLOWED_DIRS> --transport stdio filesystem-mcp -- npx -y @j0hanz/filesystem-mcpReplace <…> with your own values
Platform CLI
codex mcp add filesystem-mcp --env FS_ALLOWED_DIRS=<FS_ALLOWED_DIRS> -- npx -y @j0hanz/filesystem-mcpReplace <…> with your own values
Config file
{
"mcpServers": {
"filesystem-mcp": {
"command": "npx",
"args": [
"-y",
"@j0hanz/filesystem-mcp"
],
"env": {
"FS_ALLOWED_DIRS": "<FS_ALLOWED_DIRS>"
}
}
}
}Replace <…> with your own values
Config file
{
"servers": {
"filesystem-mcp": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@j0hanz/filesystem-mcp"
],
"env": {
"FS_ALLOWED_DIRS": "<FS_ALLOWED_DIRS>"
}
}
}
}Replace <…> with your own values
Platform CLI
gemini mcp add -e FS_ALLOWED_DIRS=<FS_ALLOWED_DIRS> filesystem-mcp npx -y @j0hanz/filesystem-mcpReplace <…> with your own values
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about Filesystem MCP
How do I install Filesystem MCP in Claude Code?
Run claude mcp add --env FS_ALLOWED_DIRS=<FS_ALLOWED_DIRS> --transport stdio filesystem-mcp -- npx -y @j0hanz/filesystem-mcp in your terminal, replacing <FS_ALLOWED_DIRS> with your target paths.
What makes Filesystem MCP different from the reference filesystem server?
It blocks .env secrets, supports in-file RE2 regex matching, respects .gitignore, and adds unified diff patching alongside file comparison tools.
What runtime is required to run Filesystem MCP?
It requires Node.js version 24 or higher on your system. Verify your installation by running node --version.