
MCP Filesystem Server
Secure local filesystem access for MCP clients — read, write, search, and manage files within allowed directories.
Add to your client
Copy the config for your MCP client and paste it into its config file.
go install github.com/mark3labs/mcp-filesystem-server@latestPaste into ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"mcp-filesystem-server": {
"command": "mcp-filesystem-server",
"args": [
"/path/to/allowed/directory",
"/another/allowed/directory"
]
}
}
}Step-by-step guides: Add to Claude Desktop · Add to Cursor · Add to Windsurf
Before you start
- Go (for `go install`) or Docker (to run the container image)
- One or more local directories to expose, passed as command arguments
About MCP Filesystem Server
An MCP server written in Go that gives MCP-compatible clients secure, sandboxed access to the local filesystem. It exposes a comprehensive set of file and directory tools (read, write, copy, move, delete, modify, list, tree, search by name, search within file contents, and metadata retrieval) plus a file:// resource. Access is limited to directories explicitly allowed at startup, with path validation and symlink security checks. It can run standalone over stdio (Go install or Docker) or be embedded as a library in a Go program.
Tools & capabilities (14)
read_fileRead the complete contents of a file from the file system. Parameters: path (required).
read_multiple_filesRead the contents of multiple files in a single operation. Parameters: paths (required, list of file paths).
write_fileCreate a new file or overwrite an existing file with new content. Parameters: path (required), content (required).
copy_fileCopy files and directories. Parameters: source (required), destination (required).
move_fileMove or rename files and directories. Parameters: source (required), destination (required).
delete_fileDelete a file or directory from the file system. Parameters: path (required), recursive (optional, default false).
modify_fileUpdate a file by finding and replacing text using string matching or regex. Parameters: path (required), find (required), replace (required), all_occurrences (optional, default true), regex (optional, default false).
list_directoryGet a detailed listing of all files and directories in a specified path. Parameters: path (required).
create_directoryCreate a new directory or ensure a directory exists. Parameters: path (required).
treeReturn a hierarchical JSON representation of a directory structure. Parameters: path (required), depth (optional, default 3), follow_symlinks (optional, default false).
search_filesRecursively search for files and directories matching a pattern. Parameters: path (required), pattern (required).
search_within_filesSearch for text within file contents across directory trees. Parameters: path (required), substring (required), depth (optional), max_results (optional, default 1000).
get_file_infoRetrieve detailed metadata about a file or directory. Parameters: path (required).
list_allowed_directoriesReturn the list of directories that this server is allowed to access. No parameters.
What this server can do
MCP Filesystem Server provides tools for these capabilities — tap one to see every MCP server that does the same:
When to use it
- Let an AI assistant read and edit code or documents within a sandboxed project directory
- Search across a directory tree for files by name or by their text contents
- Inspect directory structure and file metadata before making changes
- Perform bulk file operations (copy, move, delete) under explicit directory restrictions
- Run filesystem access in an isolated Docker container with an optional host volume mount
Security notes
Access is restricted to the directories passed as command arguments. The server performs path validation to prevent directory-traversal attacks and resolves symlinks with security checks. Use the list_allowed_directories tool to see which directories are accessible. When using Docker, mount a host volume only if you intend changes inside the container to reflect on the host filesystem.
MCP Filesystem Server FAQ
How is filesystem access restricted?
The server only accesses the directories you pass as command arguments at startup. It validates paths to prevent directory-traversal attacks and resolves symlinks with security checks. The list_allowed_directories tool returns the directories currently accessible.
What transport does it use?
It runs as a standalone stdio server, launched via the `mcp-filesystem-server` command (or `docker run`) with allowed directories as arguments.
Can I use it inside a Go program instead of as a standalone server?
Yes. Import github.com/mark3labs/mcp-filesystem-server/filesystemserver, create a server with NewFilesystemServer(allowedDirs), and call Serve().
Does it work with Docker?
Yes. Run `docker run -i --rm ghcr.io/mark3labs/mcp-filesystem-server:latest /path/to/allowed/directory`. To reflect changes on the host filesystem, mount a volume with --volume mapping a host directory into the container.
What file types are supported?
Text, binary, and image files. The server performs MIME type detection and applies size limits for inline content and base64 encoding.
Alternatives to MCP Filesystem Server
Compare all alternatives →Official MCP reference server for secure local filesystem read/write within allowed directories.
Official MCP server for reading, searching, and manipulating a local Git repository's files and history.
Official AWS Labs MCP server to manage and query S3 Tables (table buckets, namespaces, tables).
Compare MCP Filesystem Server with: