Skip to main content
Glama

vault-mcp

A personal secrets vault for AI coding agents. Your agent uses your API keys without ever seeing them.

You:    "Add a map to the dashboard showing user locations."
Agent:  [vault_search "google maps"] -> [vault_inject_env] -> sets NEXT_PUBLIC_GOOGLE_MAPS_API_KEY in .env
Agent:  "I set NEXT_PUBLIC_GOOGLE_MAPS_API_KEY in .env and wired up the map component."

Store a key once. When the agent needs it, the agent searches the vault, reads the metadata, and writes the value straight into your .env, a config file, a command's environment or a remote server. The value goes to disk. The conversation only ever sees the variable name.

Works with Claude Code, Claude Desktop, Cursor, Windsurf, Antigravity, VS Code (Copilot) and Zed, and with any other client that speaks MCP over stdio.

License: MIT · Node 20+ · Install from GitHub (not yet published to npm)


Contents

Related MCP server: envguard

Features

  • The agent never sees values. All 29 MCP tools return metadata and status only. A test drives every tool and scans each response for known plaintexts, including base64 and URL-encoded copies.

  • The agent stops asking you for keys. It searches the vault first and injects what it finds.

  • Four injection targets. A local .env, any config file through {{vault:path}} placeholders, a command's environment with output redacted, or a remote server's env file over SSH.

  • Groups, accounts and projects. stripe/acme and stripe/personal stay apart. A project holds its own keys and links to shared ones, so one call sets up a whole .env.

  • Copy and move. Copy a key into another project, or move and rename it. Projects linked to a moved key follow it.

  • 15 service presets. Stripe, Google Maps, OpenAI, Anthropic, AWS, Cloudflare, Supabase, Database URL, Twilio, Resend, SendGrid, Firebase, GitHub, SSH server, and a generic catch-all.

  • Encrypted at rest, nothing to remember. AES-256-GCM, with the master key in the macOS Keychain, Windows Credential Manager or libsecret.

  • Access code. Locks the web dashboard and guards keys marked protected. Protected keys unlock for 15 minutes.

  • Local web dashboard.

    • Home grid of credential groups, with search and filters by scope, environment and sort order.

    • Projects in the sidebar (up to 5, plus "view all"), and a page per project showing its linked and independent keys.

    • Reveal or copy a value, add credentials from presets, copy or move keys between projects.

    • Backups, activity log, and a visible timer for the 15-minute protected unlock.

    • Brand icons for known services.

  • Backups. Local snapshots to undo mistakes, and portable passphrase-sealed backups to move machines.

  • Guard rails. Refuses to write a key into a git-tracked file. Warns when a server-only key is headed for a browser variable. Logs every read and injection, never the value.

Requirements

  • Node.js 20 or later.

  • An OS keychain: macOS Keychain, Windows Credential Manager, or libsecret on Linux. No keychain (headless server, CI, some Linux setups)? Set VAULT_MASTER_PASSWORD and the master key is derived from it instead.

  • An MCP client (see the table under Register with your client).

Quick start

1. Install

git clone https://github.com/MHasnainJafri/vault-mcp.git
cd vault-mcp
npm install
npm run build
npm link

npm link makes the vault command available everywhere. Without it, run node dist/cli.js from the repository folder wherever this README says vault.

2. Create the vault and set an access code

vault init
vault set-pin

vault init creates ~/.vault-mcp and stores a random master key in your OS keychain. vault set-pin sets a 4–12 digit access code. You type it yourself; the agent never needs it unless you hand it over for a protected key.

Prefer a guided first run? vault setup does init, your first key and client registration in one go.

3. Register with your client

vault install

With no options it lists the clients it knows and marks the ones it found on this machine. Then:

vault install --client cursor

Client

--client

Where it writes

Claude Code

claude-code

Prints claude mcp add vault -s user -- node <path> serve to run

Claude Desktop

claude-desktop

macOS ~/Library/Application Support/Claude/claude_desktop_config.json, Windows %APPDATA%\Claude\claude_desktop_config.json, Linux ~/.config/Claude/claude_desktop_config.json

Cursor

cursor

