Skip to main content

🧨 Mecha

How much fuse is left on your API keys?

CI PyPI Python License: MIT Local-first No telemetry

Anthropic OpenAI Gemini xAI OpenRouter

Try it in your browser

Read the launch post (in Spanish)

Mecha is a local-first dashboard (web + CLI) that tells you at a glance how much life each of your AI credentials has left: whether it works, whether it has funds, when it expires and what kind of key it is. It covers Anthropic, OpenAI, Google Gemini, xAI and OpenRouter, plus the session files of Codex, Claude Code and Gemini CLI.

Mecha's dashboard in demo mode: one card per key with a traffic light, funds and the fuse to its expiry

Install

Just looking? Try the web demo: made-up data, runs entirely in your browser and sends nothing anywhere (its Content Security Policy forbids any connection). It never asks you to paste a key.

Mecha needs Python 3.12+. The easiest way is uv:

uvx mecha-keys serve --demo     # try it with fake data: no secrets, no network
uv tool install mecha-keys      # install the `mecha` command
pipx install mecha-keys         # or with pipx

The PyPI package is mecha-keys; the command is mecha (mecha-keys also works). Every release is published from GitHub Actions with Trusted Publishing and carries attestations you can verify:

gh attestation verify mecha_keys-*.whl --repo JoaquinRuiz/mecha

Principles

  • Local-first. Runs on 127.0.0.1. A key only ever leaves your machine towards its own provider's official endpoint. No telemetry, no cloud.
  • Zero cost by default. Automatic checks only use free endpoints; token-consuming probes are opt-in, with their cost shown first.
  • Honest about the unknown. "Unknown" is a valid state, and every value shows where it came from.
  • A stored secret is never shown again. The UI only sees a redacted form and a fingerprint.

Usage

mecha serve                                     # dashboard on 127.0.0.1:7878 (opens the browser)
mecha add --label "Prod Anthropic" --tag prod   # hidden prompt; or pipe: echo "$KEY" | mecha add
mecha ls                                        # table; --json for scripts
mecha detect < key.txt                          # classify offline, store nothing
mecha check                                     # free passive check of every key; --json, --strict, --force
mecha check --active ID                         # paid probe (fraction of a cent; one per hour, --force to repeat)
mecha link codex                                # link ~/.codex/auth.json (read-only, tokens never copied)
mecha import .env                               # preview detected keys (redacted), then import
mecha export backup.mecha                       # encrypted backup (its own passphrase)
mecha restore backup.mecha                      # merge it into this store; never overwrites
mecha rm 01J9ABCD --yes
mecha passphrase set                            # recovery passphrase for the store

Secrets are never accepted as command-line arguments. mecha ls and mecha check follow the Nagios convention: 0 all green, grey or local only, 1 some amber, 2 some red, 3 unknown. Any error in those commands, including a misspelt option, exits 3, never 2. With --strict, a grey result (could not check) exits 3.

Checks only use each provider's free endpoint (no tokens are spent) and only reach that provider's official hosts, with a closed list of method, host and path per kind of key. A result younger than 5 minutes is reused (shown as cached); --force checks again. mecha serve also re-checks every 6 hours. Settings live in config.toml in the data directory.

The store key lives in the system keyring. Without a keyring (headless Linux, cron), set MECHA_PASSPHRASE_FILE to a 0600 file holding the passphrase (or MECHA_PASSPHRASE). MECHA_HOME overrides the data directory.

Finding keys in plaintext

mecha scan                       # your home folder, AI tool configs and shell histories
mecha scan ~/Development --json  # only these folders
mecha scan --import 3f9a1c2b7d   # import a finding (the file is read again)
mecha scan --check               # validate found keys with their own provider (asks first)
mecha where 01JD8                # where a stored key was found; --rescan reads those files again

mecha scan looks for AI keys lying around on this machine and lists each one with its file and line, redacted: never the line itself. It runs offline (only --check sends keys, each to its own provider's free endpoint) and only when you run it. Everything is listed as information; it goes amber only where a key is a risk: shell history, notebooks, files tracked or not ignored in git, synced folders and files other people on this machine can read. Exit code: 0 nothing risky, 1 something amber, 3 an error. Keys that only look like AIza… or a bare sk-… are listed apart, as low confidence: they may belong to another service.

It reads the configs of Claude Desktop, Cursor, VS Code, Windsurf and Continue and the zsh, bash, fish and PowerShell histories, and skips dependencies, caches, virtual environments, local model stores, large and binary files, and files that only exist in the cloud (opening those would download them). On macOS, Desktop, Documents, Downloads, iCloud Drive and ~/Library/CloudStorage are only scanned with --include-protected, because the system asks for permission. Where a key Mecha keeps was also found is stored encrypted, and its card turns amber; other locations are never stored.

The dashboard does the same from the «Scan» tab of the add dialog: it scans your home folder in the background (with a Stop button), lists the findings redacted and imports the ones you pick. The detail sheet of a stored key says where it was found and can scan just those files again once you have cleaned them up. From the browser only the home folder can be scanned, never a path you type; the results stay in the server's memory for 30 minutes at most. In mecha serve --demo the scan never touches your disk: it finds the same made-up files every time.

On company laptops: a program that reads shell histories and config files looking for keys behaves like an infostealer, so security tools (EDR) may flag mecha scan. It never runs on its own.

Backups

mecha export FILE writes every credential (secrets, labels, tags, notes, budgets and probe settings; not the check history) encrypted with AES-256-GCM under a key derived from a passphrase you choose (at least 12 characters; Argon2id). The file is created with 0600 permissions and its header names the format, the key derivation function and its parameters, which are checked against upper bounds before any key is derived, so a tampered file cannot demand huge amounts of memory. The store's own key is never written, so a backup opens on any machine with its passphrase. There is no plaintext export.

mecha restore FILE merges a backup into the current store: duplicates are detected with the destination store's key and skipped, nothing is overwritten, and it says what it did with each entry. Without a terminal, both read the passphrase from MECHA_BACKUP_PASSPHRASE_FILE (a 0600 file).

What each provider tells Mecha

Provider Validates Funds Expiry Free check Active probe (opt-in)
Anthropic yes only when it fails with an admin key API key: GET /v1/models
admin key: GET /v1/organizations/api_keys
POST /v1/messages, claude-haiku-5-5: 0.0015 USD per 1,000 probes
OpenAI yes estimated, with an admin key with an admin key API key: GET /v1/models
admin key: GET /v1/organization/admin_api_keys
POST /v1/embeddings, text-embedding-3-small: 0.00002 USD per 1,000 probes
Google Gemini yes only when it fails no API key: GET /v1beta/models POST /v1beta/models/{model}:generateContent, gemini-3.5-flash-lite: 0.004 USD per 1,000 probes
xAI yes with a management key with a management key API key: GET /v1/api-key
management key: GET /auth/management-keys/validation
POST /v1/chat/completions, grok-4.20-0309-non-reasoning: 0.015 USD per 1,000 probes
OpenRouter yes yes yes API key: GET /api/v1/key not needed

Probe prices from each provider's pricing page, checked 2026-11-06. Generated from src/mecha/data/capabilities.toml by scripts/gen_capabilities.py; do not edit by hand.

Details, sources and what could not be verified: docs/providers.md.

Threat model

Mecha protects your secrets at rest: on disk, in backups (Time Machine, rsync, cloud sync of your home folder) and on a laptop that is lost or stolen while off. Secrets are encrypted with AES-256-GCM under a random key kept in the system keyring (or wrapped with your passphrase), the database is created 0600 in a 0700 directory, and SQLite's secure_delete overwrites deleted rows.

The local server also defends against other websites open in your browser and other users on the same machine: it listens only on 127.0.0.1, every API request needs the session token printed when the server starts, any other Host header is rejected (against DNS rebinding), and the page runs under a strict Content Security Policy with a nonce per response.

Mecha does not protect against code already running as your user: malware, a compromised dependency or editor extension, or any process of yours can ask the keyring for the store key (often without a prompt), read the memory of a running Mecha, read the session token from your terminal or call the local API with it. If something hostile already runs as you, it can read your keys from Mecha just as it could from your .env files or shell history. Mecha also cannot tell whether a provider's endpoint is honest about a key; it reports what the provider answers.

Secrets are never logged, never sent to the browser after they are added, never taken as command-line arguments and never sent anywhere except the official endpoint of their own provider. To report a vulnerability, see SECURITY.md.

Development

Requirements: uv, Node.js 22+ with pnpm (version pinned in web/package.json), just and, for the pre-commit hook, gitleaks.

just setup    # uv sync, pnpm install, gitleaks pre-commit hook
just dev      # FastAPI on 127.0.0.1:7878 + Vite on localhost:5173 (opens the Vite URL)
just test     # pytest + vitest
just lint     # ruff, mypy, biome, tsc, README capability table
just e2e      # Playwright against `mecha serve --demo` (needs `pnpm -C web exec playwright install chromium`)
just build    # vite build -> src/mecha/static, then uv build; checks the UI is in the wheel and sdist
just gif      # re-record docs/demo.gif from demo mode (needs ffmpeg)
just pages    # build and test the static web demo (web/dist-pages)
uv run mecha serve   # serve the built UI on http://127.0.0.1:7878

Each server start generates a random session token and opens http://127.0.0.1:7878/#t=<token>. The page keeps the token in sessionStorage (so reloads work) and sends it as Authorization: Bearer. Every /api/* request without it gets 401, and any Host other than 127.0.0.1:<port> or localhost:<port> gets 400.

The web demo on GitHub Pages is the same frontend built with vite.pages.config.ts: the modules that talk to the local server are swapped for in-memory versions with the same interface (web/src/demo), replaying answers that scripts/dump_demo.py records from mecha serve --demo. CI checks that the data is current, that the real app contains no demo code and that the demo contains no /api client. It is deployed by the release workflow, after PyPI and the GitHub release.

The README capability table is generated from src/mecha/data/capabilities.toml (uv run python scripts/gen_capabilities.py); CI fails if it is out of date.

Releases: bump version in pyproject.toml, add a CHANGELOG.md entry, merge, then push a tag vX.Y.Z. The Release workflow builds once, fails if the tag does not match the version, installs the built wheel on Linux, macOS and Windows, publishes the same files to TestPyPI and, after approval, to PyPI.

Repository layout:

src/mecha/      Python package (CLI, FastAPI server, core, providers, store)
web/            Vite + React + TypeScript + Tailwind CSS v4 + shadcn/ui (Radix)
tests/          pytest
scripts/        release checks, README table generator, demo GIF recorder
docs/           provider notes and architecture decision records (docs/adr/)

Never use real API keys in tests, fixtures or commits. See CONTRIBUTING.md to get involved.

License

MIT

Metadata

Release files for mecha-keys 0.3.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 mecha-keys 0.3.0
File Size Uploaded Provenance Actions
mecha_keys-0.3.0.tar.gz 605.0 kB With provenance Details for mecha_keys-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mecha-keys 0.3.0
File Interpreter ABI Platform Actions
mecha_keys-0.3.0-py3-none-any.whl Python 3 none any Details for mecha_keys-0.3.0-py3-none-any.whl

Total release size: 1.2 MB

Release files / mecha_keys-0.3.0.tar.gz

Download URL mecha_keys-0.3.0.tar.gz
Size 605.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b60ab4bcf739987e3ccce744d282c4fd91245936cf0e99b682c4ef1dc5535895
BLAKE2b-256 checksum
How to use checksums
310ea9773e4e7023888953b77ebc567ca329457fe066527fe35fc42df1fbdd14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / mecha_keys-0.3.0-py3-none-any.whl

Download URL mecha_keys-0.3.0-py3-none-any.whl
Size 634.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bcde6142a628120b9b716852e412129b131af8f63fd62d51ad72b25665a84bb8
BLAKE2b-256 checksum
How to use checksums
e9dc42887c923e16f89cd884a8fc3db44098114e30eb7188d9668446f089db69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Security for mecha-keys 0.3.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mecha_keys-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

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