Filesystem
Filesystem
Section titled “Filesystem”Filesystem MCP enables secure file operations with configurable access boundaries. It complements Claude Code’s built-in file handling with additional capabilities.
Configuration
Section titled “Configuration”{ "mcpServers": { "filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "."] } }}The last argument (.) specifies the allowed directory. Claude can only access files within this directory.
Access Control Examples
Section titled “Access Control Examples”// 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"]Available Tools
Section titled “Available Tools”Reading
Section titled “Reading”| Tool | Description |
|---|---|
read_file | Read file contents |
read_multiple_files | Read multiple files at once |
get_file_info | Get file metadata (size, modified, etc.) |
Writing
Section titled “Writing”| Tool | Description |
|---|---|
write_file | Write content to file |
edit_file | Make targeted edits to file |
Directory Operations
Section titled “Directory Operations”| Tool | Description |
|---|---|
list_directory | List directory contents |
directory_tree | Get full directory tree |
create_directory | Create new directory |
File Management
Section titled “File Management”| Tool | Description |
|---|---|
move_file | Move or rename files |
search_files | Search for files by pattern |
Use Cases
Section titled “Use Cases”Project Indexing
Section titled “Project Indexing”/indexFilesystem:
- Uses
directory_treeto scan project - Uses
list_directoryfor detailed info - Uses
get_file_infofor file metadata
Bulk Operations
Section titled “Bulk Operations”/refactor Move utilities to shared folderFilesystem:
- Uses
search_filesto find utility files - Uses
move_fileto relocate them - Uses
read_fileto update imports
Test File Management
Section titled “Test File Management”/test Generate tests for auth serviceFilesystem:
- Uses
directory_treeto find test directories - Uses
search_filesto find existing tests - Uses
write_fileto create new test files
Command Integration
Section titled “Command Integration”| Command | How Filesystem Helps |
|---|---|
/index | Scans project structure |
/feature | Creates new files in correct locations |
/test | Manages test file creation |
/refactor | Moves and reorganizes files |
Example Workflow
Section titled “Example Workflow”Scanning Project
Section titled “Scanning Project”// Get project structuredirectory_tree(".")→ Returns hierarchical view of all files
// Get specific directory contentslist_directory("./src/services")→ Returns files with metadata
// Search for patternssearch_files("*.test.ts")→ Returns all test filesFile Operations
Section titled “File Operations”// Read fileread_file("./src/auth/service.ts")→ Returns file contents
// Write new filewrite_file("./src/auth/types.ts", "export interface User {...}")→ Creates new file
// Move filemove_file("./src/utils/helper.ts", "./src/shared/helper.ts")→ Relocates fileSecurity
Section titled “Security”Access Boundaries
Section titled “Access Boundaries”Filesystem respects the configured directory boundaries:
- Cannot read files outside allowed directories
- Cannot write to system directories
- Cannot access parent directories with
../
Best Practices
Section titled “Best Practices”- Limit scope — Only allow directories needed for the task
- Use project root —
.is usually sufficient - Avoid sensitive paths — Don’t allow access to credentials or secrets
Comparison with Built-in Tools
Section titled “Comparison with Built-in Tools”| Feature | Built-in | Filesystem MCP |
|---|---|---|
| Read files | ✓ | ✓ |
| Write files | ✓ | ✓ |
| Directory tree | Limited | Full tree view |
| File search | Via Glob | Pattern search |
| Bulk operations | Sequential | Batch capable |
| Access control | Permission-based | Directory-based |
Troubleshooting
Section titled “Troubleshooting”Permission Denied
Section titled “Permission Denied”If operations fail:
- Check allowed directory in configuration
- Verify file permissions
- Ensure path is within allowed scope
File Not Found
Section titled “File Not Found”If search returns empty:
- Verify file exists
- Check file extension in pattern
- Confirm path is relative to allowed directory
Path Issues
Section titled “Path Issues”Always use forward slashes and relative paths:
- ”./src/file.ts” not ”.\src\file.ts”
- Avoid absolute paths