Go server implementing Model Context Protocol (MCP) for filesystem operations.
What is mcp-filesystem-server
MCP Filesystem Server
This MCP server provides secure access to the local filesystem via the Model Context Protocol (MCP).
Components
Tools
File Operations
-
read_file
- Read the complete contents of a file from the file system
- Parameters:
path
(required): Path to the file to read
-
read_multiple_files
- Read the contents of multiple files in a single operation
- Parameters:
paths
(required): List of file paths to read
-
write_file
- Create a new file or overwrite an existing file with new content
- Parameters:
path
(required): Path where to write the file,content
(required): Content to write to the file
-
copy_file
- Copy files and directories
- Parameters:
source
(required): Source path of the file or directory,destination
(required): Destination path
-
move_file
- Move or rename files and directories
- Parameters:
source
(required): Source path of the file or directory,destination
(required): Destination path
-
delete_file
- Delete a file or directory from the file system
- Parameters:
path
(required): Path to the file or directory to delete,recursive
(optional): Whether to recursively delete directories (default: false)
Directory Operations
-
list_directory
- Get a detailed listing of all files and directories in a specified path
- Parameters:
path
(required): Path of the directory to list
-
create_directory
- Create a new directory or ensure a directory exists
- Parameters:
path
(required): Path of the directory to create
-
tree
- Returns a hierarchical JSON representation of a directory structure
- Parameters:
path
(required): Path of the directory to traverse,depth
(optional): Maximum depth to traverse (default: 3),follow_symlinks
(optional): Whether to follow symbolic links (default: false)
Search and Information
-
search_files
- Recursively search for files and directories matching a pattern
- Parameters:
path
(required): Starting path for the search,pattern
(required): Search pattern to match against file names
-
get_file_info
- Retrieve detailed metadata about a file or directory
- Parameters:
path
(required): Path to the file or directory
-
list_allowed_directories
- Returns the list of directories that this server is allowed to access
- Parameters: None
Features
- Secure access to specified directories
- Path validation to prevent directory traversal attacks
- Symlink resolution with security checks
- MIME type detection
- Support for text, binary, and image files
- Size limits for inline content and base64 encoding
Getting Started
Installation
Using Go Install
go install github.com/mark3labs/mcp-filesystem-server@latest
Usage
As a standalone server
Start the MCP server with allowed directories:
mcp-filesystem-server /path/to/allowed/directory [/another/allowed/directory ...]
As a library in your Go project
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)
}
}
Usage with Model Context Protocol
To integrate this server with apps that support MCP:
{
"mcpServers": {
"filesystem": {
"command": "mcp-filesystem-server",
"args": ["/path/to/allowed/directory", "/another/allowed/directory"]
}
}
}
Docker
Running with Docker
You can run the Filesystem MCP server using Docker:
docker run -i --rm ghcr.io/mark3labs/mcp-filesystem-server:latest /path/to/allowed/directory
Docker Configuration with MCP
To integrate the Docker image with apps that support MCP:
{
"mcpServers": {
"filesystem": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"ghcr.io/mark3labs/mcp-filesystem-server:latest",
"/path/to/allowed/directory"
]
}
}
}
License
See the LICENSE file for details.
Leave a Comment
Frequently Asked Questions
What is MCP?
MCP (Model Context Protocol) is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications, providing a standardized way to connect AI models to different data sources and tools.
What are MCP Servers?
MCP Servers are lightweight programs that expose specific capabilities through the standardized Model Context Protocol. They act as bridges between LLMs like Claude and various data sources or services, allowing secure access to files, databases, APIs, and other resources.
How do MCP Servers work?
MCP Servers follow a client-server architecture where a host application (like Claude Desktop) connects to multiple servers. Each server provides specific functionality through standardized endpoints and protocols, enabling Claude to access data and perform actions through the standardized protocol.
Are MCP Servers secure?
Yes, MCP Servers are designed with security in mind. They run locally with explicit configuration and permissions, require user approval for actions, and include built-in security features to prevent unauthorized access and ensure data privacy.
Related MCP Servers
aashari mcp server atlassian bitbucket
Node.js/TypeScript MCP server for Atlassian Bitbucket. Enables AI systems (LLMs) to interact with workspaces, repositories, and pull requests via tools (list, get, comment, search). Connects AI directly to version control workflows through the standard MCP interface.
aashari mcp server atlassian confluence
Node.js/TypeScript MCP server for Atlassian Confluence. Provides tools enabling AI systems (LLMs) to list/get spaces & pages (content formatted as Markdown) and search via CQL. Connects AI seamlessly to Confluence knowledge bases using the standard MCP interface.
prisma prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
yaoxiaolinglong mcp mongodb mysql server
用于mysql和mongodb的mcp
tomschell mcp long term memory
A long-term memory storage system for LLMs using the Model Context Protocol (MCP) standard. This system helps LLMs remember the context of work done over the entire history of a project, even across multiple sessions. It uses semantic search with embeddings to provide relevant context from past interactions and development decisions.
stevearagonsite PythonServerMcp
A template repository for MCP
RmMargt searchAPI mcp
SearchAPI MCP for Google searches
mario andreschak mcp veo2
MCP for Video- or Image-Generation with Google VEO2
kalivaraprasad gonapa react mcp
react-mcp integrates with Claude Desktop, enabling the creation and modification of React apps based on user prompts
isdaniel mcp metal price
An MCP server that provides current and historical gold/precious metal prices via the GoldAPI.io service.
Submit Your MCP Server
Share your MCP server with the community
Submit Now