Skip to main content

snap-maintainer

PyPI License: MIT

Find out which of your published snaps need a rebuild or a new release, and why.

snap-maintainer reads your Snap Store account, finds the source repository behind each snap, and checks it against three things:

  • Security fixes. Ubuntu has fixed a package your snap stages, and a rebuild would pick up the fix.
  • Unreleased changes. Your repo has commits, or a version bump, that aren't in the published revision.
  • Upstream releases. A part pulls from a git repo that has moved on.

For every snap that needs work, it writes out the exact steps to rebuild and release it, matched to how that snap is built: a GitHub Actions workflow, a Launchpad recipe, or a local snapcraft pack.

It never builds, uploads or releases anything itself. Those steps need someone watching, so the tool stops at a plan that a person, or an agent, can follow. Agents can also use it directly through its built-in MCP server.

Requirements

  • Python 3.10 or later
  • snapcraft, logged in to the Snap Store as the snaps' publisher: snapcraft login
  • The GitHub CLI gh, logged in: gh auth login
  • Optional:
    • unsquashfs (package squashfs-tools): looks inside published snaps, for exact or checked security results instead of inferred ones.
    • git: compares pinned source-tags with upstream tags.
    • The mcp Python package: only for the MCP server (snap-maintainer mcp).

The tool checks all of these when it starts, and tells you the command to fix anything that's missing.

Install

From PyPI, with pip or pipx:

pip install snap-maintainer        # or: pipx install snap-maintainer

To use it from an agent, install the MCP extra instead:

pip install 'snap-maintainer[mcp]'  # or: pipx install 'snap-maintainer[mcp]'

The latest development version comes straight from GitHub:

pipx install git+https://github.com/carlosbravoa/snap-maintainer.git

From a checkout, for development:

git clone https://github.com/carlosbravoa/snap-maintainer.git
cd snap-maintainer
pipx install --editable .

You can also run it without installing, from the checkout: PYTHONPATH=src python3 -m snap_maintainer <command>.

Quick start

snap-maintainer discover       # find your snaps, their repos and how they're built
snap-maintainer check          # decide which need a rebuild or release
snap-maintainer plan           # the steps to rebuild and release each of them

The first check downloads Ubuntu archive and security data and the published snaps themselves, so it takes a few minutes. Later runs use a cache.

Commands

Command What it does
discover [snaps...] Lists the snaps registered to your account, their channels, source repos and builders, and saves them to the inventory. Prompts for a repo it can't find (--no-input to skip).
check [snaps...] Gives each snap a verdict, rebuild, update or up to date, with the reasons. -v shows every notice, commit and note; --refresh re-downloads cached Ubuntu data.
plan [snaps...] Shows the steps to rebuild and release every snap that needs it, or just the named ones. --all includes up-to-date snaps; --markdown and --json print it for an issue, an agent or a script. Runs nothing.
show [--json] Prints the inventory without contacting anything.
set-repo <snap> <url> Sets a snap's source repo by hand.
set-build <snap> <method> [--workflow FILE] Sets how a snap is built: github-workflow, launchpad, local or manual.
mcp Runs an MCP server so an agent can use the tool directly. See Use it from an agent (MCP).

Repos and builders you set by hand are never overwritten by discover.

The inventory is kept in ~/.local/share/snap-maintainer/inventory.json (or under $XDG_DATA_HOME), so it's the same wherever you run the command.

Global options go before the command: -i FILE uses another inventory file, and --debug shows a traceback for unexpected errors. The SNAP_MAINTAINER_INVENTORY environment variable sets the inventory file too.

Exit codes are 0 for success, 1 for an error, 2 when a required tool or login is missing, and 130 when interrupted.

Output uses colours, a progress bar and clickable links in a terminal, and plain text when piped or when NO_COLOR is set.

Handing a plan to an agent

plan --markdown prints a self-contained checklist with the reasons, the target channel and architectures, and copy-paste commands:

snap-maintainer plan --markdown > rebuild-plan.md
snap-maintainer plan --markdown hello-nginx | gh issue create -R you/hello-nginx \
  --title "Rebuild for security fixes" --body-file -

Use it from an agent (MCP)

snap-maintainer mcp runs a Model Context Protocol server over stdio, so an agent such as Claude Code can discover, check and plan rebuilds directly. It needs the optional mcp package:

pip install 'snap-maintainer[mcp]'   # or, if already installed with pipx: pipx inject snap-maintainer mcp

The agent starts the server as snap-maintainer mcp, so snap-maintainer must be on the agent's PATH (pipx puts it there). If the agent can't find it, use the absolute path, e.g. ~/.local/bin/snap-maintainer, as the command.

Claude Code (--scope user makes it available in every project):

claude mcp add --scope user snap-maintainer -- snap-maintainer mcp

Codex CLI:

codex mcp add snap-maintainer -- snap-maintainer mcp

or in ~/.codex/config.toml:

[mcp_servers.snap-maintainer]
command = "snap-maintainer"
args = ["mcp"]

Gemini CLI (-s user makes it available in every project):

gemini mcp add -s user snap-maintainer snap-maintainer mcp

VS Code / Copilot:

code --add-mcp '{"name":"snap-maintainer","command":"snap-maintainer","args":["mcp"]}'

or in .vscode/mcp.json (note the servers key):

{
  "servers": {
    "snap-maintainer": { "type": "stdio", "command": "snap-maintainer", "args": ["mcp"] }
  }
}

Cursor (~/.cursor/mcp.json), Windsurf, Cline, Claude Desktop and most other clients take the common mcpServers form in their server configuration:

{
  "mcpServers": {
    "snap-maintainer": { "command": "snap-maintainer", "args": ["mcp"] }
  }
}

The server provides these tools:

Tool What it does
get_inventory Known snaps, their repos, builders and last verdicts. Read-only and fast.
discover_snaps Same as discover.
check_snaps Same as check, with progress updates.
rebuild_plan Same as plan, as Markdown or JSON. Read-only.
set_repo, set_build Same as the commands.

It also provides a maintain_snaps prompt that walks through the whole flow.

Like the command line, the server never builds, uploads or releases anything. Its instructions tell the agent to show you the plan, and to ask before running any upload, release, tag push or workflow, one snap at a time.

The server shares the command line's inventory, ~/.local/share/snap-maintainer/inventory.json. To use another one, set SNAP_MAINTAINER_INVENTORY or pass -i FILE before mcp.

If check_snaps or discover_snaps says it can't reach the keyring, the MCP client started the server without your desktop session's DBUS_SESSION_BUS_ADDRESS, so snapcraft can't read your login. Either pass that variable through in the client's server configuration, or give the server an exported login instead:

(umask 077; snapcraft export-login - > ~/.config/snap-maintainer-login)   # readable only by you

Then set SNAPCRAFT_STORE_CREDENTIALS to that file's contents in the server's environment.

How it works

Finding the repo

For each snap, the first of these that points to a repo that exists is used:

  1. A repo you set with set-repo, or typed at the prompt.
  2. The store listing's source code link.
  3. A GitHub URL among the listing's website, issues or contact links.
  4. github.com/<your GitHub login>/<snap name>. This catches private snaps, which the public store API can't see.
  5. A prompt, when running in a terminal.

On GitHub, renamed repos are followed (and noted), and the tool records the default branch, the location of snapcraft.yaml and the workflow files. Repos on other hosts are recorded but not inspected.

Detecting the builder

Builder When
github-workflow A workflow builds the snap (snapcore/action-build, or snapcraft / snapcraft pack in a step). The tool records whether it also uploads (snapcraft upload, snapcore/action-publish), what triggers it (tags, manual dispatch, releases, pushes), and any hard-coded channel.
launchpad A Launchpad snap recipe builds this snap from the repo.
local Neither of the above: build with snapcraft pack on your machine.
manual Only when you set it: you rebuild the snap some other way.

A workflow or recipe that uploads to the store is preferred over one that only builds. The candidates that weren't chosen are kept in the inventory.

Deciding what needs work

check looks at the most stable published revision of each architecture on the latest track.

