Secret Scanner

io.github.GuardBee由 GitHub 帳號 GuardBee 發布v1.1.1更新於 Nov 3, 2026

Scans files for leaked secrets and API keys

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

概覽

AI 產生的概覽

本機 MCP 伺服器,可掃描文字、檔案、目錄、Git 歷史與編碼代理工作階段紀錄,找出外洩的密鑰與 API Key。

可以做什麼
  • 掃描文字字串或程式碼片段中是否外洩密鑰與 API Key
  • 掃描單一檔案,或遞迴掃描目錄,並自動略過 node_modules、.git、dist 與二進位檔
  • 掃描 Git 儲存庫的暫存變更或每次提交新增的行,找出已從檔案刪除但仍留在歷史中的密鑰
  • 掃描本機編碼代理(Claude Code、Codex、Gemini CLI、Continue)的工作階段紀錄,找出貼進對話或被指令印出的密鑰
  • 列出掃描器可偵測的所有密鑰規則
適用情境
適合在提交或分享前請助理檢查專案、設定檔或程式碼片段是否外洩憑證,也適合稽核 Git 歷史與代理工作階段紀錄,找出已經外洩、需要輪替的密鑰。
執行需求
以本機 stdio 程序執行,從 npm 套件 @guardbee/mcp-secret-scanner 安裝(需要 Node.js,通常透過 npx 啟動)。未宣告任何帳號、API Key 或標頭。它會讀取本機的檔案、目錄、Git 儲存庫與代理工作階段紀錄資料夾。
安裝前請注意
掃描結果只對符合的值做部分遮蔽(保留前 4 碼與後 4 碼),仍會露出真實密鑰的片段。線上驗證密鑰是否有效僅在 CLI 提供,MCP 工具不會執行。選用遙測預設關閉;設定 GUARDBEE_TELEMETRY=1 後,會把伺服器、工具、成功狀態、耗時與檔案路徑等短參數值傳送給第三方。掃描代理工作階段紀錄會顯示已傳送給模型供應商的密鑰,應儘快輪替。

安裝

在 SourceWeft 中

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

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

@guardbee/mcp-secret-scanner

🇬🇧 English | 🇹🇷 Türkçe | 🇨🇳 中文 | 🇯🇵 日本語 | 🇰🇷 한국어 | 🇧🇷 Português | 🇪🇸 Español | 🇩🇪 Deutsch

[npm version] [npm downloads] [License: MIT]

An MCP server that scans your source files, directories, and environment configs for exposed API keys, passwords, tokens, and other secrets. Ask Claude directly whether your project is leaking secrets.

Telemetry is off by default. With GUARDBEE_TELEMETRY=1 it sends the server, tool, success, duration and short parameter values such as a file path; longer strings and fields like content, token or password are replaced with a placeholder. See @guardbee/mcp-telemetry.