~/.cursor/mcp.json, or .cursor/mcp.json with --project

Windsurf

windsurf

~/.codeium/windsurf/mcp_config.json

Antigravity (IDE and CLI)

antigravity

~/.gemini/config/mcp_config.json, or .agents/mcp_config.json with --project

VS Code (Copilot)

vscode

.vscode/mcp.json with --project

Zed

zed

Use --print and paste the block under context_servers in ~/.config/zed/settings.json

Other options: --all (every client detected), --project (project-level config), --config <path> (a specific file), --print (show the JSON only).

The config is merged into what is already there. The original is copied to <config>.vault-backup first, so no other server or setting is touched.

Any other MCP client takes the standard block:

{
  "mcpServers": {
    "vault": { "command": "node", "args": ["/absolute/path/to/vault-mcp/dist/cli.js", "serve"] }
  }
}

VS Code calls the top-level key servers instead of mcpServers.

4. Restart your client

A newly registered server appears the next time the client starts. Its tools show up as vault_*.

5. Add your first key

vault add openai/personal/api_key --env OPENAI_API_KEY

Paste the key at the hidden prompt. Then ask your agent to use OpenAI in a project, and it will find the key and inject it.

Adding keys

Paths are group/account/field, for example stripe/acme/secret_key. Containers are created as needed.

Hidden prompt (recommended for live keys). The value is never in your shell history or a chat window.

vault add openai/personal/api_key --env OPENAI_API_KEY --tags ai --notes "server only"

Inline value. Quick, but the value lands in your shell history. Fine for test keys. The command reminds you.

vault add openai/personal/api_key sk-test-123

A whole service from a preset. Give the account path without a field and it walks every field the service needs.

vault add stripe/acme

This asks for secret_key, publishable_key and webhook_secret, with the right env var names and usage notes. Run vault presets to see all 15.

From stdin or the clipboard. Good for multi-line values such as PEM keys.

cat key.pem | vault add ssh/prod/private_key --stdin
pbpaste | vault add github/personal/token --stdin

Import a file you already have. A .env, or a JSON object of named fields.

vault import ./my-app/.env --to projects/my-app
vault import ./server.json --to vps/my-server

Each variable or field becomes its own key. Nested JSON is flattened ({"db":{"user":"root"}} becomes db/user), and arrays are kept whole. Add --overwrite to replace keys that already exist.

The web dashboard. Run vault ui and add a credential from a preset, by hand, or by pasting a file.

From inside your AI chat. Tell the agent "I need to add a key to the vault". There are three routes:

Route

What happens

Use it for

Terminal command

The agent gives you a vault add … command; you run it and type the value at the hidden prompt

Any key. The agent never sees it

vault_open_ui

Your browser opens the dashboard behind your access code; you type the key there

Production keys. The agent is not given the page's token

vault_add_secret

You paste the value in chat and the agent stores it

Test keys only. The value stays in the transcript, so rotate anything live

Useful flags on vault add: --env, --tags, --notes, --description, --environment (development | staging | production | any), --protected, --expires <iso-date>, --stdin.

Organizing keys

stripe/
  acme/        secret_key, publishable_key, webhook_secret
  personal/    secret_key
google-maps/
  default/     api_key
projects/
  my-shop/     database_url            <- the project's own key
               + linked: stripe/acme/secret_key

Link a shared key into a project instead of copying it. The optional --env renames it for that project only.

vault link projects/my-shop stripe/acme/secret_key
vault link projects/my-shop stripe/acme/secret_key --env PAYMENTS_KEY

Copy a key into a project (it keeps its name) or to a new path:

vault cp stripe/acme/secret_key projects/my-shop
vault cp openai/team/api_key projects/chatbot/llm_key --env LLM_KEY

Move or rename a key. Projects linked to it follow it to the new path.

vault mv projects/old-app/database_url projects/new-app

Both refuse to replace a key that already exists unless you pass --overwrite. Protected keys stay protected, and the CLI asks for your access code before copying or moving one.

Write a project's keys into a .env:

vault inject --project projects/my-shop --file .env

Using keys from the agent

The agent searches first (vault_search), then picks one of four targets. Each returns only variable names and a status.

1. A .env file — vault_inject_env. Keeps existing lines, comments and order. Refuses a git-tracked file.

vault_inject_env { projectPath: "projects/my-shop", envFile: ".env" }

2. Any config file — vault_render_file fills {{vault:path}} placeholders. Transforms: |base64, |json, |uri.

# docker-compose.yml
environment:
  STRIPE_KEY: "{{vault:stripe/acme/secret_key}}"
  SA_JSON: "{{vault:firebase/prod/service_account|base64}}"

3. A command's environment — vault_run. Nothing is written to disk. Every occurrence of the value, plain, base64 or URL-encoded, is stripped from the output the agent sees.

vault_run {
  command: "npx",
  args: ["wrangler", "secret", "put", "STRIPE_KEY"],
  secrets: [{ path: "stripe/acme/secret_key", varName: "STRIPE_KEY" }],
  stdinSecret: "stripe/acme/secret_key"
}

4. A remote server — vault_ssh_inject upserts keys into a remote env file over SSH and sets it to chmod 600. The SSH credentials come from the vault too: store them first with vault add ssh/<name>.

vault_ssh_inject { serverPath: "ssh/prod", remoteFile: "/srv/app/.env", projectPath: "projects/my-shop" }

Example prompts

You do not need to name tools. Ask in plain words and the agent picks them.

You say

What the agent does

"Add Stripe payments to this app."

vault_search "stripe", then vault_inject_env writes STRIPE_SECRET_KEY and NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY into .env

"Set up the .env for my-shop."

vault_project projects/my-shop, then vault_inject_env with every key the project owns or links

"Which keys is this project missing?"

vault_check_env compares .env with the vault by name and lists the gaps

"Make a .env.example I can commit."

vault_write_env_example writes names, descriptions and format hints with empty values

"Deploy the Stripe key to Cloudflare."

vault_run runs wrangler secret put with the key in its environment; the output is redacted

"Put the database URL on the prod server."

vault_ssh_inject writes it into the server's env file over SSH

"I need to add my OpenAI key."

Opens the dashboard with vault_open_ui so you type it yourself. Ask for "the terminal command" and it gives you vault add … instead

"What did you do with my keys today?"

vault_audit lists every read and injection, without values

If a key is not in the vault, the agent says so and lets you choose how to add it. For live keys it is told to prefer the dashboard, so the value never enters the chat.

Web dashboard

vault ui

It opens http://127.0.0.1:5177/?token=… in your browser.

  • Loopback only. It never listens on the network.

  • Token. A one-time token is generated at startup and required on every request.

  • Access code. If you set one, the page asks for it before showing anything. Five wrong tries lock it for ten minutes. A session lasts one hour.

What you can do there:

  • Browse every credential group, with search and filters by scope, environment and sort order.

  • Open a project to see its linked keys and its own (independent) keys.

  • Reveal or copy a value, one key at a time. Every reveal is logged.

  • Add credentials from a preset, by hand, or by importing a .env or JSON.

  • Edit metadata, copy or move a key to another project, link and unlink, delete.

  • Create and restore backups, including portable ones with a passphrase that never leaves the page.

  • Read the activity log.

  • See how long the protected tier stays unlocked, and lock it again.

A tour of the dashboard

Sidebar. Home, Backups and Activity; up to five projects (most recently used first) with a + to create one and View all for the rest; then every service you have keys for, with its logo. The badge next to the name shows how many minutes protected keys stay unlocked. Click it to lock them now, or to unlock when it says Locked.

Home. One card per credential group, for example Stripe · acme or SSH Server · prod-web. Each card shows its path, the project that uses it (or Shared for keys under shared/), how many keys it holds, the environment, a PIN mark for protected keys and when it was last used.

  • All Scope narrows to keys used by a project, standalone services, or shared keys.

  • Search matches service, path, key name, env var name, tag and description. Press ⌘K (or Ctrl+K) to jump to it.

  • Env and Sort filter by environment and order by last used, last added, name or number of keys.

  • + Add Credential opens a picker of the 15 services, plus Custom key and Import .env / JSON.

