An MCP server for reading and writing files from your local file system. This server can be used with Claude for Desktop or any other MCP client to provide file system access for AI assistants.
- List files and directories
- Read file contents
- Write content to files
- Delete files and directories
- Execute commands inside the container
- Docker installed on your system
- Git (optional, for cloning the repository)
-
Clone this repository:
git clone https://github.com/abhishekloiwal/mcp-file-server.git cd mcp-file-server
-
Edit the
docker-compose.yml
file to update the volume mount path if needed. By default, it's set to:volumes: - /Users/abhishekloiwal/CascadeProjects/ClaudeProjects:/data
Replace with your desired local path if different.
-
Deploy with Docker Compose:
docker-compose up -d
-
Clone the repository:
git clone https://github.com/abhishekloiwal/mcp-file-server.git cd mcp-file-server
-
Build the Docker image:
docker build -t mcp-file-server .
-
Run the container with your local directory mounted:
docker run -d --name mcp-file-server -v /Users/abhishekloiwal/CascadeProjects/ClaudeProjects:/data mcp-file-server
Replace the path with your desired local directory path.
-
Create or update your Claude for Desktop configuration file at:
- Mac:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%AppData%\Claude\claude_desktop_config.json
- Mac:
-
Add the mcp-file-server to your configuration:
{ "mcpServers": { "file-server": { "command": "docker", "args": ["exec", "-i", "mcp-file-server", "python", "server.py"] } } }
-
Restart Claude for Desktop.
-
You should now see the file-server tools available in Claude.
The following tools are available through this MCP server:
list_files
: List all files in a directoryread_file
: Read the contents of a filewrite_file
: Write content to a filedelete_file
: Delete a file or directoryrun_command
: Run a shell command with optional STDIN and get STDOUT/STDERR
-
Basic:
- Command:
hostname
- Returns: JSON with
stdout
,stderr
,exit_code
.
- Command:
-
List files (with options):
- Command:
ls -al
- Optional
cwd
: relative to the mounted base directory (/data
).
- Command:
-
Pass text via STDIN:
- Command:
cat >> notes/todo.txt
- STDIN:
Buy milk\nCall Alice\n
- Effect: Appends the STDIN text into
notes/todo.txt
.
- Command:
-
Send code to a REPL via STDIN:
- Command:
python -
- STDIN:
print('hello from stdin')\n
- Note: Any program that reads from STDIN (e.g.,
bash
,sh
,python
) can receive code/text this way.
- Command:
- By default, commands time out after 60 seconds.
- You can control timeouts with either:
timeout
: seconds (float or string), e.g.,5
.timeout_ms
: milliseconds (int/float/string), e.g.,5000
.
- Values
<= 0
disable the timeout (run until completion). - On timeout, the server terminates the entire process group and returns JSON with
timed_out: true
andtimeout_seconds
.
stdout
andstderr
are capped at a configurable number of lines (default: 1000) to prevent excessive output.- The JSON response includes:
truncated
: whether either stream was truncated.stdout_truncated
/stderr_truncated
: per-stream truncation flags.max_lines
: the per-stream cap in effect.
- Environment variable (takes precedence):
- Set
RUN_COMMAND_MAX_LINES
(orMAX_OUTPUT_LINES
) to a positive integer. - Example:
RUN_COMMAND_MAX_LINES=200
.
- Set
- Config file (fallback if env not set):
- Create a
config.json
next toserver.py
(or setFILE_SERVER_CONFIG_PATH
to point to a JSON file) with either:- Nested:
{ "run_command": { "max_lines": 500 } }
- Or top-level:
{ "max_lines": 500 }
- Nested:
- Create a
MIT
-
If Claude for Desktop doesn't connect to the server, check the Docker container status:
docker ps -a | grep mcp-file-server
-
View server logs:
- Prefer your MCP client's server logs panel when launching via
docker exec
. - If running the server as the container's main process,
docker logs mcp-file-server
works as well.
- Prefer your MCP client's server logs panel when launching via
-
Make sure the volume is correctly mounted:
docker inspect mcp-file-server | grep -A 10 Mounts