Per-command secret injection for AI coding agents — values never enter model context
Why: anything placed in an LLM's context can be exfiltrated (prompt injection, logs, generated code). The fix is architectural: keys never enter context, only the execution environment.
uv tool install keygrant # or: pipx install keygrant Requires Python ≥ 3.10. macOS ships Python 3.9, so a bare pip install there fails; uv fetches a suitable Python automatically.
Then, in each project where agents should use secrets:
keygrant init init adds a keygrant entry to the project's .mcp.json (merging with any existing servers) and appends usage guidance for the model to CLAUDE.md, both idempotently. Restart Claude Code in that folder to load the server.
Values live in the login Keychain; approval is a native dialog.
What this does NOT protect against (known residual risks):
Every use of a secret — via the CLI or the MCP server — requires the user's approval through a native, topmost dialog (deny by default on a 60s timeout). Approving grants access to that secret for 15 minutes, bound to the requesting session (tracked in grants.json); keygrant revoke withdraws a grant early. Both channels go through the same gate, so an agent cannot bypass MCP approval by shelling out to the CLI — and a grant approved for one session cannot be reused by another. The dialog will be replaced by a resident tray app with toast notifications; the grant semantics stay the same.
The vault file also records usage metadata (use count, last used) as the seed of an audit trail.
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.