Project page. Click View keys on a card or a project in the sidebar.

  • Linked & grouped credentials: shared keys the project links to, and groups stored inside the project.

  • Independent keys: keys that belong to this project alone.

  • Each row shows a masked value (sk_live_••••9Xq). Reveal shows it, Copy puts it on your clipboard. Public values such as publishable keys are shown in full and marked Public. PEM keys and JSON files show their size and open in a viewer.

  • The ⋯ menu on a row: edit details, copy or move, use in another project, copy the env var name or path, remove from the project, delete.

  • + Add to Project: link existing keys, copy one in, add a service, add a single key, or import a .env.

Backups. Create a portable backup (downloads to your browser), take a local snapshot, restore from a file, or restore any backup listed for this machine. A Replace restore asks for confirmation first.

Activity. The latest 50 events: what happened, who did it (AI agent, terminal or dashboard), which keys, where they went, and whether it worked.

Options: --port <port> (default 5177), --no-open. If an agent started the dashboard for you, vault ui-url prints its link and vault ui-stop stops it.

Tools reference

The server registers as vault, so its tools appear as vault_*. Full parameters are in TOOLS.md.

Area

Tool

What it does

Find

vault_search

Fuzzy search by service, purpose, env var name or tag. Metadata only

Find

vault_list

Browse the tree of groups, accounts and projects

Find

vault_info

One key in full; optional heavily masked preview (sk_l…9Xq)

Find

vault_project

Everything a project needs, with the env var name for each

Find

vault_presets

The 15 service templates and their fields

Find

vault_status

Counts, and whether the access code is set or unlocked

Find

vault_audit

Recent activity: which key went where

Use

vault_inject_env

Write keys into a .env

Use

vault_render_file

Fill {{vault:…}} placeholders in any file

Use

vault_run

Run a command with keys in its environment, output redacted

Use

vault_ssh_inject

Write keys into a remote server's env file over SSH

Use

vault_check_env

Compare a .env with the vault by name; report what is missing

Use

vault_write_env_example

Generate a committable .env.example

Use

vault_gitignore_check

Check a secrets file is git-ignored; optionally fix it

Organize

vault_open_ui

Open the dashboard so you type a key in yourself

Organize

vault_add_secret

Store a value you gave in chat (it stays in the transcript)

Organize

vault_import_env

Import a .env or JSON file from disk; values never surface

Organize

vault_update_meta

Change env var name, notes, tags, environment, sensitivity or expiry

Organize

vault_create_container

Create a group, account or project

Organize

vault_link / vault_unlink

Let a project use a shared key without copying it

Organize

vault_delete

Remove a key or a container; needs confirm

Organize

vault_unlock / vault_lock

Unlock protected keys for 15 minutes, or lock again

Backups

vault_backup

Encrypted local snapshot, sealed with this machine's key

Backups

vault_list_backups

List backups from their headers, without decrypting

Backups

vault_backup_info

Inspect one backup file

Backups

vault_restore

Restore a local backup (merge or replace); safety snapshot first

Backups

vault_delete_backup

Delete a backup file

Plus one resource, vault://catalog: every key's metadata in a single JSON document.

CLI reference

Command

What it does

vault init

Create the vault and its master key

vault setup

Guided first run: init, first key, register with a client

vault add <path> [value]

Add a key (hidden prompt, or inline value) or a whole preset

vault ls [path]

List what is stored (--show-preview for masks)

vault info <path>

One key's metadata (--preview for a mask)

vault get <path>

Print a value to stdout, for piping

vault rm <path>

Delete (-r for a container, -y to skip confirmation)

vault import <file> --to <path>

Import a .env or JSON file

vault link <project> <secret>

Link a shared key into a project (--env to rename)

vault cp <from> <to>

Copy a key to another path or project (--env, --overwrite)

vault mv <from> <to>

Move or rename a key; linked projects follow (--env, --overwrite)

vault inject --project <p>

Write keys into a local .env (--secret, --file)

vault set-pin

Set the access code

vault backup

Portable backup with a passphrase; --local for a machine-sealed snapshot

vault restore <file>

Restore a backup; --replace to mirror it exactly

vault backups

List backups on this machine

vault export / vault import-bundle

Older bundle format; superseded by backup/restore

vault ui

Start the web dashboard (--port, --no-open)

vault ui-url / vault ui-stop

Link to, or stop, a dashboard an agent started

vault serve

Run the MCP server over stdio (what your client launches)

vault install

Register with an MCP client

vault status

Vault health and where things live

vault audit

Recent activity (--tail <n>)

vault presets

List the service templates

Security model

  • The vault is one AES-256-GCM encrypted file, ~/.vault-mcp/vault.enc.

  • The master key lives in your OS keychain under the service name vault-mcp. Another user account on the same machine cannot read it. Without a keychain, it is derived from VAULT_MASTER_PASSWORD.

  • Access code. 4–12 digits. It unlocks the dashboard and guards keys marked protected. Protected keys are sealed with a key derived from both the master key and the code, so they need both. The code unlocks them for 15 minutes; five wrong tries lock it for ten. The code is a second gate, not the main encryption: the keychain does the real work.

Rules the code enforces:

  1. No MCP tool result contains a secret value. A test drives all 29 tools and scans every response for known plaintexts, including base64 and URL-encoded forms.

  2. vault_run redacts injected values from command output.

  3. Writing a key into a git-tracked file, or an un-ignored file inside a repo, is refused unless you pass force. addToGitignore: true fixes it properly instead.

  4. Nothing may be written inside ~/.vault-mcp itself.

  5. Every read and injection is appended to ~/.vault-mcp/audit.log: paths and destinations, never values.

  6. The dashboard is loopback-only, needs a startup token, and asks for the access code when one is set.

  7. vault_open_ui starts the dashboard but is not given its token, so the agent cannot read the page it opened.

  8. Portable backups need a passphrase of 10+ characters, and no tool accepts a passphrase as an argument.

Backups

The whole vault in one encrypted file. Two kinds:

Sealed with

Restores on

Use it for

Local

This machine's master key

This machine only

Undoing a bad delete. Nothing to remember

Portable

A passphrase you type (10+ characters)

Any machine

A drive, cloud storage, moving to a new computer

vault backup
vault backup --local
vault backups
vault restore <file>
vault restore <file> --replace
  • merge (the default) keeps what is in the vault and adds what is missing. --replace makes the vault match the backup exactly.

  • A restore always takes a safety snapshot first, so even --replace can be undone.

  • The dashboard's Backups page creates a portable backup and hands it to your browser's downloads. The passphrase is typed in the page and never leaves it.

  • The agent can take local snapshots (vault_backup) and does so before destructive steps. It cannot make or restore a portable backup, because that needs a passphrase.

  • A backup is one file, not a zip: it reveals a date and a count, not your key names. It carries a checksum, so a damaged copy is refused rather than half-restored.

  • Lose the passphrase and the portable backup is gone. There is no recovery.

Configuration and file locations

Environment variable

Effect

VAULT_MCP_DIR

Use a different vault directory (default ~/.vault-mcp)

VAULT_MASTER_PASSWORD

Derive the master key from this instead of the OS keychain

What

Where

MCP server name

vault (tools appear as vault_*)

CLI command

vault after npm link, otherwise node dist/cli.js

Vault directory

~/.vault-mcp

Encrypted keys

~/.vault-mcp/vault.enc

Backups

