Skip to main content

MCP server for inspecting KubeStash backup health on any Kubernetes cluster via the Kubernetes API

Project description

kubestash-mcp

An MCP server for inspecting KubeStash backup health on any Kubernetes cluster. It connects through your kubeconfig — exactly like kubectl — and exposes read-only tools that an AI assistant (Claude Code, Claude Desktop, etc.) can call in natural language.

Its headline capability is stuck-repository detection: KubeStash's Repository.status.lastBackupTime can freeze while backups keep succeeding, which silently breaks any alert that reads that field. This server computes the true backup freshness from status.recentSnapshots and tells you when the two disagree.

No vendor lock-in: no hardcoded endpoints, clusters, metrics backend, or auth. If kubectl can reach your cluster, so can this.

Install

# run straight from PyPI, no install
uvx mcp-server-kubestash

# or install into a tool environment
uv tool install mcp-server-kubestash

Requires Python 3.11+ and a kubeconfig with access to the KubeStash CRDs (core.kubestash.com, storage.kubestash.com).

Configure an MCP client

Add to your MCP client config (e.g. ~/.mcp.json):

{
  "mcpServers": {
    "kubestash": {
      "type": "stdio",
      "command": "uvx",
      "args": ["mcp-server-kubestash"],
      "env": {
        "KUBESTASH_CONTEXTS": "all",
        "KUBESTASH_STALE_HOURS": "24"
      }
    }
  }
}

All settings are optional — see .env.example:

Variable Default Meaning
KUBESTASH_CONTEXTS all all / `` (current) / CSV of context names or unique short ids
KUBESTASH_CONTEXTS_EXCLUDE fnmatch globs dropped after resolution
KUBESTASH_NAMESPACES namespaces to search (empty = whole cluster)
KUBESTASH_STALE_HOURS 24 freshness threshold for "stale"
KUBESTASH_STUCK_THRESHOLD_MINUTES 60 tolerance before a repo counts as "stuck"
KUBECONFIG standard kubeconfig path override

Tools

Tool What it does
list_clusters The kubeconfig contexts that will be queried, and any that didn't resolve
backup_health Fleet rollup: session phase counts, repo counts, stuck/stale, overall verdict
list_repositories Repositories with freshness + stuck check
detect_stuck_repositories Only the repositories whose lastBackupTime has frozen
list_backup_sessions BackupSessions, optionally filtered by phase
list_backup_configurations What's configured to back up: target, schedule, history limit
repository_detail One repository, including the raw recentSnapshots
diagnose_failed_session Triage a failed BackupSession + remediation hints

All tools are read-only — the server never mutates cluster state.

How "stuck" is determined

For each Repository, the server compares status.lastBackupTime against the newest status.recentSnapshots[].snapshotTime whose phase == "Succeeded". If the newest succeeded snapshot is more than KUBESTASH_STUCK_THRESHOLD_MINUTES newer than lastBackupTime — or snapshots exist but lastBackupTime is unset — the repository is stuck: backups are healthy, but the status field (and anything alerting on it) is not.

Development

uv sync --all-extras --dev
uv run ruff check .
uv run pytest -q

The suite is fully offline (the Kubernetes client is mocked). A small opt-in end-to-end check runs against a real cluster when RUN_E2E=1 and a kubeconfig are present.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_server_kubestash-0.1.0.tar.gz (128.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_server_kubestash-0.1.0-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file mcp_server_kubestash-0.1.0.tar.gz.

File metadata

  • Download URL: mcp_server_kubestash-0.1.0.tar.gz
  • Upload date:
  • Size: 128.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mcp_server_kubestash-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0697dc528e2dbfdb9d8e911453874b32c5f29016b2f21ad090cea20a16e2a2d2
MD5 ca52045906fb2cb6cc959726aea882dc
BLAKE2b-256 21ab07f9a8a0ae1772c3b57c5eee7d3b0337bc777b2fbb4ff8422b5de3bf5d7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_server_kubestash-0.1.0.tar.gz:

Publisher: publish.yml on margus/kubestash-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcp_server_kubestash-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_server_kubestash-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bafab2061bd8457bcd688da0715ca9744c4edef256f6ed8c0c0e39273925a86d
MD5 00fcde3784113e4584e3186b612f7549
BLAKE2b-256 282b8aa360a6e2f12f04983d3757b242f4cd86a8243cb690b7a92d23923181bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_server_kubestash-0.1.0-py3-none-any.whl:

Publisher: publish.yml on margus/kubestash-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page