File System
STDIOMCP server providing file system operations for AI assistants to interact with local files.
MCP server providing file system operations for AI assistants to interact with local files.
A simple Model Context Protocol (MCP) server providing file system operations. This server offers a clean API for performing file system operations within a specified project directory, following the MCP protocol design.
This MCP server enables AI assistants like Claude (via Claude Desktop) or other MCP-compatible systems to interact with your local file system. With these capabilities, AI assistants can:
All operations are securely contained within your specified project directory, giving you control while enabling powerful AI collaboration on your local files.
By connecting your AI assistant to your filesystem, you can transform your workflow from manual coding to a more intuitive prompting approach - describe what you need in natural language and let the AI generate, modify, and organize code directly in your project files.
list_directory: List all files and directories in the project directoryread_file: Read the contents of a filesave_file: Write content to a file atomicallyappend_file: Append content to the end of a filedelete_this_file: Delete a specified file from the filesystemedit_file: Make selective edits using exact string matchingmove_file: Move or rename files and directories within the projectget_reference_projects: Discover available reference projectslist_reference_directory: List files in reference projectsread_reference_file: Read files from reference projectsStructured Logging: Comprehensive logging system with both human-readable and JSON formats# Clone the repository git clone https://github.com/MarcusJellinghaus/mcp_server_filesystem.git cd mcp_server_filesystem # Create and activate a virtual environment (optional but recommended) python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate # Install dependencies using pip with pyproject.toml pip install -e .
Once installed, you can use the mcp-server-filesystem command directly:
mcp-server-filesystem --project-dir /path/to/project [--reference-project NAME=/path/to/reference]... [--log-level LEVEL] [--log-file PATH]
--project-dir: (Required) Directory to serve files from--reference-project: (Optional) Add reference project in format name=/path/to/dir (repeatable, auto-renames duplicates)--log-level: (Optional) Set logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)--log-file: (Optional) Path for structured JSON logs. If not specified, logs to mcp_filesystem_server_{timestamp}.log in project_dir/logs/.The server uses FastMCP for operation. The project directory parameter (--project-dir) is required for security reasons. All file operations will be restricted to this directory. Attempts to access files outside this directory will result in an error.
The server provides flexible logging options:
project_dir/logs/mcp_filesystem_server_{timestamp}.log or custom path with --log-file)--console-only to disable file loggingReference projects allow you to provide AI assistants with read-only access to additional codebases or directories for context and reference. This feature enables the LLM to browse and read files from multiple projects while maintaining write access only to the main project directory.
Use the --reference-project argument to add reference projects:
# Single reference project mcp-server-filesystem --project-dir ./my-project --reference-project docs=./documentation # Multiple reference projects mcp-server-filesystem --project-dir ./my-project \ --reference-project docs=./documentation \ --reference-project examples=/home/user/examples \ --reference-project libs=../shared-libraries # Absolute paths mcp-server-filesystem --project-dir /path/to/main/project \ --reference-project utils=/usr/local/utils \ --reference-project config=/etc/myapp
If you specify duplicate reference project names, they are automatically renamed with numeric suffixes:
# This configuration: mcp-server-filesystem --project-dir ./project \ --reference-project docs=./docs1 \ --reference-project docs=./docs2 \ --reference-project docs=./docs3 # Results in these reference project names: # - docs (points to ./docs1) # - docs_2 (points to ./docs2) # - docs_3 (points to ./docs3)
The server validates reference projects at startup:
This server can be integrated with different Claude interfaces. Each requires a specific configuration.
The Claude Desktop app can also use this file system server.
Locate the Claude Desktop configuration file:
%APPDATA%\Claude\claude_desktop_config.json~/Library/Application Support/Claude/claude_desktop_config.jsonAdd the MCP server configuration (create the file if it doesn't exist):
{ "mcpServers": { "filesystem": { "command": "mcp-server-filesystem", "args": [ "--project-dir", "C:\\path\\to\\your\\specific\\project", "--reference-project", "docs=C:\\path\\to\\documentation", "--reference-project", "examples=C:\\path\\to\\examples", "--log-level", "INFO" ] } } }
Configuration notes:
mcp-server-filesystem command should be available in your PATH after installation--project-dirRestart the Claude Desktop app to apply changes
%APPDATA%\Claude\logs (Windows) or ~/Library/Application Support/Claude/logs (macOS)mcp-server-filesystem command is available in your PATH (run mcp-server-filesystem --help to test)For development setup, testing, and contribution guidelines, see CONTRIBUTING.md.
The server exposes the following MCP tools:
| Operation | Description | Example Prompt | 
|---|---|---|
list_directory | Lists files and directories in the project directory | "List all files in the src directory" | 
read_file | Reads the contents of a file | "Show me the contents of main.js" | 
save_file | Creates or overwrites files atomically | "Create a new file called app.js" | 
append_file | Adds content to existing files | "Add a function to utils.js" | 
delete_this_file | Removes files from the filesystem | "Delete the temporary.txt file" | 
edit_file | Makes selective edits using exact string matching | "Fix the bug in the fetch function" | 
move_file | Moves or renames files and directories | "Rename config.js to settings.js" | 
get_reference_projects | Lists available reference projects | "What reference projects are available?" | 
list_reference_directory | Lists files in a reference project | "List files in the docs reference project" | 
read_reference_file | Reads files from reference projects | "Show me the README from the examples project" | 
file_path (string): Path to the file to read (relative to project directory)file_path (string): Path to the file to write tocontent (string): Content to write to the filefile_path (string): Path to the file to append tocontent (string): Content to append to the filesave_file to create new filesfile_path (string): Path to the file to deleteMakes precise edits to files using exact string matching. This tool is designed for reliability and predictability.
Parameters:
file_path (string): File to edit (relative to project directory)edits (array): List of edit operations, each containing:
old_text (string): Exact text to find and replace (must match exactly)new_text (string): Replacement textdry_run (boolean, optional): Preview changes without applying (default: False)options (object, optional): Formatting settings
preserve_indentation (boolean, default: False): Apply indentation from old_text to new_textKey Characteristics:
old_text must match exactly (case-sensitive, whitespace-sensitive)old_text patternExamples:
# Basic text replacement edit_file("config.py", [ {"old_text": "DEBUG = False", "new_text": "DEBUG = True"} ]) # Multiple edits in one operation edit_file("app.py", [ {"old_text": "def old_function():", "new_text": "def new_function():"}, {"old_text": "old_function()", "new_text": "new_function()"} ]) # Preview changes without applying edit_file("code.py", edits, dry_run=True) # With indentation preservation edit_file("indented.py", [ {"old_text": " old_code()", "new_text": "new_code()"} ], options={"preserve_indentation": True})
Important Notes:
old_text must match exactly - including spacing, capitalization, and line breaks\n for line breaks in multi-line replacementsold_text appears multiple times, only the first occurrence is replaceddry_run=True to preview changes before applying themMoves or renames files and directories within the project directory. Automatically preserves git history when applicable.
Parameters:
source_path (string): Source file/directory path (relative to project)destination_path (string): Destination path (relative to project)Returns: Boolean (true for success)
Features:
Examples:
# Rename a file move_file("old_name.py", "new_name.py") # Move a file to a different directory move_file("src/temp.py", "archive/temp.py") # Rename a directory move_file("old_folder", "new_folder") # Move with automatic parent directory creation move_file("file.txt", "new_dir/sub_dir/file.txt") # Creates new_dir/sub_dir if needed
Error Handling:
Discovery tool for LLMs to find available reference projects.
Parameters: None
Returns: Dictionary containing:
count: Number of available projectsprojects: List of project namesusage: Instructions for next stepsExample:
get_reference_projects() # Returns: { # "count": 3, # "projects": ["docs", "examples", "utils"], # "usage": "Use these 3 projects with list_reference_directory() and read_reference_file()" # }
Use Cases:
Lists files and directories in a reference project, with the same gitignore filtering as the main project.
Parameters:
reference_name (string): Name of the reference projectReturns: List of strings containing file and directory names
Examples:
# List root directory of reference project (shows subdirectories) list_reference_directory("docs") # Then read files from subdirectories using read_reference_file read_reference_file("examples", "src/components/Button.tsx")
Features:
Reads the contents of a file from a reference project.
Parameters:
reference_name (string): Name of the reference projectfile_path (string): Path to the file within the reference project (relative to reference project root)Returns: String containing the file contents
Examples:
# Read README from docs reference project read_reference_file("docs", "README.md") # Read source file from examples project read_reference_file("examples", "src/app.py") # Read config file read_reference_file("config", "settings/production.yml")
Features:
Error Handling:
For easy configuration and installation of this MCP server, you can use the mcp-config development tool. This CLI tool simplifies the process of managing MCP server configurations across multiple clients (Claude Desktop, VS Code, etc.).
# Install mcp-config pip install git+https://github.com/MarcusJellinghaus/mcp-config.git
# Setup for Claude Desktop with automatic configuration mcp-config setup mcp-server-filesystem "Filesystem Server" --project-dir /path/to/your/project # Setup with reference projects mcp-config setup mcp-server-filesystem "Filesystem Server" \ --project-dir /path/to/your/project \ --reference-project docs=/path/to/documentation \ --reference-project examples=/path/to/examples # Setup with custom log configuration mcp-config setup mcp-server-filesystem "Filesystem Server" \ --project-dir /path/to/your/project \ --reference-project utils=/shared/utilities \ --log-level DEBUG \ --log-file /custom/path/server.log
Learn more: mcp-config on GitHub
This tool eliminates the manual configuration steps and reduces setup errors by handling path resolution, environment detection, and client-specific configuration formats automatically.
This project is licensed under the MIT License - see the LICENSE file for details.
The MIT License is a permissive license that allows reuse with minimal restrictions. It permits use, copying, modification, and distribution with proper attribution.