Mecha
How much fuse is left on your API keys?
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.
Status: alpha. See SPEC.md (in Spanish) for the full design.
Install
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.
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/modelsadmin 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/modelsadmin 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-keymanagement 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)
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 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.
License
Metadata
Release files for mecha-keys 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mecha_keys-0.1.0.tar.gz | 571.8 kB | With provenance | Details for mecha_keys-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mecha_keys-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for mecha_keys-0.1.0-py3-none-any.whl |
Total release size: 1.2 MB
Release files / mecha_keys-0.1.0.tar.gz
| Download URL | mecha_keys-0.1.0.tar.gz |
|---|---|
| Size | 571.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9b107bb01e6fbc7da1382d8020998b9742db5feea898ef3986f5c11ad5be1f8c
|
|
BLAKE2b-256 checksum How to use checksums |
75e8bb76c6d58c2b4a5d9d3fd83ecbc466434ca01a969280a59e6bff7e21c99a
|
| 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 9, 2026.
Transparency logRelease files / mecha_keys-0.1.0-py3-none-any.whl
| Download URL | mecha_keys-0.1.0-py3-none-any.whl |
|---|---|
| Size | 598.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
44ceca6d7185561a3ed70d332c04b13aefea0733e66fc3b9dbd6330adbbbb8d0
|
|
BLAKE2b-256 checksum How to use checksums |
2d70011e830a3a3b1007a0ec067a4efc49a52d003ed727c2f0b3d6c83c5d17b8
|
| 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 9, 2026.
Transparency logSecurity for mecha-keys 0.1.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.
Attestation for mecha_keys-0.1.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 9, 2026.
Transparency logA 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.