Signal Verdict When
Security rebuild A Ubuntu Security Notice fixes a package the snap stages, and the fix is in the public Ubuntu archive.
Source update The repo has commits since the revision was uploaded, or snapcraft.yaml declares a different version.
Upstream update A part's git source has a newer tag than its source-tag, or new commits on the branch it tracks (GitHub only).

For security, the check is exact when the published snap contains a build manifest (snap/manifest.yaml). That manifest records the version of every staged package, so a notice counts only if the snap has an older version than the fix.

Without a manifest, the check is checked: it works out which packages the snap stages (its stage-packages plus their dependencies, minus what the base snap provides), and counts any notice issued after the revision was built.

Either way, a notice only counts if the package's files are really in the snap. The tool downloads each published revision once and lists its files, then looks up in the Ubuntu archive's Contents index which files the package ships. A package whose files aren't there, because the base or a content snap provides it or the build dropped it at prime, is reported as a note instead: rebuilding wouldn't change it. (The gpu extension removes libraries that mesa-2404 provides, for example.)

When the snap can't be downloaded, the check is inferred: as above, but without looking at the snap, so it counts notices issued after the upload and can't tell which packages the build left out.

snapcraft writes the manifest only when building with SNAPCRAFT_BUILD_INFO=1. Launchpad and snapcore/action-build set it automatically; for local builds, the plans include it in the build command.

Limitations

  • Private snaps can't be downloaded, so their security checks are always inferred.
  • A package that the archive's Contents index doesn't list, or that ships nothing but documentation, can't be looked for in the snap and is counted as present.
  • Fixes that exist only in Ubuntu Pro (ESM) are shown as notes, because a rebuild can't pick them up.
  • Non-security Ubuntu updates, and dependencies bundled by language plugins (pip, npm, cargo, go), aren't checked.
  • Repo inspection, workflow detection and branch checks only support GitHub.
  • The checked and inferred modes read the base snap's package list from /snap/<base>/current. If that base isn't installed locally, the inferred mode may include packages the base already ships.

Data and privacy

  • The inventory is written to ~/.local/share/snap-maintainer/inventory.json, the file given with -i, or SNAP_MAINTAINER_INVENTORY. Versions up to 0.1.3 wrote inventory.json to the current directory; if one is there and the new file isn't, it's still used, with a warning saying how to move it.
  • Ubuntu archive and security data is cached for 24 hours in ~/.cache/snap-maintainer (about 20 MB per Ubuntu release and architecture). The archive's Contents index, which says which files each package ships, is kept for a week (about 50 MB per release and architecture). check --refresh re-downloads all of it.
  • What each published revision contains (its file list, build time and manifest) is cached there permanently. Each public revision is downloaded once and not kept.
  • Your Snap Store and GitHub logins stay with snapcraft and gh; this tool never reads or stores them.

Development

pip install -e '.[mcp]' pytest
python3 -m pytest

Without the mcp package, the MCP server tests are skipped.

License

MIT

Metadata

Release files for snap-maintainer 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for snap-maintainer 0.2.0
File Size Uploaded Provenance Actions
snap_maintainer-0.2.0.tar.gz 58.1 kB Without provenance Details for snap_maintainer-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for snap-maintainer 0.2.0
File Interpreter ABI Platform Actions
snap_maintainer-0.2.0-py3-none-any.whl Python 3 none any Details for snap_maintainer-0.2.0-py3-none-any.whl

Total release size: 110.9 kB

Release files / snap_maintainer-0.2.0.tar.gz

Download URL snap_maintainer-0.2.0.tar.gz
Size 58.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c69ca001e462f2b621cdba05b8e821af7e54a4228e699cc0ef72bfda2f8c87c3
BLAKE2b-256 checksum
How to use checksums
d49c63e11fd43050f352a0449cf0bcb953f0a325415de0316886aae6ff5391ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / snap_maintainer-0.2.0-py3-none-any.whl

Download URL snap_maintainer-0.2.0-py3-none-any.whl
Size 52.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
892b24d62aedd1b54a74ef33bbda337af6a8d6d1a7f04fc6d6a2468c31cd95ce
BLAKE2b-256 checksum
How to use checksums
18b29339592c64ab5f7a275daf653c0b46a42e642081140fb8413fef2b9e2652
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for snap-maintainer 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page