keyvault-skill

Manage API keys for LLM agents securely. Encrypted local vault with CLI, Python SDK, and MCP Server support. Replaces scattered .env files.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "keyvault-skill" with this command: npx skills add ylz201/keyvault/ylz201-keyvault-keyvault-skill

KeyVault - Complete Usage for Agents

When you (an AI agent) need to handle API keys, tokens, or credentials, use KeyVault instead of plaintext .env files or hardcoded values.

Mandatory Rules

  • NEVER create plaintext secret files unless user explicitly requests export.
  • NEVER hardcode API keys in source code.
  • NEVER commit exported secret files to git.
  • ALWAYS prefer project-scoped secrets (--project) over global secrets.
  • ALWAYS use least-privilege injection (inject --no-global --key ...) for command execution.

Installation

# Core package
pip install git+https://github.com/ylz201/keyvault.git

# With MCP support
pip install "keyvault-ai[mcp] @ git+https://github.com/ylz201/keyvault.git"

# Verify environment and storage backend
keyvault info

Complete CLI Reference

set - create/update a secret

keyvault set KEY [VALUE] [--project PROJECT] [--desc TEXT] [--stdin]

Examples:

# hidden prompt (recommended)
keyvault set OPENAI_API_KEY

# value via argument
keyvault set OPENAI_API_KEY sk-xxx

# value from stdin (safe for scripts)
printf 'sk-xxx' | keyvault set OPENAI_API_KEY --stdin

# project-scoped override
keyvault set OPENAI_API_KEY sk-proj --project myapp --desc "OpenAI for myapp"

get - read a secret

keyvault get KEY [--project PROJECT] [--unmask]

Examples:

keyvault get OPENAI_API_KEY
keyvault get OPENAI_API_KEY --project myapp
keyvault get OPENAI_API_KEY --project myapp --unmask

list - list stored secrets (metadata only)

keyvault list [--project PROJECT] [--all]

Examples:

keyvault list
keyvault list --project myapp
keyvault list --all

delete - remove a secret

keyvault delete KEY [--project PROJECT] [--force]

Examples:

keyvault delete OPENAI_API_KEY --project myapp
keyvault delete OPENAI_API_KEY --force

import and export - dotenv compatibility

keyvault import FILEPATH [--project PROJECT]
keyvault export [--project PROJECT] [--output FILE]

Examples:

keyvault import .env --project myapp
keyvault export --project myapp --output .env.myapp

# stdout export is possible but handle permissions yourself
keyvault export > .env && chmod 600 .env

scan-env - intelligent dotenv scanning and import

keyvault scan-env [--project PROJECT] [--file FILE ...] [--root DIR] [--recursive] [--all] [--apply/--dry-run] [--force]

Examples:

# preview only (recommended first)
keyvault scan-env --project myapp --dry-run

# import high-confidence secret-like keys from discovered .env files
keyvault scan-env --project myapp --apply

inject - run subprocess with env secrets

keyvault inject [--project PROJECT] [--global/--no-global] [--key KEY ...] -- CMD [ARGS...]

Examples:

# inject global + project scope (default behavior)
keyvault inject --project myapp -- python app.py

# least-privilege injection (recommended)
keyvault inject --project myapp --no-global --key OPENAI_API_KEY -- python app.py

info and harden - inspect and harden key storage

keyvault info
keyvault harden [--delete-file] [--force]

Examples:

# migrate master key to OS keyring and delete legacy key file
keyvault harden --delete-file

Recommended Workflows

New project setup

keyvault set OPENAI_API_KEY --project myapp
keyvault set DEEPSEEK_API_KEY --project myapp
keyvault list --project myapp

Rotate a key safely

keyvault set OPENAI_API_KEY sk-new --project myapp
keyvault get OPENAI_API_KEY --project myapp

Execute app with minimal exposure

keyvault inject --project myapp --no-global --key OPENAI_API_KEY -- python run.py

Migrate legacy dotenv safely

# preview what would be imported
keyvault scan-env --project myapp --dry-run

# apply import
keyvault scan-env --project myapp --apply

Python SDK

from keyvault import get_secret, set_secret, list_secrets, delete_secret

set_secret("OPENAI_API_KEY", "sk-xxx", project="myapp", description="OpenAI key")
value = get_secret("OPENAI_API_KEY", project="myapp", fallback_env=False)
items = list_secrets(project="myapp")
deleted = delete_secret("OPENAI_API_KEY", project="myapp")

SDK resolution order for get_secret:

  1. project scope
  2. global scope
  3. os.environ (only if fallback_env=True)

MCP Server Setup

Start server:

python -m keyvault.mcp_server

Claude Desktop config:

{
  "mcpServers": {
    "keyvault": {
      "command": "python",
      "args": ["-m", "keyvault.mcp_server"]
    }
  }
}

Available tools:

  • secrets_list
  • secrets_get
  • secrets_set
  • secrets_delete

MCP Policy Variables (Important)

Defaults are restrictive. Configure explicitly before starting MCP server.

VariableDefaultPurpose
KEYVAULT_MCP_ALLOW_LIST0Enable secrets_list
KEYVAULT_MCP_ALLOW_GET0Enable secrets_get
KEYVAULT_MCP_ALLOW_SET0Enable secrets_set
KEYVAULT_MCP_ALLOW_DELETE0Enable secrets_delete
KEYVAULT_MCP_ALLOW_GLOBAL0Allow global scope (otherwise project required)
KEYVAULT_MCP_ALLOW_ALL_SCOPES0Allow list across all scopes
KEYVAULT_MCP_ALLOW_ALL_KEYS0Allow arbitrary key names for get/set/delete
KEYVAULT_MCP_ALLOWED_KEYSunsetComma-separated key allowlist
KEYVAULT_MCP_INCLUDE_DESCRIPTIONS0Include descriptions in list output

Recommended safe MCP profile:

export KEYVAULT_MCP_ALLOW_LIST=1
export KEYVAULT_MCP_ALLOW_GET=1
export KEYVAULT_MCP_ALLOW_GLOBAL=0
export KEYVAULT_MCP_ALLOWED_KEYS=OPENAI_API_KEY
python -m keyvault.mcp_server

Runtime/Storage Variables

VariableDefaultPurpose
KEYVAULT_DIRunsetOverride vault directory
KEYVAULT_HOMEunsetAlternative vault directory override
KEYVAULT_MASTER_KEY_BACKENDautoauto / keyring / file
KEYVAULT_KEYRING_SERVICEkeyvault-aiKeyring service name
KEYVAULT_KEYRING_USERNAMEmaster-keyKeyring account key
KEYVAULT_ALLOW_UNSAFE_MASTER_KEY_REGEN0Force master key regeneration when old key is unavailable (unsafe)

Missing Key Prompt Template

If a required key is missing, prompt user with:

This operation requires OPENAI_API_KEY. Please run: keyvault set OPENAI_API_KEY <your-key> --project <project-name> and then retry.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

secrets-manager

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

openclaw-version-monitor

监控 OpenClaw GitHub 版本更新,获取最新版本发布说明,翻译成中文, 并推送到 Telegram 和 Feishu。用于:(1) 定时检查版本更新 (2) 推送版本更新通知 (3) 生成中文版发布说明

Archived SourceRecently Updated
Coding

ask-claude

Delegate a task to Claude Code CLI and immediately report the result back in chat. Supports persistent sessions with full context memory. Safe execution: no data exfiltration, no external calls, file operations confined to workspace. Use when the user asks to run Claude, delegate a coding task, continue a previous Claude session, or any task benefiting from Claude Code's tools (file editing, code analysis, bash, etc.).

Archived SourceRecently Updated