SuperAPIAI Directory

cyberdroid2077/opsecforge-tools

github.com · AI security

OpsecForge MCP is a local MCP server (stdio) for AI coding agents such as Claude Code, Codex, and Cursor, designed to keep secrets out of the model context. The agent only needs to pass a file path or environment variable name; processing is done locally and only redacted or derived results are returned. The server makes no network requests and requires no account, API key, or telemetry; it requires Node.js 20 or later. Main tools include: redact_file (reads a local text file and redacts secrets), scan_secrets (scans files or the staging area before committing), redact_text (redacts existing text), verify_webhook (offline verification of GitHub, Stripe, or generic HMAC signatures), inspect_jwt (decodes a JWT and provides risk hints), file_checksum (computes SHA-256/SHA-512 checksums). The Claude Code plugin also provides a PreToolUse hook that intercepts calls that directly read sensitive files such as .env, *.pem, and *.key, along with skill hints. The project is MIT-licensed and reuses the same codebase as the opsecforge.com browser tool. Note: redaction is heuristic, the hook is a best-effort safeguard rather than a sandbox, Codex and Cursor have no corresponding hook, and tool arguments and results still pass through the model context.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsLinux · API

About this tool

Purpose

OpsecForge MCP is a local MCP server (stdio) for AI coding agents such as Claude Code, Codex, and Cursor, with the goal of keeping secrets out of the model context as much as possible. The agent passes a file path or environment variable name; the actual processing is done locally, and only redacted or derived results are returned to the model. The server sends no data to any remote service, makes no network requests, requires no account or API key, and has no telemetry.

Main capabilities

  • redact_file({ path }):Reads a local text file, replaces secrets with [REDACTED], and returns a summary of findings (type, count, line numbers in the original file). Accepts only regular files, up to 1 MiB, and rejects binary files. Can recognize private key blocks, sensitive named fields, 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 that scans specified files/directories or added lines in git diff --cached, listing file:line, secret type, and a masked preview. Directory scans skip .git, node_modules, build artifacts, and symlinks, up to 2000 files at 1 MiB each, skipping binaries.
  • redact_text({ text }):Redacts text the agent already holds, for example before pasting logs. This text is already in the model context; this tool can only produce a safer copy for external sharing.
  • verify_webhook({ provider, body_path, secret_env, signature, algorithm?, tolerance_seconds? }):Offline verification of github (X-Hub-Signature-256), stripe (Stripe-Signature), or generic HMAC (hex/base64, sha1/sha256/sha512) signatures. The secret is read only from the environment variable specified by secret_env, and does not accepttakes a plaintext key parameter; the request body is read from body_path as raw bytes (max 10 MiB). Returns the match result and diagnostic information, without returning the key or the computed signature.
  • inspect_jwt({ token_env?, token? }):decodes a JWT and returns the header, claims, temporal claim status, and risk hints (alg: none, HMAC algorithms that cannot be verified offline, missing exp, jku/jwk/x5u headers, etc.). Decoding is not verification; the tool has no key and never validates signatures.
  • file_checksum({ path, algorithm, expected? }):computes the SHA-256 or SHA-512 of a local file (max 32 MiB), optionally comparing it against an expected value.

Usage

Requires Node.js 20 or later.

Claude Code recommends using the plugin, which consists of three parts: an MCP server (npx -y opsecforge-mcp@0.1, exposed as mcp__plugin_opsecforge_opsecforge__*); a PreToolUse hook that intercepts Read, Grep, and Bash calls that would directly read files such as .env, .pem, .key, id_rsa, id_ed25519, credentials, *.p12, and prompts the model to use redact_file instead (.env.example, .env.sample, .env.template, and *.pub are allowed); and a skill that tells the agent when to use which tool. The hook's onFailure: "block" requires a relatively recent Claude Code (per the hook documentation, v2.1.295 or later); on older versions, timed-out hooks may be skipped rather than blocked.

When using only the MCP server: Codex can run codex mcp add opsecforge -- npx -y opsecforge-mcp, or add it to ~/.codex/config.toml; Cursor can add it to .cursor/mcp.json (project) or ~/.cursor/mcp.json (global).

verify_webhook and inspect_jwt reads the key by name from environment variables; the variable must exist in the MCP server process's environment, either exported in the shell that starts the agent or added as an env entry in the client's server configuration. Optional hardening: set OPSECFORGE_MCP_ROOTS to a path-separator-delimited list of directories, and the file tools will reject paths outside the list. All tools are read-only and run locally, returning readable errors rather than crashing the server.

Use cases

Suitable for scenarios in AI coding agent workflows involving .env files, private keys, API keys, webhook signature verification, JWT decoding, and file checksums, especially for developers who want to avoid pasting keys into chats or committing them to repositories.

Limitations

  • The hook is a best-effort guard, not a sandbox. It parses tool call text and cannot prevent scripts from indirectly reading key files (e.g., python app.py opening .env, make, docker compose config), running grep -r on a directory containing .env, using shell variables or command output as file names, or language runtimes reading within the program.
  • Redaction is heuristic and may miss custom token formats, keys in prose, base64-wrapped values, or keys split across lines, and may also produce false positives. A clean result only means "no match," not "no key."
  • Every MCP tool's parameters and results pass through the model, so the tools are designed around paths and variable names; redact_text and inspect_jwt with a token cannot keep the supplied content out of the context.
  • Codex and Cursor have no equivalent of Claude Code's PreToolUse hook; there the tools are only advisory and need to be combined with each client's own permission and sandbox settings.
  • Redacted output still contains unmatched content (hostnames, usernames, internal URLs, personal data).
  • scan_secrets cannot replace a dedicated scanner with a continuously maintained ruleset in CI.
  • If a key has entered the model context, logs, or commits, that key should be rotated.
  • Stronger protection can combine Claude Code's own sandbox and Read deny rules in settings.json, but deny rules also have gaps and may produce prompts or false positives, so testing is needed.
Up/Down to navigate · Enter to open · ESC to closeBrowse all tools