
Secret Safe Env
io.github.irrenwill由 GitHub 账号 irrenwill 发布v0.1.2更新于 Oct 24, 2026
Write secrets into .env without the agent ever seeing the value - Windows masked dialog (繁中 UI)
概览
仅限 Windows 的本地 MCP 服务器,让助手把密钥写入项目的 .env 文件,值由用户在掩码对话框中输入,助手始终看不到。
- 可以做什么
- 写入密钥到 .env:助手只提供变量名,本地弹出 Windows 掩码对话框由用户输入值,本地 PowerShell 辅助程序将其写入文件,助手只收到 OK、CANCEL 或错误码等状态。检查键是否存在:对 .env 中某个变量名只返回 true 或 false,便于确认写入而无需读取文件。可指定目标:通过传入绝对路径选择特定的 .env 文件。
- 适用场景
- 当助手需要把 API 密钥、令牌、密码或连接字符串加入项目的 .env,而你不想把密钥粘贴进聊天、记录或日志时适用。适合希望由助手内联完成该步骤、自己只输入一次值的 Windows 用户。
- 运行要求
- 作为本地 stdio 进程运行,从 npm 安装(需要 Node.js 18 或更高版本)。仅支持 Windows 10 或 11,使用固定路径的 Windows PowerShell 5.1;在 Linux 和 macOS 上工具会以 UNSUPPORTED_PLATFORM 拒绝执行。未声明任何账户、API 密钥或环境变量。建议显式传入项目的 .env 路径。
安装
在 SourceWeft 中
- 打开 控制台中的 Secret Safe Env,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
secret-safe-env
[npm version] [MCP Registry] [License: MIT] [Platform: Windows]
A Model Context Protocol server that lets an AI agent put a secret (API key, token, password, connection string) into a project's .env file without the agent ever seeing the value.
The agent calls a tool with only the variable name. A native, masked Windows dialog opens locally; you type the value; a local PowerShell helper writes it straight to .env. The agent receives only a status token (OK / CANCEL / ERR:<CODE>) — never the secret.
繁體中文說明見 README.zh-TW.md.
Demo
▶︎ Full-quality video (with audio)
Why
When you ask an agent to "add my OpenAI key to .env", the usual paths all leak the secret: pasting it into the chat puts it in the model's context and transcripts; letting the agent write the value means the agent handled it; cat .env to "verify" exposes it again. secret-safe-env removes the secret from every one of those channels — the value travels user → masked dialog → PowerShell → .env and never enters the agent/model context.
"Can't I just edit .env myself?"
Yes — and this doesn't replace that. It removes the repetitive leave the chat → open the file → paste step so the agent handles it inline, with you only typing the value once. It also guards a different surface than .gitignore: keeping .env out of git doesn't help if the value already leaked into the chat / transcript / logs the moment you handed it over. Scope is deliberately just getting the value safely into .env — production secret management (vaults, runtime injection) is out of scope.
Platform support
This tool is Windows-only by design — the trust anchor is a native WinForms masked dialog driven by Windows PowerShell.
Install
Claude Code
For the most stable setup (no npx cache surprises), install the global bin and point at it:
Updating:
npm i -g secret-safe-env@latest. With unpinnednpx, clear the cache (npx clear-npx-cache) or pin a version (npx -y secret-safe-env@<version>) to avoid running a stale cached copy.
Other MCP clients (.mcp.json)
Reload the client so it picks up the server. If an npx-launched stdio server appears in the list but never connects on Windows, wrap the command as cmd /c npx -y secret-safe-env.
Tools
set_env_secret({ key, env_path? }) → status text
Opens the masked dialog for key; the user types the value; the helper writes key=value to .env. Returns human/agent-readable text plus an error flag — never the value. key must be UPPER_SNAKE_CASE (^[A-Z_][A-Z0-9_]*$). Values are single-line (for multi-line PEM/JSON, ask the user to edit .env manually). destructiveHint: true (it upserts a key in place).
env_key_exists({ key, env_path? }) → { exists: boolean }
Returns only whether key is present in .env — never the value. Use it to confirm a write instead of reading/cat-ing .env. readOnlyHint: true.
env_pathis the absolute path to the project.env. Always pass it explicitly — a runner-launched MCP server's working directory is the runner sandbox, not your workspace. If omitted it defaults to<CLAUDE_PROJECT_DIR or cwd>/.env.
For AI agents
Use set_env_secret whenever a task needs a secret/API key/token/password/credential in a project .env (e.g. "add my OpenAI key", "set DATABASE_URL", "configure my .env"). Rules:
- ✅ Pass only the variable name; the user supplies the value in the local dialog.
- ✅ Confirm a write with
env_key_exists(returnstrue/false, never the value). - ❌ Never ask the user to paste the secret into the chat.
- ❌ Never write the value or a placeholder yourself.
- ❌ Never
cat/read.envto verify — that re-exposes the secret.
These rules are also delivered to the agent via the server's instructions and each tool's description, so a cold agent with zero prior context can use it correctly.
Security scope
In scope — from the moment you type the value until it lands in .env, no audited Windows/agent channel records it: PSReadLine history, 4688/Sysmon process command lines, 4103 Module Logging, 4104 Script Block Logging, PowerShell Transcription, AMSI, the MCP/agent context, OTEL traces, and mcp-debug logs. The value never crosses a PowerShell parameter boundary and is written only via [System.IO.File], never a cmdlet. A static AST lint (npm run lint:ps) and Pester transcript tests enforce this.
Out of scope (your responsibility, once the value is in .env) — cloud sync / OneDrive, VSS / backup snapshots, antivirus scanning, file ACLs, and the agent reading .env afterward.
See docs/SPEC.md for the full threat model and guarantees.
Development
PowerShell tests need Pester 5: Install-Module Pester -MinimumVersion 5.0 -Scope CurrentUser.
Releases are automated: push a vX.Y.Z tag and GitHub Actions publishes to npm (Trusted Publishing / OIDC) and the MCP Registry — no tokens. See docs/DECISIONS.md.
Documentation
- docs/SPEC.md — purpose, guarantees, threat model, scope & non-goals.
- docs/ARCHITECTURE.md — modules and data flow.
- docs/DECISIONS.md — design decisions and rationale.
Contributing
Contributions welcome — see CONTRIBUTING.md. The one rule: keep the no-leak guarantee intact and tested.
License
Disclaimer
secret-safe-env is provided "as is", without warranty of any kind (see LICENSE). It reduces secret exposure within the documented security scope on a best-effort basis; it does not guarantee absolute secrecy. You are responsible for confirming it fits your threat model, and for whatever happens to a value after it is written to .env — cloud sync, backups, antivirus, file permissions, and any tool (including the agent) that later reads .env. For production secrets, prefer a dedicated secrets manager.
This is an independent open-source project. It is not affiliated with, endorsed by, or sponsored by Anthropic, "Claude", or the Model Context Protocol project; those names belong to their respective owners and are used only to describe compatibility.
来源:README.md,提交 e650830
工具
0版本历史
1- v0.1.2最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分