The MCP Filesystem Server provides secure access to your local file system through the Model Context Protocol (MCP). It allows you to perform various operations on files and directories from applications that support MCP, with built-in security features to prevent unauthorized access.
The simplest way to install the MCP Filesystem Server is using Go's install command:
go install github.com/mark3labs/mcp-filesystem-server@latest
You can also run the server using Docker:
docker run -i --rm ghcr.io/mark3labs/mcp-filesystem-server:latest /path/to/allowed/directory
Start the MCP server with one or more allowed directories:
mcp-filesystem-server /path/to/allowed/directory [/another/allowed/directory ...]
The server will only provide access to the directories you specify, preventing access to other parts of your file system.
You can integrate the server into your Go applications:
package main
import (
"log"
"os"
"github.com/mark3labs/mcp-filesystem-server/filesystemserver"
)
func main() {
// Create a new filesystem server with allowed directories
allowedDirs := []string{"/path/to/allowed/directory", "/another/allowed/directory"}
fs, err := filesystemserver.NewFilesystemServer(allowedDirs)
if err != nil {
log.Fatalf("Failed to create server: %v", err)
}
// Serve requests
if err := fs.Serve(); err != nil {
log.Fatalf("Server error: %v", err)
}
}
To use this server with applications that support the Model Context Protocol:
{
"mcpServers": {
"filesystem": {
"command": "mcp-filesystem-server",
"args": ["/path/to/allowed/directory", "/another/allowed/directory"]
}
}
}
When using Docker with MCP-supporting applications:
{
"mcpServers": {
"filesystem": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"ghcr.io/mark3labs/mcp-filesystem-server:latest",
"/path/to/allowed/directory"
]
}
}
}
To allow the Docker container to access and modify files on your host system:
{
"mcpServers": {
"filesystem": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--volume=/allowed/directory/in/host:/allowed/directory/in/container",
"ghcr.io/mark3labs/mcp-filesystem-server:latest",
"/allowed/directory/in/container"
]
}
}
}
read_file: Read a file's contents
path
(required): Path to the fileread_multiple_files: Read multiple files at once
paths
(required): List of file pathswrite_file: Create or overwrite a file
path
(required), content
(required)copy_file: Copy files or directories
source
(required), destination
(required)move_file: Move or rename files or directories
source
(required), destination
(required)delete_file: Delete a file or directory
path
(required), recursive
(optional, default: false)modify_file: Update file contents by finding and replacing text
path
(required), find
(required), replace
(required), all_occurrences
(optional, default: true), regex
(optional, default: false)list_directory: Get contents of a directory
path
(required)create_directory: Create a new directory
path
(required)tree: Get a hierarchical representation of a directory structure
path
(required), depth
(optional, default: 3), follow_symlinks
(optional, default: false)search_files: Find files matching a pattern
path
(required), pattern
(required)search_within_files: Search for text within file contents
path
(required), substring
(required), depth
(optional), max_results
(optional, default: 1000)get_file_info: Get metadata about a file or directory
path
(required)list_allowed_directories: Show directories the server can access
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "filesystem" '{"command":"mcp-filesystem-server","args":["/path/to/allowed/directory","/another/allowed/directory"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"filesystem": {
"command": "mcp-filesystem-server",
"args": [
"/path/to/allowed/directory",
"/another/allowed/directory"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"filesystem": {
"command": "mcp-filesystem-server",
"args": [
"/path/to/allowed/directory",
"/another/allowed/directory"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect