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)

已驗證STDIO僅桌面開發者工具安全與監控

概覽

AI 產生的概覽

僅限 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 路徑。
安裝前請注意
寫入工具會就地新增或覆寫某個鍵,因此會修改 .env 檔案。值僅支援單行,多行 PEM 或 JSON 需手動編輯。保護範圍僅限從輸入到寫入的過程:雲端同步、備份、防毒軟體、檔案權限以及之後任何讀取 .env 的行為都不在其範圍內,也不保證絕對保密。正式環境密鑰建議使用專門的密鑰管理服務。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Secret Safe Env,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

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

[secret-safe-env demo — the agent calls the tool with only the key name; a masked dialog opens locally for you to type the value, which is written straight to .env]

▶︎ 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.

agent: set_env_secret({ key: "OPENAI_API_KEY" })          │  (name only — no value)          ▼   ┌──────────────────────────┐     you type the value here   │  native masked dialog     │ ◄── (never shown to the agent)   └──────────────────────────┘          │  $script:SecretValue (never a parameter, never stdout)          ▼   PowerShell writes .env via [System.IO.File]          │          ▼agent receives:  "OK"   ← status token only

"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.

RequirementSupportedNotes
Windows 10 / 11✅ RequiredThe only supported OS.
Linux / macOS❌ Not supportedThe tools return UNSUPPORTED_PLATFORM and refuse; the agent is told the machine is unsupported. (The npm package still installs on any OS, it just won't run there.)
Windows PowerShell 5.1✅ RequiredLaunched from the pinned path %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe.
PowerShell 7+ (pwsh)❌ Not usedDeliberately never PATH-resolved, so a pwsh on PATH can't change the execution/logging surface.
Node.js✅ 18+Runs the MCP server (spawns PowerShell; never touches the value).

Install

Claude Code

bash
claude mcp add secret-safe-env -- npx -y secret-safe-env

For the most stable setup (no npx cache surprises), install the global bin and point at it:

bash
npm i -g secret-safe-envclaude mcp add secret-safe-env -- secret-safe-env

Updating: npm i -g secret-safe-env@latest. With unpinned npx, 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)

jsonc
{  "mcpServers": {    "secret-safe-env": { "command": "secret-safe-env" }        // requires `npm i -g secret-safe-env`    // zero-install alternative (pin a version):    // "secret-safe-env": { "command": "npx", "args": ["-y", "secret-safe-env@<version>"] }  }}

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_path is 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 (returns true/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 .env to 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

bash
npm installnpm run build       # tsc -> dist/npm test            # Node unit tests (vitest)npm run test:ps     # PowerShell upsert + no-leak tests (Pester 5)npm run lint:ps     # static value-path AST lint

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

Contributing

Contributions welcome — see CONTRIBUTING.md. The one rule: keep the no-leak guarantee intact and tested.

License

MIT

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
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.2最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分