This MCP server provides file system operations for navigating directories, reading and writing files, analyzing content, and executing commands. It offers a comprehensive set of tools to interact with the file system programmatically.
The MCP File System Server can be installed and run as part of an MCP-enabled environment. No separate installation is needed if you're already working with an MCP setup.
The server provides various tools organized by functionality. Here's how to use each category of operations:
Navigate and manipulate files and directories:
# List directory contents
ls("/path/to/directory")
# Change working directory
cd("/path/to/directory")
# Use tilde for home directory
cd("~/projects")
# Read file contents
content = read_file("/path/to/file.txt")
# Write content to a file
write_file("/path/to/file.txt", "This is the new content")
# Create directory
mkdir("/path/to/new_directory")
# Remove file or empty directory
rm("/path/to/file.txt")
# Remove directory and contents recursively
rmdir("/path/to/directory")
# Copy file or directory
cp("/path/to/source", "/path/to/destination")
# Move file or directory
mv("/path/to/source", "/path/to/destination")
Modify files and search for content:
# Apply multiple search/replace operations to a file
edit_file("/path/to/file.txt", [
("old text", "new text"),
("another old text", "another new text")
])
# Search for regex pattern in file(s)
results = grep("pattern", "/path/to/file.txt")
Analyze file contents:
# Generate summary of Python or Markdown files
summary = summary("/path/to/file.py") # Lists functions and classes
summary = summary("/path/to/file.md") # Lists headers
Process multiple files simultaneously:
# Read multiple files
files_content = read_files(["/path/to/file1.txt", "/path/to/file2.txt"])
# Generate summaries for multiple files
summaries = summarize(["/path/to/file1.py", "/path/to/file2.md"])
Quickly explore project directories:
# Change to directory, list contents, and get notes
work_on("/path/to/project")
Check and format code:
# Run ruff linter on specified files
lint_results = ruff_check(["/path/to/file.py"])
# Format files using ruff
ruff_format(["/path/to/file.py"])
Execute shell commands:
# Run a shell command with arguments
result = shell_command("ls", ["-la"])
# Run a shell command with complete command line
result = shell_command(cmdline="ls -la | grep 'file'", timeout=60)
⚠️ Security Warning: The shell_command tool allows arbitrary command execution on the host system. Always inspect and validate commands before allowing them to run, especially if the input source is untrusted.
Here's a complete workflow example:
# Navigate to a project directory
cd("~/projects/my_python_app")
# List the directory contents
files = ls(".")
# Read a Python file
code = read_file("main.py")
# Get a summary of the Python file
main_summary = summary("main.py")
# Run the linter on all Python files
lint_results = ruff_check(["*.py"])
# Execute the application
output = shell_command("python", ["main.py", "--verbose"])
# Edit a configuration file
edit_file("config.json", [
('"debug": false', '"debug": true'),
('"log_level": "info"', '"log_level": "debug"')
])
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.