Skip to main content
Glama
BTRFS Snapper MCP

BTRFS Snapper MCP

BTRFS Snapper MCP

PyPI Built with Claude Code

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: snapper for snapshots, btrfs_health for filesystem monitoring

  • Full 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

Related MCP server: aha-mcp

Installation

pip install snapper-mcp

Using uvx (no install required)

uvx snapper-mcp

From 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

SNAPPER_MCP_USE_SUDO

true

Set to false if user has direct permissions

SNAPPER_MCP_SNAPPER_PATH

snapper

Path to snapper binary

SNAPPER_MCP_BTRFS_PATH

btrfs

Path to btrfs binary

SNAPPER_MCP_SUDO_PATH

sudo

Path to sudo binary

SNAPPER_MCP_DEFAULT_CONFIG

root

Default snapper config name

SNAPPER_MCP_DEFAULT_MOUNT

/

Default BTRFS mount point

SNAPPER_MCP_TIMEOUT

60

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

configs

List available snapper configurations

-

list

Show all snapshots for a config

config (optional)

create

Create a new snapshot

config, description (optional)

delete

Remove a snapshot by number

config, snapshot_id

rollback

Restore to a previous snapshot

config, snapshot_id

cleanup

Prune snapshots using an algorithm

config, cleanup_algorithm

diff

Show file differences between snapshots

config, snapshot_id, snapshot_id_end

status

List changed files between snapshots

config, snapshot_id, snapshot_id_end

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 snapshots

  • timeline: 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

usage

Comprehensive filesystem space usage

mount_point (optional)

devices

List devices in the BTRFS array

mount_point (optional)

stats

Device error statistics

mount_point, device (optional)

scrub_status

Status of scrub operation

mount_point (optional)

balance_status

Status of balance operation

mount_point (optional)

df

Space allocation by data type

mount_point (optional)

filesystem_show

Filesystem information

mount_point (optional)

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 snapper

Fedora/openSUSE:

sudo dnf install snapper
# or
sudo zypper install snapper

Creating Snapper Configs

# For root filesystem
sudo snapper -c root create-config /

# For home partition
sudo snapper -c home create-config /home

Sudo Configuration

For passwordless operation, add to /etc/sudoers.d/btrfs-snapper:

yourusername ALL=(ALL) NOPASSWD: /usr/bin/snapper
yourusername ALL=(ALL) NOPASSWD: /usr/bin/btrfs

Or 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:

  1. Replacing the run_snapper_command() function with your tool's CLI

  2. Adjusting the action handlers for your tool's command syntax

  3. Updating environment variables as needed

Different Filesystems

For ZFS or other filesystems:

  1. Replace run_btrfs_command() with your filesystem's CLI

  2. Update BtrfsAction enum with relevant actions

  3. Implement new handlers for your filesystem's commands

The action-dispatch pattern remains the same regardless of underlying tools.

License

MIT

Available Tools

2 tools
btrfs_healthA

Check BTRFS filesystem health and status. Monitor disk usage, errors, and maintenance operations.

Actions:

  • usage: Comprehensive filesystem space usage

  • devices: List devices in the BTRFS array

  • stats: Device error statistics (corruption, read/write errors)

  • scrub_status: Status of scrub operation (data integrity check)

  • balance_status: Status of balance operation (data redistribution)

  • df: Space allocation by data type (Data, Metadata, System)

  • filesystem_show: Filesystem information and device list

Current default mount: / Using sudo: True

Examples:

  • Check usage: action="usage", mount_point="/"

  • Check for errors: action="stats", mount_point="/"

  • Scrub status: action="scrub_status", mount_point="/"

  • Show filesystem: action="filesystem_show"

Inputs: action (required), mount_point, device.

snapperA

Manage BTRFS snapshots via Snapper. A unified tool for all snapshot operations.

Actions:

  • configs: List available snapper configurations

  • list: Show all snapshots for a config

  • create: Create a new snapshot (optionally with description)

  • delete: Remove a snapshot by number

  • rollback: Restore system to a previous snapshot (requires reboot)

  • cleanup: Prune snapshots using an algorithm (number, timeline, empty-pre-post)

  • diff: Show file differences between two snapshots

  • status: List changed files between two snapshots

Current default config: root Using sudo: True

Examples:

  • List configs: action="configs"

  • List snapshots: action="list", config="root"

  • Create snapshot: action="create", config="root", description="Before update"

  • Delete snapshot: action="delete", config="root", snapshot_id=5

  • Compare snapshots: action="diff", config="root", snapshot_id=1, snapshot_id_end=5

  • Cleanup old snapshots: action="cleanup", config="root", cleanup_algorithm="number"

Inputs: action (required), config, snapshot_id, snapshot_id_end, +3 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.3/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools have completely distinct purposes: btrfs_health monitors filesystem health, and snapper manages snapshots. There is no overlap in functionality, so an agent can easily distinguish when to use each.

    Naming Consistency4/5

    Both tool names are descriptive and use a clear style (btrfs_health uses prefix 'btrfs_', snapper uses the application name). While there is no strict pattern like verb_noun, the names are intuitive and consistent in being self-explanatory.

    Tool Count2/5

    Only two tools for a complex domain like BTRFS management is minimal. Each tool bundles many sub-actions, which could be separate tools for better discoverability. The low count suggests an incomplete surface for tasks like defragmentation or advanced configuration.

    Completeness4/5

    The tools cover essential BTRFS operations: health monitoring (usage, errors, scrub, balance) and snapshot management (create, delete, rollback, diff, cleanup). Missing are direct balance initiation or defragmentation, but these are covered by status checks, making the set fairly comprehensive for core tasks.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables interaction with Proxmox VE for managing VMs, containers, storage, and cluster resources via natural language through the Model Context Protocol.
      73
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables natural language interaction with Home Assistant for managing entities, automations, services, and dashboards via the Model Context Protocol.
      154 npm
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables read-only observability of Windows systems, exposing CPU, memory, storage, service, and health information through Model Context Protocol tools.
      MIT