
Keystash
io.github.thu-lawyerv0.3.3更新於 Oct 7, 2026
Local encrypted vault that lets an AI agent use your secrets without exposing them to the model.
概覽
Keystash 是本地加密保險庫的 MCP 伺服器,讓 AI 助理在不看見密鑰值的情況下列出、注入、複製與產生密鑰。
- 功能
- 以 stdio 方式在本機執行,底層是一個加密保險庫檔案。工具包含 list_entries 與 status(只回傳名稱、標籤、到期時間、環境變數名稱)、run_command(把密鑰注入指令並從輸出中遮蔽)、copy_secret(把值送到剪貼簿)、generate_and_store、add_secret、update_entry 與 delete_entry。除了刻意保留的 add_secret 之外,助理不會取得密鑰值。
- 適用情境
- 適合讓 AI 助理執行需要 API key、token 或密碼的指令與工作流程,同時避免這些值進入對話與模型上下文。也適合把散落在 .env 檔案與 shell 歷史中的密鑰集中到一個加密檔案。
- 執行需求
- macOS 桌面上的本機程序,從 PyPI 安裝(keystash),以 uvx 或 keystash 命令列執行。需要一個保險庫檔案,透過 KEYSTASH_VAULT 環境變數或 --vault 指定。解鎖使用主密碼,可用 keystash unlock 存入 Touch ID;指令稿與 CI 可用 KEYSTASH_PASSWORD 提供。不需要網路或帳號。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Keystash,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
keystash 🔑
English | 中文
Give an AI agent access to your secrets — without ever showing it a secret.
keystashruns as an MCP server: the agent can inject keys into commands, hand one to your clipboard, or generate a new one, and never sees a value. Touch ID fires only when a secret is actually read — never at session startup.
Local-first encrypted vault for API keys, tokens and passwords — one file you own, fuzzy search, env injection, expiry tracking, Touch ID unlock, a plaintext-leak hunter, and a zero-plaintext MCP server for AI agents.
Your LLM API keys, cloud tokens and passwords are scattered across .env files, shell
histories and notes apps. keystash puts them in one encrypted file that you own:
no server, no account, no subscription. Sync that file with iCloud / Dropbox / SeaDrive /
Syncthing — it's ciphertext, so syncing it is safe.
English
Why keystash
Quick start
Touch ID unlock
Typing the master password for every command is exactly the friction that pushes people back to plaintext notes. Unlock once and macOS gates it instead:
Every read shows the system authentication prompt (Touch ID → Apple Watch → device
passcode fallback). --no-keychain or KEYSTASH_PASSWORD bypass it for scripts and CI.
On machines without biometry the keychain still removes the typed password.
keystash doctor — clean up the mess you already have
Browser password managers only guard the keys you remember to move. doctor
actively hunts the ones littering your machine:
Knows OpenAI / Anthropic / GitHub / AWS / Google / Slack / Stripe / Hugging Face /
SendGrid token shapes, PEM private keys, JWTs, plus an entropy-checked
API_KEY=... sweep. Secrets already in the vault are reported as stored; --shred
replaces each value with a [redacted→keystash:<name>] placeholder so file structure
and comments survive.
AI agents, zero plaintext: keystash mcp
Run keystash as an MCP server so AI agents (Claude Desktop, ZCode, Cursor, …) can orchestrate secrets without ever seeing their values:
What the agent gets — and what it can never get:
Run keystash unlock once beforehand and the server picks the password up from the
keychain — the Touch ID prompt appears lazily, on the first tool call that actually
needs the vault (never at session startup), and at most once per session. A locked
server answers every call with a helpful hint instead of prompting on stdio.
Remaining risk, stated honestly: an agent deliberately writing code that
exfiltrates (encode, split, transform) cannot be stopped — that is visible in
its transcript and auditable by you. The server removes the accidental
exposure path entirely.
Commands
Multi-machine sync
The vault is a single encrypted file. Point KEYSTASH_VAULT at any synced folder:
Each write re-encrypts with a fresh random salt, so last-writer-wins applies — prefer one writer per vault at a time, like any sync file.
Security model
- Cipher: Fernet (AES-128-CBC + HMAC-SHA256, encrypt-then-MAC) via
cryptography. - Key derivation: PBKDF2-HMAC-SHA256, 600 000 iterations, per-save 128-bit random salt.
- File mode:
0600; nothing is ever written to disk in plaintext. - Clipboard: copied secrets are auto-cleared after 30 s (best effort, detached process).
- No network. No telemetry. The CLI is fully offline.
- Secrets live in process memory only while a command runs; Python cannot guarantee zeroization after exit — the same is true of any CLI in a GC'd language.
Environment variables
Development
中文
让 AI 助手用上你的密钥,却不让它看见密钥。
keystash可以跑成 MCP 服务器:AI 能把密钥注入命令、复制进你的剪贴板、或生成新密钥, 全程看不到任何密钥值。Touch ID 只在真正读取密钥时弹出,会话启动时绝不弹。
为什么是 keystash
LLM 的 API key、云服务 token、各类密码散落在 .env、shell 历史和备忘录里。
keystash 把它们收进一个你完全拥有的加密文件:不需要服务器、不需要注册账号、
没有订阅费。文件是密文,直接丢进 iCloud / 坚果云 / SeaDrive / Syncthing 同步即安全。
快速上手
Touch ID 解锁
每条命令都输一遍主密码,正是把人推回明文备忘录的摩擦来源。解锁一次,之后交给 macOS:
每次读取都会弹系统认证(Touch ID → Apple Watch → 锁屏密码回退)。
--no-keychain 或 KEYSTASH_PASSWORD 供脚本/CI 绕过。没有生物识别的机器上,
钥匙串仍能省掉重复输密码。
keystash doctor —— 主动清剿你已经撒出去的明文
浏览器密码箱只能保护你"记得搬进去"的密钥;doctor 会主动搜捕散落在机器上的:
内置 OpenAI / Anthropic / GitHub / AWS / Google / Slack / Stripe / Hugging Face /
SendGrid 令牌格式、PEM 私钥、JWT 的识别规则,外加带熵值校验的 API_KEY=... 通扫。
已在库中的密钥会标记为已存储;--shred 把原值替换为 [redacted→keystash:<名字>]
占位符,文件结构和注释原样保留。
AI 助手零明文管理:keystash mcp
把 keystash 跑成 MCP 服务器,让 AI 助手 (Claude Desktop、ZCode、Cursor 等)编排密钥,但永远看不到密钥的值:
先 keystash unlock 一次,服务器会从钥匙串取密码——Touch ID 只在第一次真正
用到密钥库的工具调用时弹出(会话启动时绝不弹),每个会话最多弹一次。未解锁时
每个工具调用都会返回解锁指引而不是卡死。诚实地说明边界:AI 蓄意写变形编码的代码外传无法拦截
——但那会完整留痕在它的执行记录里,可审计。本服务器消灭的是意外暴露路径。
命令一览
多机同步
保险库就是单个加密文件,指到任意同步盘即可:
每次写入都会用全新随机盐重新加密,因此并发写遵循"最后写入者获胜"—— 和所有同步文件一样,同一时刻尽量只让一台机器写。
安全模型
- 加密:Fernet(AES-128-CBC + HMAC-SHA256,先加密后 MAC),基于
cryptography。 - 密钥派生:PBKDF2-HMAC-SHA256,60 万轮迭代,每次保存生成 128 位随机盐。
- 文件权限:
0600;任何明文都不会落盘。 - 剪贴板:复制的密钥 30 秒后自动清除(尽力而为,独立进程)。
- 无网络、无遥测,CLI 完全离线。
- 密钥仅在命令执行期间存在于进程内存;Python 无法保证进程退出后的内存清零 ——任何 GC 语言写的 CLI 都一样。
环境变量
参与开发
License
來源:README.md,提交 316ca0f
工具
0版本歷史
1- v0.3.3最新Oct 7, 2026