Features

  • 76 Secret Patterns — AWS, Azure, GCP, GitHub, GitLab, Stripe, OpenAI, Anthropic, OpenRouter, Groq, Hugging Face, Slack, Twilio, SendGrid, DigitalOcean, Cloudflare, Supabase, Vault, PyPI, Shopify, Linear, Notion, Atlassian and more — plus the Turkish providers iyzico, PayTR, Netgsm and İleti Merkezi, matched on their variable names since their keys have no prefix. The rules live in @guardbee/guard-core, so @guardbee/mcp-security-proxy masks the same formats in tool results at runtime
  • File & Directory Scanning — a single file or an entire project tree
  • Git History & Staged Scanning — --history scans every line any commit added, so a key deleted from the files but still in the repository is found, reported once at the commit that added it (with author and date); --staged scans only what you are about to commit
  • Baseline — --write-baseline records today's findings as hashes (never the secrets, safe to commit); --baseline then reports only new ones, so an existing repo can adopt the scanner in CI without fixing everything first. SARIF results carry a stable partialFingerprints value
  • High-Entropy Values — a random-looking value assigned to a secret-like name (WEBHOOK_SIGNING_SECRET=… in .env, client_secret: in YAML, "internalApiKey" in JSON) is reported even when no provider rule knows its format. Randomness is measured as Shannon entropy (hex values need 32+ characters; values without digits need more bits, so a camel-case passphrase does not count); public/publishable, *_hash, *_id and *_url names, placeholders and ${VAR} references are left alone, and a value a provider rule already reported is not reported twice. Medium severity, low in test files; --no-entropy (or entropy: false in the MCP tools) turns it off
  • Agent Transcripts — scan --agent-history (MCP: scan_agent_history) scans what coding agents keep on your machine: Claude Code (~/.claude/projects, ~/.claude.json), Codex (~/.codex), Gemini CLI (~/.gemini/tmp) and Continue (~/.continue/sessions). A key pasted into a chat or printed by a command the agent ran stays there — and was already sent to the model provider, so rotate it. Each secret is reported once per agent with how often it appears; the entropy check is off here unless --entropy, since transcripts are full of code the agent read
  • Large Line Files — .jsonl, .ndjson, .ipynb and .log files over 1 MB (transcripts, notebooks with outputs, logs) are read line by line instead of being skipped
  • Live Verification (CLI only) — --verify asks each provider whether a found key still works, through a read-only identity endpoint (GitHub /user, OpenAI /models, Slack auth.test, …): GitHub, GitLab, OpenAI, Anthropic, Slack, Stripe, Hugging Face, npm, SendGrid, Groq, OpenRouter and DigitalOcean. Each key goes only to its own provider, once, and never appears in the output; findings are marked live / invalid / unknown and live ones are listed first. --fail-on=live fails CI only for keys that still work. The MCP tools never verify, so an agent cannot send your secrets anywhere on its own
  • Smart Skipping — directories like node_modules, .git, dist, build, .next are skipped automatically
  • Safe Redaction — matches are shown as first 4 + stars + last 4 characters
  • Allowlist Support — allowlist known test/fake values
  • 71 Unit Tests — 100% passing test suite

Quick Start

bash
npm install -g @guardbee/mcp-secret-scanner

Add to claude_desktop_config.json:

json
{  "mcpServers": {    "guardbee-secret-scanner": {      "command": "npx",      "args": ["-y", "@guardbee/mcp-secret-scanner"]    }  }}

MCP Tools

ToolDescription
scan_textScans the given text for secrets
scan_fileScans a single file
scan_directoryRecursively scans a directory and its subdirectories
scan_gitScans a git repository's staged changes or every commit's added lines (history)
scan_agent_historyScans coding agents' transcripts on this machine (Claude Code, Codex, Gemini CLI, Continue)
list_patternsLists all active secret patterns

Example Usage

You can ask Claude:

"Scan my project for secrets: /Users/me/my-app"

"Are there any secrets in this .env file?"

"Is this text safe: export API_KEY=sk-abc123..."


Detected Secret Types

CategoryExamples
CloudAWS Access Key, AWS Secret, GCP API Key
Source ControlGitHub PAT, GitLab Token
PaymentsStripe Secret/Publishable Key
AIOpenAI API Key, Anthropic API Key, HuggingFace Token
CommunicationSlack Bot Token, Twilio Auth Token, SendGrid Key
DatabasePostgreSQL URL, MySQL URL, MongoDB URI, Redis URL
CryptographyRSA Private Key, EC Private Key, OpenSSH Key, PGP Key
WebJWT Token, Bearer Token
Package/Platformnpm Token, Docker Hub Token, Vercel Token
GenericSECRET=, PASSWORD=, API_KEY= patterns

Security Note

This tool partially redacts matched values in scan results (e.g. sk_live_abc1...xyz9). Full values are never logged or exported.


CLI — CI/CD Integration

In addition to MCP server mode, this can also be used directly as a CLI:

