The Filesystem MCP Server implements the Model Context Protocol for performing filesystem operations. It allows you to read and write files, manage directories, search for files, and get detailed file information through a standardized interface that can be used with AI assistants like Claude.
To install the Filesystem MCP Server, use Go's package manager:
go install github.com/mark3labs/mcp-filesystem-server
The server only allows operations within directories explicitly specified during startup. This is an important security feature to prevent unrestricted filesystem access.
To use this server with Claude Desktop, add the following to your claude_desktop_config.json
file:
{
"mcpServers": {
"filesystem": {
"command": "mcp-filesystem-server",
"args": [
"/Users/username/Desktop",
"/path/to/other/allowed/dir"
]
}
}
}
Replace the paths in the args
array with the directories you want to allow access to.
To read the contents of a file:
read_file
Input: path (string) - The path to the file
To read multiple files simultaneously:
read_multiple_files
Input: paths (string[]) - Array of file paths
Note: Failed reads won't stop the entire operation when reading multiple files.
To create a new file or overwrite an existing one:
write_file
Inputs:
- path (string): File location
- content (string): File content
Use this tool with caution as it will overwrite existing files.
To create a new directory:
create_directory
Input: path (string) - The path to create
This will create parent directories if needed and succeed silently if the directory already exists.
To list the contents of a directory:
list_directory
Input: path (string) - The directory path
Results include file or directory indication with [FILE] or [DIR] prefixes.
To move or rename files and directories:
move_file
Inputs:
- source (string): Original location
- destination (string): New location
This operation will fail if the destination already exists.
To search for files recursively:
search_files
Inputs:
- path (string): Starting directory
- pattern (string): Search pattern
The search is case-insensitive and returns full paths to all matches.
To retrieve detailed metadata about a file or directory:
get_file_info
Input: path (string) - The path to examine
Returns size, creation time, modified time, access time, type, and permissions.
To generate a hierarchical representation of a directory:
tree
Inputs:
- path (string): Directory to traverse
- depth (number): Maximum depth (default: 3)
- follow_symlinks (boolean): Whether to follow symbolic links (default: false)
Returns a formatted JSON with file/directory hierarchy including metadata.
To see which directories the server has access to:
list_allowed_directories
No input required
Returns all directories that the server is configured to access.
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 > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.