~/.vault-mcp/backups/*.vaultbak

Activity log

~/.vault-mcp/audit.log

Master key

OS keychain, service vault-mcp

Dashboard

http://127.0.0.1:5177, loopback only

Troubleshooting

The client does not show the vault_* tools. Restart the client completely. Check that the config file from the client table contains a vault entry pointing at an existing dist/cli.js (run npm run build if dist/ is missing). Some Cursor builds ignore the global file; use vault install --client cursor --project.

"Vault is not initialized. Run vault init first." Run vault init. If you set VAULT_MCP_DIR, make sure the client launches the server with the same value.

"No OS keychain available and VAULT_MASTER_PASSWORD is not set." Common on headless Linux and CI. Set VAULT_MASTER_PASSWORD in the environment of both your shell and your MCP client, and keep it the same, or the vault cannot be opened.

A protected key is refused as locked. Give the agent your access code so it can call vault_unlock; it stays unlocked for 15 minutes. If no code is set yet, run vault set-pin first.

Lost the dashboard link an agent opened. Run vault ui-url. Run vault ui-stop to stop it.

Port 5177 is already in use. Start the dashboard on another port: vault ui --port 5178.

"Too many wrong codes." Five wrong access codes lock the dashboard for ten minutes. Wait it out.

zsh: command not found: vault. The command is only installed after npm link in the repository folder. Run it, then open a new terminal tab (or run rehash in zsh). Until then, use node dist/cli.js from the repository folder.

The dashboard looks out of date after a pull. Run npm run build, stop the dashboard (Ctrl+C or vault ui-stop) and start it again.

Updating and uninstalling

Update to the latest version. Your keys, backups and settings in ~/.vault-mcp are not touched.

git pull
npm install
npm run build

Then restart your MCP client so it loads the new server.

Uninstall. Remove the global command:

npm unlink -g vault-mcp

Remove the vault entry from your client's config file (see the client table). A copy of the original was saved as <config>.vault-backup when you ran vault install.

To delete your keys as well, first make a portable backup if you might want them again (vault backup), then delete ~/.vault-mcp and the vault-mcp entry in your OS keychain (Keychain Access on macOS, Credential Manager on Windows). This cannot be undone.

Development

npm run build
npm test
npm run typecheck

npm run build bundles with tsup into dist/. npm test runs the vitest suite (111 tests).

src/core/    crypto, keychain, store, envfile, importer, template, presets, git guards, audit, backup
src/mcp/     server and tools (read, inject, run, manage, ssh, backup, open-ui)
src/cli/     commander CLI and client registration
src/ui/      loopback web dashboard, its server, and brand icon data (public/icons.json)
test/        core, vault, backup, copy/move, dashboard masking, git guard, client config, and the no-leak suite

Measured on a laptop, search stays around 10 ms and reading one key under 50 ms up to 2,000 keys. The whole vault is held in memory while the server runs: it is built for one person's keys, not a company-wide store.

Contributing

Issues and pull requests are welcome at https://github.com/MHasnainJafri/vault-mcp.

  • Run npm test and npm run typecheck before opening a pull request.

  • Add a service preset: add an entry to src/core/presets.ts with its fields, env var names, usage notes, format hints and which fields are public or protected. The CLI, the agent tools and the dashboard pick it up.

  • Add a brand icon: add the service to the SERVICES list in src/ui/public/index.html. If Simple Icons has its logo, add the slug's colour and path to src/ui/public/icons.json; otherwise give it a letter tile.

  • Never let a tool result carry a secret value. The no-leak test in test/no-leak.test.ts must stay green.

Known limits

  • vault get prints a value by design. Do not run it on a shared screen.

  • The dashboard can reveal values. It is local-only, token-gated and code-gated, but it is a deliberate exception to "never show a value": for you, not for the agent.

  • The audit log is append-only but not tamper-proof. Anything that can read the vault file can rewrite it.

  • "The agent never sees a value" covers the MCP tool surface. It keeps keys out of your transcript; it is not a sandbox against an agent that also has shell access to your machine.

License

MIT © 2026 M. Hasnain Jafri.

Brand icons in the dashboard come from Simple Icons 16.35.0 (CC0 1.0). Each logo is a trademark of its owner and is used only to identify that service. Brands that ask not to be redistributed (OpenAI, AWS, Twilio, SendGrid, Heroku, Slack) are shown as plain lettered tiles instead.

Issues and source: https://github.com/MHasnainJafri/vault-mcp.

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      C
      quality
      C
      maintenance
      Enables AI agents to securely store and manage encrypted secrets locally while using them indirectly through environment-variable injection or file writes, so plaintext values never enter the agent's context.
      8
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to scan and audit environment files for leaked secrets, sanitize them, encrypt/decrypt vaults, and run processes with zero-disk secret injection.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI coding agents to manage and use API keys and secrets without ever seeing their values, by checking availability, listing names, requesting missing values, and running commands with injected secrets and redacted output.
      50 npm
      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