bash
# Scan a project directorynpx @guardbee/mcp-secret-scanner scan ./my-project
# Scan a single filenpx @guardbee/mcp-secret-scanner scan .env
# Fail only on critical/highnpx @guardbee/mcp-secret-scanner scan . --fail-on=high
# JSON output (for CI reporting)npx @guardbee/mcp-secret-scanner scan . --format=json# Secrets pasted into Claude Code / Codex / Gemini CLI / Continue sessions on this machinenpx @guardbee/mcp-secret-scanner scan --agent-history# Which of the found keys still work? (sends each key to its own provider)npx @guardbee/mcp-secret-scanner scan . --history --verify --fail-on=live# Pre-commit: only the lines you are about to commitnpx @guardbee/mcp-secret-scanner scan --staged
# Every commit on every branch (finds keys deleted from the files)npx @guardbee/mcp-secret-scanner scan . --historynpx @guardbee/mcp-secret-scanner scan . --history=main..HEAD   # just this branch
# Adopt an existing repo: record known findings once, then fail only on new onesnpx @guardbee/mcp-secret-scanner scan . --history --write-baseline=.guardbee-secrets-baseline.jsonnpx @guardbee/mcp-secret-scanner scan . --history --baseline=.guardbee-secrets-baseline.json

Exit codes: 0 = no secrets found · 1 = secrets found · 2 = error

GitHub Actions

yaml
name: Secret Scanon: [push, pull_request]
jobs:  secret-scan:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@v4        with:          fetch-depth: 0   # full history for --history      - name: Scan for exposed secrets        run: npx @guardbee/mcp-secret-scanner scan . --history --baseline=.guardbee-secrets-baseline.json --fail-on=high

GitLab CI

yaml
secret-scan:  image: node:20  script:    - npx @guardbee/mcp-secret-scanner scan . --fail-on=high  only:    - merge_requests    - main

Pre-commit Hook

bash
# .git/hooks/pre-commitnpx @guardbee/mcp-secret-scanner scan --staged --fail-on=high || exit 1

Development

bash
npm installnpm test          # 71 unit testsnpm run build     # TypeScript compile

License

MIT — GuardBee

Feedback

Questions, ideas, or a false positive? Start a thread in GitHub Discussions or open an issue. If GuardBee is useful to you, a ⭐ on the repository helps others find it.

來源:packages/secret-scanner/README.md,提交 bc5997d

工具

6

scan_text

Scan a text string or code snippet for exposed secrets and API keys

輸入參數labelcontent必填entropy

scan_file

Scan a single file for exposed secrets and API keys

輸入參數path必填entropy

scan_directory

Recursively scan a directory for exposed secrets and API keys. Automatically skips node_modules, .git, dist, and binary files.

輸入參數path必填entropyexcludeincludebaselinemaxFiles

scan_git

Scan a git repository for secrets in what git says was added: the staged changes (before a commit) or every commit's added lines (history). History finds secrets that were deleted from the files but are still in the repository.

輸入參數mode必填path必填rangeentropybaselinemaxCommits

scan_agent_history

Scan the transcripts coding agents keep on this machine (Claude Code, Codex, Gemini CLI, Continue) for secrets that were pasted into a chat or printed by a command. Such a secret was already sent to the model provider and should be rotated. Each secret is reported once with how often it appears.

輸入參數entropy

list_patterns

List all secret patterns that the scanner can detect

無需輸入參數。

版本歷史

12
  1. v1.1.1最新Oct 30, 2026
  2. v1.0.2Oct 22, 2026
  3. v0.6.11Oct 21, 2026
  4. v0.6.10Oct 20, 2026
  5. v0.6.8Oct 19, 2026
  6. v0.6.7Oct 16, 2026
  7. v0.6.6Oct 15, 2026
  8. v0.6.4Oct 14, 2026
  9. v0.6.3Oct 14, 2026
  10. v0.6.1Oct 13, 2026
  11. v0.6.0Oct 11, 2026
  12. v0.3.0Oct 9, 2026

評分

已滿足適用檢查項的 90%

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

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

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

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分