home / mcp / filesystem mcp server
Go server implementing Model Context Protocol (MCP) for filesystem operations.
Configuration
View docs{
"mcpServers": {
"mark3labs-mcp-filesystem-server": {
"command": "mcp-filesystem-server",
"args": [
"/path/to/allowed/directory",
"/another/allowed/directory"
]
}
}
}The MCP Filesystem Server provides secure access to your local filesystem through the Model Context Protocol, letting you read, write, move, copy, delete, and query files and directories with built‑in safety checks. It exposes a rich set of tools for common filesystem operations while guarding against traversal attacks and handling different MIME types.
You access the Filesystem MCP server from an MCP client by starting the server locally or by running it inside a container, then connecting your client to the provided MCP endpoint. The server offers a comprehensive suite of file and directory operations that you can call from your MCP-enabled app. Use the server to read file contents, list directories, search for files, modify text, and perform safe file transfers while benefiting from path validation and symlink safety checks.
Prerequisites: ensure you have Go installed if you want to build from sources, or use the prebuilt MCP server binary via the provided execution commands.
Step 1: Install the server as a standalone executable.
Go install approach (if you are building from source or using the Go toolchain):
go install github.com/mark3labs/mcp-filesystem-server@latestRun the server with one or more allowed directories. The server enforces path validation and resolves symlinks securely.
Starting as a standalone server with one or more allowed paths:
mcp-filesystem-server /path/to/allowed/directory [/another/allowed/directory ...]You can run the MCP Filesystem Server inside Docker for isolation and portability.
Docker run example:
docker run -i --rm ghcr.io/mark3labs/mcp-filesystem-server:latest /path/to/allowed/directoryIf you integrate with a client using MCP, you can configure a connection that launches the server and points to the allowed directories. The following example shows how you might define a connection in MCP client configuration to start the server with the required paths.
{
"mcpServers": {
"filesystem": {
"command": "mcp-filesystem-server",
"args": ["/path/to/allowed/directory", "/another/allowed/directory"]
}
}
}Read the complete contents of a file from the file system with a required path parameter.
Read contents of multiple files in a single operation by providing a list of file paths.
Create a new file or overwrite an existing file with new content, given a path and content.
Copy files and directories from a source path to a destination path.
Move or rename files and directories from a source path to a destination path.
Delete a file or directory, with an optional recursive flag for directories.
Update a file by finding and replacing text, with optional regex and replacement scope.
Get a detailed listing of all files and directories within a specified directory.
Create a new directory or ensure it exists at the given path.
Return a hierarchical JSON representation of a directory structure, with options for depth and following symlinks.
Recursively search for files and directories that match a given pattern starting from a path.
Search for text within file contents across directory trees with optional depth and result limits.
Retrieve detailed metadata about a specific file or directory.
Return the list of directories this server is configured to access.