Skip to content

Filesystem

Filesystem MCP enables secure file operations with configurable access boundaries. It complements Claude Code’s built-in file handling with additional capabilities.

{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
}
}
}

The last argument (.) specifies the allowed directory. Claude can only access files within this directory.

// Allow entire project
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
// Allow only src directory
"args": ["-y", "@modelcontextprotocol/server-filesystem", "./src"]
// Allow multiple directories
"args": ["-y", "@modelcontextprotocol/server-filesystem", "./src", "./tests"]
ToolDescription
read_fileRead file contents
read_multiple_filesRead multiple files at once
get_file_infoGet file metadata (size, modified, etc.)
ToolDescription
write_fileWrite content to file
edit_fileMake targeted edits to file
ToolDescription
list_directoryList directory contents
directory_treeGet full directory tree
create_directoryCreate new directory
ToolDescription
move_fileMove or rename files
search_filesSearch for files by pattern
/index

Filesystem:

  1. Uses directory_tree to scan project
  2. Uses list_directory for detailed info
  3. Uses get_file_info for file metadata
/refactor Move utilities to shared folder

Filesystem:

  1. Uses search_files to find utility files
  2. Uses move_file to relocate them
  3. Uses read_file to update imports
/test Generate tests for auth service

Filesystem:

  1. Uses directory_tree to find test directories
  2. Uses search_files to find existing tests
  3. Uses write_file to create new test files
CommandHow Filesystem Helps
/indexScans project structure
/featureCreates new files in correct locations
/testManages test file creation
/refactorMoves and reorganizes files
// Get project structure
directory_tree(".")
Returns hierarchical view of all files
// Get specific directory contents
list_directory("./src/services")
Returns files with metadata
// Search for patterns
search_files("*.test.ts")
Returns all test files
// Read file
read_file("./src/auth/service.ts")
Returns file contents
// Write new file
write_file("./src/auth/types.ts", "export interface User {...}")
Creates new file
// Move file
move_file("./src/utils/helper.ts", "./src/shared/helper.ts")
Relocates file

Filesystem respects the configured directory boundaries:

  • Cannot read files outside allowed directories
  • Cannot write to system directories
  • Cannot access parent directories with ../
  1. Limit scope — Only allow directories needed for the task
  2. Use project root. is usually sufficient
  3. Avoid sensitive paths — Don’t allow access to credentials or secrets
FeatureBuilt-inFilesystem MCP
Read files
Write files
Directory treeLimitedFull tree view
File searchVia GlobPattern search
Bulk operationsSequentialBatch capable
Access controlPermission-basedDirectory-based

If operations fail:

  1. Check allowed directory in configuration
  2. Verify file permissions
  3. Ensure path is within allowed scope

If search returns empty:

  1. Verify file exists
  2. Check file extension in pattern
  3. Confirm path is relative to allowed directory

Always use forward slashes and relative paths:

  • ”./src/file.ts” not ”.\src\file.ts”
  • Avoid absolute paths