BTRFS Snapper MCP
BTRFS Snapper MCP
An MCP (Model Context Protocol) server for managing BTRFS snapshots via Snapper and monitoring BTRFS filesystem health. Exposes two unified tools with action-based dispatch to minimize tool proliferation while providing full snapshot management and disk health monitoring.
Features
Two-tool design:
snapperfor snapshots,btrfs_healthfor filesystem monitoringFull Snapper support: list, create, delete, rollback, cleanup, diff, status
BTRFS health monitoring: usage, device stats, scrub status, balance status
Flexible configuration: Environment variables for cross-system portability
No hardcoded paths: Works with any Snapper configuration and mount points
Installation
From PyPI (recommended)
pip install snapper-mcpUsing uvx (no install required)
uvx snapper-mcpFrom source
git clone https://github.com/danielrosehill/BTRFS-Snapper-MCP.git
cd BTRFS-Snapper-MCP
pip install -e .Configuration
The server is configured via environment variables, making it portable across systems:
Variable | Default | Description |
|
| Set to |
|
| Path to snapper binary |
|
| Path to btrfs binary |
|
| Path to sudo binary |
|
| Default snapper config name |
|
| Default BTRFS mount point |
|
| Command timeout in seconds |
MCP Client Configuration
Claude Code / Claude Desktop
Add to your MCP settings (e.g., ~/.claude/settings.json or Claude Desktop config):
{
"mcpServers": {
"btrfs-snapper": {
"command": "uvx",
"args": ["snapper-mcp"]
}
}
}With custom configuration
{
"mcpServers": {
"btrfs-snapper": {
"command": "uvx",
"args": ["snapper-mcp"],
"env": {
"SNAPPER_MCP_DEFAULT_CONFIG": "root",
"SNAPPER_MCP_DEFAULT_MOUNT": "/",
"SNAPPER_MCP_USE_SUDO": "true"
}
}
}
}Tools
snapper - Snapshot Management
Manages BTRFS snapshots via Snapper.
Actions
Action | Description | Required Parameters |
| List available snapper configurations | - |
| Show all snapshots for a config |
|
| Create a new snapshot |
|
| Remove a snapshot by number |
|
| Restore to a previous snapshot |
|
| Prune snapshots using an algorithm |
|
| Show file differences between snapshots |
|
| List changed files between snapshots |
|
Examples
// List configurations
{"action": "configs"}
// List snapshots
{"action": "list", "config": "root"}
// Create snapshot
{"action": "create", "config": "root", "description": "Before system update"}
// Delete snapshot
{"action": "delete", "config": "root", "snapshot_id": 5}
// Rollback (requires reboot)
{"action": "rollback", "config": "root", "snapshot_id": 3}
// Cleanup with algorithm
{"action": "cleanup", "config": "root", "cleanup_algorithm": "number"}
// Compare snapshots
{"action": "diff", "config": "root", "snapshot_id": 1, "snapshot_id_end": 5}Cleanup algorithms:
number: Keep a fixed number of snapshotstimeline: Keep snapshots based on age (hourly, daily, weekly, monthly, yearly)empty-pre-post: Remove empty pre/post snapshot pairs
btrfs_health - Filesystem Health Monitoring
Monitors BTRFS filesystem health and status.
Actions
Action | Description | Parameters |
| Comprehensive filesystem space usage |
|
| List devices in the BTRFS array |
|
| Device error statistics |
|
| Status of scrub operation |
|
| Status of balance operation |
|
| Space allocation by data type |
|
| Filesystem information |
|
Examples
// Check filesystem usage
{"action": "usage", "mount_point": "/"}
// Check for device errors
{"action": "stats", "mount_point": "/"}
// Check scrub status
{"action": "scrub_status", "mount_point": "/"}
// Show data/metadata allocation
{"action": "df", "mount_point": "/"}
// Show filesystem info
{"action": "filesystem_show"}Prerequisites
Linux with BTRFS filesystem
Snapper installed and configured (for snapshot management)
Python 3.10+
Sudo access (unless running as root or with appropriate permissions)
Installing Snapper
Ubuntu/Debian:
sudo apt install snapperFedora/openSUSE:
sudo dnf install snapper
# or
sudo zypper install snapperCreating Snapper Configs
# For root filesystem
sudo snapper -c root create-config /
# For home partition
sudo snapper -c home create-config /homeSudo Configuration
For passwordless operation, add to /etc/sudoers.d/btrfs-snapper:
yourusername ALL=(ALL) NOPASSWD: /usr/bin/snapper
yourusername ALL=(ALL) NOPASSWD: /usr/bin/btrfsOr disable sudo if you have direct permissions:
{
"env": {
"SNAPPER_MCP_USE_SUDO": "false"
}
}Adapting for Other Systems
Different Snapshot Tools
The architecture can be adapted for other snapshot tools (e.g., Timeshift, ZFS snapshots) by:
Replacing the
run_snapper_command()function with your tool's CLIAdjusting the action handlers for your tool's command syntax
Updating environment variables as needed
Different Filesystems
For ZFS or other filesystems:
Replace
run_btrfs_command()with your filesystem's CLIUpdate
BtrfsActionenum with relevant actionsImplement new handlers for your filesystem's commands
The action-dispatch pattern remains the same regardless of underlying tools.
License
MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/danielrosehill/BTRFS-Snapper-MCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server