mcp-secret-scan
Scans staged or working-tree git changes and commit ranges for secrets, with exact file and line numbers.
Detects GitHub tokens (ghp_, gho_, github_pat_) in scanned content to prevent secret leakage.
Detects Google API keys in scanned content to prevent them from being committed.
Detects npm tokens in scanned content to prevent them from being committed.
Detects OpenAI API keys (sk-) in scanned content to prevent them from being committed.
Can be used as a pre-commit hook to block commits when secrets are found at or above a severity threshold.
Detects PyPI tokens in scanned content to prevent them from being committed.
Detects SendGrid API keys in scanned content to prevent them from being committed.
Detects Slack tokens in scanned content to prevent them from being committed.
Detects Stripe API keys in scanned content to prevent them from being committed.
Detects Twilio API keys in scanned content to prevent them from being committed.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-secret-scanscan my staged changes for secrets before I commit"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Secret Scan
Find secrets before they reach a commit.
MCP Secret Scan checks staged diffs, files, directories, and raw text for API keys, tokens, private keys, passwords, and high-entropy strings — with masked findings and severity-based exit codes that work as a pre-commit or CI gate. Use it as an MCP tool so an agent can scan its own work before committing, or straight from the terminal. Fully offline: nothing you scan leaves your machine.
Fifth tool in the TokenSaver family: TokenSaver MCP maps repositories, MCP Context Budget audits tool costs, MCP Web Snapshot reads the web, MCP Log Tail summarizes logs, and Secret Scan guards commits.
Why
Secrets leak through commits far more often than through breaches: an .env pasted into a config, a token in a test fixture, credentials in a database URL. Linters and tests do not catch them, and by the time a scanner runs in CI the secret is already in history. The cheapest fix is a gate right before the commit — and that gate should be callable by the agent doing the work.
Related MCP server: Security & GRC MCP Server
Quick start
CLI, no install needed. Scan staged changes:
npx -y mcp-secret-scan scan --stagedExample output:
# Secret scan: staged changes
2 finding(s) in 1 file(s) — CRITICAL 1, HIGH 1
CRITICAL src/config.ts:12:15 aws-access-key — AWS access key id
const key = "AKIA…MPLE";
HIGH src/db.ts:4:20 uri-credentials — Password embedded in a URI
const url = "postgres://admin:****@db.example.com/app";
All secrets are masked. Nothing leaves your machine.
Gate: FAILED — this would block a commit.Other modes:
npx -y mcp-secret-scan scan ./src --strict
npx -y mcp-secret-scan text --content "AWS_KEY=AKIAIOSFODNN7EXAMPLE"
npx -y mcp-secret-scan scan --range main..HEAD --jsonExit codes: 0 clean, 1 findings at or above the threshold (critical/high by default, medium with --strict), 2 usage error. That makes it a drop-in pre-commit hook.
MCP server
Add it to any MCP-compatible client:
{
"mcpServers": {
"secretscan": {
"command": "npx",
"args": ["-y", "mcp-secret-scan", "serve"]
}
}
}From a local checkout, point command at node and args at the built entry point:
{
"mcpServers": {
"secretscan": {
"command": "node",
"args": ["/absolute/path/to/mcp-secret-scan/dist/index.js", "serve"]
}
}
}Tools
Tool | What it scans |
| Arbitrary text before it is written anywhere. |
| Staged or working-tree git changes, with exact file and line numbers. |
| A file or directory tree, skipping dependencies, binaries, and oversized files. |
Every tool returns masked findings classified as critical, high, medium, or low. The full secret is never printed.
What it detects
Cloud and platform keys: AWS access key ids, Google API keys.
Developer tokens: GitHub (
ghp_,gho_,github_pat_), npm, PyPI, Slack, Stripe, SendGrid, Twilio.AI provider keys: OpenAI (
sk-), Anthropic (sk-ant-).Credentials: private key blocks, passwords embedded in URIs, JWTs.
Unlabeled secrets: high-entropy strings with mixed character classes.
Generic assignments:
api_key = "...",password: "...", and similar patterns.
False positives are first-class
Inline
// secret-scan:ignore(or# secret-scan:ignore) skips a line..secretscanignorein the working directory holds allowlist regexes, one per line.--allow <regex>adds allowlist patterns per run; repeatable.Placeholders like
your_api_key_here,example,xxxx, orchangemeare ignored.Generic matches are
mediumand never block unless--strictis set.
Design principles
Offline: no network, no telemetry, no secret ever transmitted or logged in full.
Bounded: file size caps, directory ignore list, binary detection, and a findings cap.
Read-only: never edits files, never writes history.
Fast: pure regex and entropy checks, no model calls.
Gate-friendly: severity thresholds and exit codes designed for hooks and CI.
CLI reference
Option | Meaning |
| Scan git changes instead of the filesystem |
| Also block on medium severity findings |
| Maximum findings to report (default 200) |
| Allowlist pattern, repeatable |
| Machine-readable output |
Pre-commit example
# .pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: secret-scan
name: secret scan
entry: npx -y mcp-secret-scan scan --staged
language: system
pass_filenames: falseRoadmap
Custom rule files per project.
Baseline mode: accept existing findings and only block new ones.
Git history scan for auditing past commits.
SARIF output for code scanning integrations.
Configurable entropy thresholds.
Development
npm install
npm run typecheck
npm run build
npm testThe suite covers every rule, masking, entropy detection, allowlists, git diff parsing with real repositories, directory walking, CLI behavior, and MCP round trips.
License
MIT — see LICENSE.
This server cannot be deployed
Maintenance
Related MCP Connectors
Scan configs, files, or text for leaked secrets and obvious misconfigurations. Nothing stored.
Deep security scans of repos you own from your editor: dependency CVEs, SAST, git-history secrets.
Gitleaks Cloud - GitHub API Key Hunter & Secret Scanner
Generate SBOMs, scan vulnerabilities, and analyze dependencies from local projects or Git repos.
Related MCP Servers
- AlicenseAqualityBmaintenanceEnables scanning diffs or code blobs for leaked secrets, returning a verdict with severity and masked findings, all processed locally with no data sent externally.1MIT
- FlicenseNot gradedqualityCmaintenanceEnables local security scanning and compliance gap analysis for code and text, detecting secrets, PII, and OWASP vulnerabilities, and assessing readiness across major frameworks like NCA, ISO 27001, NIST CSF, and SOC 2.-
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to scan source code for secrets like API keys and passwords locally without network requests.2Apache 2.0
- AlicenseAqualityCmaintenanceScans diffs, files, and snippets for leaked secrets like AWS keys, GitHub tokens, and private keys, returning redacted findings while running fully locally without network calls.1MIT