
OpsecForge
io.github.cyberdroid2077由 GitHub 帳號 cyberdroid2077 發布v0.1.1更新於 Oct 24, 2026
Local MCP tools that keep secrets out of agent context: redact files, scan commits, verify webhooks.
概覽
一個本機 MCP 伺服器,讓程式開發助理在不把密鑰送進模型上下文的前提下,對檔案做去識別化、掃描提交中的憑證、離線驗證 webhook 簽章並解析 JWT。
- 可以做什麼
- 讀取本機檔案並將其中的密鑰去識別化,回傳含行號的發現摘要,原始值不會進入模型上下文。掃描檔案、目錄或 git 暫存區新增的行,列出密鑰類型與遮蔽後的預覽。對助理已持有的文字產生去識別化副本,方便對外分享。離線驗證 GitHub、Stripe 或通用 HMAC 的 webhook 簽章,密鑰依環境變數名稱讀取。解析 JWT 並提示時間宣告與演算法風險。計算本機檔案的 SHA-256 或 SHA-512 校驗值並與預期值比對。
- 適用情境
- 當 AI 程式開發助理要在可能含有 .env 檔案、密鑰或憑證的儲存庫中工作時,可讓它檢查這些內容而不把密鑰帶進模型上下文。也適合提交前的密鑰檢查、排查 webhook 簽章不符,以及快速檢視 JWT 宣告。
- 執行需求
- 需要 Node.js 20 或更新版本,透過 npx 以 stdio 在本機執行。不需帳號、API 金鑰或網路存取。webhook 與 JWT 工具要求把密鑰或權杖以環境變數形式匯出到伺服器行程,並依變數名稱傳入。可選設定 OPSECFORGE_MCP_ROOTS 限制可存取的目錄。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 OpsecForge,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
opsecforge-mcp
A local MCP server (stdio) for AI coding agents such as Claude Code, Codex and Cursor. It helps keep secrets out of the model context: the agent passes a file path or an environment variable name, the work happens on your machine, and only redacted or derived results come back.
- Nothing is sent to any remote service. The server makes no network requests.
- No account, no API key, no telemetry.
- Source: github.com/cyberdroid2077/opsecforge-tools (MIT). It reuses the same tested code that powers the browser tools at opsecforge.com.
Read the limitations below before relying on this. Redaction is heuristic, the Claude Code hook is a best-effort guard rather than a sandbox, and Codex and Cursor have no hook at all.
Install
Requires Node.js 20 or newer.
Claude Code: plugin (recommended: MCP server + guard hook + skill)
The plugin adds three things:
- the MCP server (
npx -y [email protected]), exposed asmcp__plugin_opsecforge_opsecforge__*; - a
PreToolUsehook that blocksRead,GrepandBashcalls that would directly read.env,*.pem,*.key,id_rsa*,id_ed25519*,credentials,*.p12and similar files, and tells the model to useredact_fileinstead (.env.example,.env.sample,.env.templateand*.pubare allowed); - a skill that tells the agent which tool to use when.
The hook's onFailure: "block" setting needs a recent Claude Code (v2.1.295 or later according to the hooks documentation). On older versions a hook that times out may be skipped instead of blocking.
Claude Code: MCP server only
Codex
Add to ~/.codex/config.toml:
(or codex mcp add opsecforge -- npx -y opsecforge-mcp).
Cursor
Add to .cursor/mcp.json (project) or ~/.cursor/mcp.json (global):
Environment variables the tools read
verify_webhook and inspect_jwt read secrets from environment variables by name. The variable must exist in the environment of the MCP server process. Export it in the shell that starts the agent, or add an env entry to the server's configuration in your client. Do not paste the secret into chat and do not commit it.
Optional hardening: set OPSECFORGE_MCP_ROOTS to a path-delimiter-separated list of directories (for example /home/me/projects) and the file tools refuse paths outside them.
Tools
Every tool is read-only, runs locally, and returns readable errors instead of crashing the server.
redact_file({ path })
Reads a local text file and returns it with secrets replaced by [REDACTED], plus a findings summary: type, count and line numbers (of the original file). Original values are never returned, and no part of a value is shown. The response starts with a notice that the original values did not leave the machine or reach the model.
Only regular files (no directories, pipes, devices), at most 1 MiB; larger files fail with an explicit message. Binary files are refused. Detects, among others: private key blocks (including unterminated ones, which are masked from BEGIN to the end of the text), sensitive named fields (password, token, secret, *_KEY, ...), Authorization / cookie / API-key headers, URL credentials, AWS, Stripe, GitHub, GitLab, Slack, Google, OpenAI, Anthropic and SendGrid key formats, and JWT-shaped strings.
scan_secrets({ paths?, staged? })
Pre-commit check. Scans files or directories (paths) and/or only the lines added in git diff --cached (staged: true). Lists file:line, the secret type and a masked preview: the first 4 characters for values of 20 or more characters, otherwise just …. Never returns an original value. Directory scans skip .git, node_modules, build output and symlinks, read at most 2000 files of at most 1 MiB, and skip binaries.
redact_text({ text })
Redacts text the agent already has, for example before pasting logs into an issue or ticket. That text is already in the model context; this tool cannot take it back out. It only produces a safer copy to share outward. To keep a secret out of the context in the first place, use redact_file with a path.
verify_webhook({ provider, body_path, secret_env, signature, algorithm?, tolerance_seconds? })
Verifies a github (X-Hub-Signature-256), stripe (Stripe-Signature) or generic HMAC (hex or base64, sha1/sha256/sha512) signature offline.
- The secret comes only from the environment variable named by
secret_env. There is no plaintext secret parameter; any unknown parameter (for examplesecret) is rejected with an explanation, and the value is not echoed. - The body is read from
body_pathas raw bytes (up to 10 MiB). Save it exactly as received. - Returns match / no match plus diagnostics: signature header well-formed or not; Stripe timestamp age and whether it is outside the tolerance (default 300 s); whether the body looks reformatted (it tests whether the signature would match with the trailing newline removed or added, CRLF/LF changed, a BOM removed, or the JSON minified or pretty-printed); whitespace or quote characters around the secret; a Stripe API key used where a
whsec_signing secret is needed. - It never returns the secret or a computed signature.
inspect_jwt({ token_env?, token? })
Decodes a JWT and returns the header, the claims, time-claim status (exp, nbf, iat, auth_time) and risk notes: alg: none, HMAC algorithms that cannot be verified offline, a missing exp, jku/jwk/x5u headers. Decoding is not verification: the tool has no key and never checks the signature. Prefer token_env (the variable name) so the raw token does not pass through the model; a token parameter is already in the context. Claim values under secret-looking field names are masked, but the claims you get back are in the context either way.
file_checksum({ path, algorithm, expected? })
SHA-256 or SHA-512 of a local file (up to 32 MiB), optionally compared with an expected value (<hex>, sha256:<hex> and sha256sum output are accepted). A match proves only that the file equals whatever the expected value came from.
Honest limitations
-
The hook is a best-effort guard, not a sandbox. It parses the text of tool calls. It does not stop a script from reading a secret file indirectly (
python app.pythat opens.env,make,docker compose config),grep -rover a directory that contains a.env, commands that use shell variables or command output as file names (cat "$FILE",find . -name .env | xargs cat), or anything a language runtime does inside a program. Treat it as a speed bump that catches the common, accidental case. -
For stronger protection, combine it with Claude Code's own controls: run in its sandbox, and add
Readdeny rules for your secret paths insettings.json(check the permissions documentation for the exact pattern syntax), for example:Deny rules also have gaps and can produce prompts or false positives; test them.
-
Redaction is heuristic and can miss secrets. It recognises common formats and secret-looking field names. It does not know your custom token formats, secrets inside prose, base64-wrapped values, or secrets split across lines in unusual ways. Review the output before sharing it, and treat a clean result as "nothing matched", not "nothing there". It can also redact harmless values (false positives).
-
Parameters and results of every MCP tool pass through the model. That is why the tools take paths and variable names.
redact_textandinspect_jwtwithtokencannot keep what you hand them out of the context. -
Codex and Cursor have no equivalent of the Claude Code
PreToolUsehook. There the tools are advisory: they only help if the agent chooses to call them instead of reading a file directly. Use each client's own permission and sandbox settings alongside them. -
Redacted output still contains everything that was not matched (hostnames, usernames, internal URLs, personal data).
-
scan_secretsis not a replacement for a dedicated scanner with a maintained rule set in CI. -
If a secret has already reached a model context, a log or a commit, rotate it.
Learn more
Browser-local versions of these checks and the background behind them, all at opsecforge.com:
- Env file sanitizer and How to sanitize .env files before sharing
- Webhook debugger and Webhook signature validation with HMAC-SHA256
- JWT decoder and JWT vulnerabilities and safe validation
- Hash and file checksum generator and Hash generators and data integrity
- Environment variable security and secrets management
- AI agent credential security
License
MIT
來源:packages/opsecforge-mcp/README.md,提交 60bcf3f
工具
0版本歷史
1- v0.1.1最新Oct 14, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分