Filesystem MCP Server
Filesystem MCP servers enable AI models to interact with local file systems, providing capabilities for file operations, directory management, and secure file access within specified boundaries.
Overview
The MCP Filesystem Server enables AI models to safely interact with local file systems through the Model Context Protocol. It provides controlled access to read, write, and manage files within specified directories, making it essential for AI-powered file management and code editing tasks.
Official Server:
Developed and maintained by Anthropic
Key Features
File Operations
Read, write, and edit files with UTF-8 encoding support
Directory Management
Create, list, and navigate directory structures
Search & Metadata
Search files recursively and retrieve detailed file metadata
Secure Boundaries
Operations restricted to specified allowed directories only
Available Tools
Quick Reference
| Tool | Purpose | Category |
|---|---|---|
read_file | Read complete file contents | Read |
read_multiple_files | Read multiple files at once | Read |
write_file | Create or overwrite file | Write |
edit_file | Make selective edits to file | Write |
create_directory | Create new directory | Directory |
list_directory | List directory contents | Directory |
move_file | Move or rename files | File Ops |
search_files | Search for files recursively | Search |
get_file_info | Get file metadata | Metadata |
list_allowed_directories | List accessible directories | Info |
Detailed Usage
read_file▶
Read complete file contents with UTF-8 encoding.
use_mcp_tool({
server_name: "filesystem",
tool_name: "read_file",
arguments: {
path: "/path/to/file.txt"
}
});
Returns full file contents as string.
read_multiple_files▶
Read multiple files simultaneously for efficiency.
use_mcp_tool({
server_name: "filesystem",
tool_name: "read_multiple_files",
arguments: {
paths: [
"/path/to/file1.txt",
"/path/to/file2.js",
"/path/to/file3.md"
]
}
});
Returns array of file contents.
write_file▶
Create new file or overwrite existing file with content.
use_mcp_tool({
server_name: "filesystem",
tool_name: "write_file",
arguments: {
path: "/path/to/output.txt",
content: "Hello, World!\nThis is a new file."
}
});
Exercise caution - overwrites existing files without warning.
edit_file▶
Make selective edits using pattern matching with indentation preservation.
// Preview changes first (dry run)
use_mcp_tool({
server_name: "filesystem",
tool_name: "edit_file",
arguments: {
path: "/path/to/code.js",
edits: [
{
oldText: "const foo = 'bar';",
newText: "const foo = 'baz';"
}
],
dryRun: true
}
});
// Apply edits
use_mcp_tool({
server_name: "filesystem",
tool_name: "edit_file",
arguments: {
path: "/path/to/code.js",
edits: [
{
oldText: "const foo = 'bar';",
newText: "const foo = 'baz';"
}
],
dryRun: false
}
});
Always use dryRun: true first to preview changes.
create_directory▶
Create new directory with automatic parent directory creation.
use_mcp_tool({
server_name: "filesystem",
tool_name: "create_directory",
arguments: {
path: "/path/to/new/nested/directory"
}
});
Succeeds silently if directory already exists.
list_directory▶
List directory contents with file/directory type indicators.
use_mcp_tool({
server_name: "filesystem",
tool_name: "list_directory",
arguments: {
path: "/path/to/directory"
}
});
Returns items prefixed with [FILE] or [DIR].
move_file▶
Move or rename files and directories.
// Rename file
use_mcp_tool({
server_name: "filesystem",
tool_name: "move_file",
arguments: {
source: "/path/to/old-name.txt",
destination: "/path/to/new-name.txt"
}
});
// Move to different directory
use_mcp_tool({
server_name: "filesystem",
tool_name: "move_file",
arguments: {
source: "/path/to/file.txt",
destination: "/new/path/file.txt"
}
});
Fails if destination already exists.
search_files▶
Recursively search for files and directories by pattern.
// Search for JavaScript files
use_mcp_tool({
server_name: "filesystem",
tool_name: "search_files",
arguments: {
path: "/path/to/project",
pattern: "*.js"
}
});
// Search with exclusions
use_mcp_tool({
server_name: "filesystem",
tool_name: "search_files",
arguments: {
path: "/path/to/project",
pattern: "*.ts",
excludePatterns: ["node_modules/**", "dist/**", "*.test.ts"]
}
});
Supports glob patterns for matching and exclusion.
get_file_info▶
Get detailed metadata for files or directories.
use_mcp_tool({
server_name: "filesystem",
tool_name: "get_file_info",
arguments: {
path: "/path/to/file.txt"
}
});
Returns size, timestamps, type, and permissions.
list_allowed_directories▶
List all directories the server is allowed to access.
use_mcp_tool({
server_name: "filesystem",
tool_name: "list_allowed_directories",
arguments: {}
});
Returns configured allowed directory paths.
Installation
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/username/Desktop",
"/path/to/other/allowed/dir"
]
}
}
}
Security:
Only directories listed in args will be accessible. Operations outside these paths will be blocked.
Common Use Cases
Code Editing
Make surgical edits to source files:
use_mcp_tool({
server_name: "filesystem",
tool_name: "edit_file",
arguments: {
path: "/project/src/config.js",
edits: [
{
oldText: "API_URL = 'http://localhost:3000'",
newText: "API_URL = 'https://api.production.com'"
}
],
dryRun: true // Preview first
}
});
Project Exploration
Search and analyze project structure:
// Find all TypeScript files
use_mcp_tool({
server_name: "filesystem",
tool_name: "search_files",
arguments: {
path: "/project",
pattern: "*.ts",
excludePatterns: ["node_modules/**", "dist/**"]
}
});
// Read configuration files
use_mcp_tool({
server_name: "filesystem",
tool_name: "read_multiple_files",
arguments: {
paths: [
"/project/package.json",
"/project/tsconfig.json",
"/project/.env"
]
}
});
File Organization
Organize and structure files:
// Create directory structure
use_mcp_tool({
server_name: "filesystem",
tool_name: "create_directory",
arguments: {
path: "/project/src/components/ui"
}
});
// Move files to new structure
use_mcp_tool({
server_name: "filesystem",
tool_name: "move_file",
arguments: {
source: "/project/Button.tsx",
destination: "/project/src/components/ui/Button.tsx"
}
});
Security Model
The filesystem server implements strict security boundaries:
- Allowed Directories: Only paths specified in server args are accessible
- Path Validation: All paths are validated to prevent directory traversal attacks
- No Deletion: Server does not provide file deletion capabilities
- Read-Only Mounts: Docker supports read-only directory mounting
Sources
Related Articles
Confluence MCP Server
Confluence MCP servers provide interfaces for LLMs to interact with Atlassian Confluence workspaces. These servers enable AI models to manage documentation, collaborate on content, and automate knowledge management tasks.
RabbitMQ MCP Server
RabbitMQ MCP server enables AI models to interact with RabbitMQ message brokers, providing capabilities for queue management, message operations, system monitoring, and broker administration through the RabbitMQ HTTP Management API.
Model Context Protocol (MCP): Open Standard for AI Integration
The Model Context Protocol (MCP) is an open standard enabling AI systems to connect with diverse data sources, tools, and services, eliminating custom integrations for seamless interaction.