secretscan-mcp
Scans Git repositories and their commit history for exposed secrets, respects .gitignore, reports when secrets were added or removed, and provides remediation guidance for cleaning up the repository.
Detects GitHub classic and fine-grained tokens in files and Git history and provides GitHub-specific rotation, revocation, and misuse-check guidance.
Detects GitLab tokens in files and Git history and provides GitLab-specific rotation, revocation, and misuse-check guidance.
Detects Google API keys in files and Git history and provides Google-specific rotation and remediation guidance.
Detects npm tokens in files and Git history and provides npm-specific rotation and remediation guidance.
Detects OpenAI API keys in files and Git history and provides OpenAI-specific rotation and remediation guidance.
Detects PyPI tokens in files and Git history and provides PyPI-specific rotation and remediation guidance.
Detects SendGrid API keys in files and Git history and provides SendGrid-specific rotation and remediation guidance.
Detects Slack tokens and webhook URLs in files and Git history and provides Slack-specific rotation and remediation guidance.
Detects Stripe live and test secret keys in files and Git history and provides Stripe-specific rotation and remediation guidance.
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., "@secretscan-mcp Scan my repo for committed secrets, including git history."
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.
secretscan-mcp
Let your AI agent find secrets you committed by mistake, in your files and in your git history, without the secrets ever reaching the agent.
What's different here. Other secret-scanning MCP servers either call a vendor's cloud API (GitGuardian's ggmcp), only look at the working tree (mcp-secret-sentinel), or are generic scanners. secretscan-mcp is offline (one dependency,
mcp; it shells out to your owngit), it walks git history and tells you which commit added and removed each secret, it ends with a provider-specific rotation and clean-up checklist, and its safety claim is structural and tested: no code path can return a raw secret, and a test launches the server over stdio and checks that no planted secret, or 16-character slice of one, appears in any tool output or error.
It finds API keys, tokens, private keys, passwords in URLs and .env mistakes, in the working tree and in every
commit you let it walk. Then it tells the agent what to do: rotate first, look for misuse, clean up, and (optionally,
as text only) how to rewrite history.
Companion to the tutorial secretscan-mcp-the-hard-way, which builds a minimal version of this server from scratch.
What it looks like
Real output (the secrets are fake values generated by the test suite):
> scan_tree("C:\code\demo")
Scanned 2 files (git repository: .gitignore respected; skipped 0 binary, 0 over 1 MB). 2 finding(s).
HIGH f-15ab4258b891b540 aws-access-key-id .env:1 AKIA... (20 chars)
HIGH f-b5d779ed381cbf95 github-token app/settings.py:2 ghp_... (40 chars)
> scan_history("C:\code\demo")
Scanned 3 commit(s). 3 distinct secret(s) found: 1 removed from the files but STILL IN HISTORY, 2 still present in the newest scanned commit.
REMOVED HIGH f-8d09a993cf035308 stripe-live-key old.py:1 sk_l... (36 chars)
added in d98048147385 (2026-11-06), removed in 8996cdd170d6 (2026-11-06)
PRESENT HIGH f-15ab4258b891b540 aws-access-key-id .env:1 AKIA... (20 chars)
added in e7274b88dc45 (2026-11-06)
> explain_finding("f-8d09a993cf035308")
Stripe live secret or restricted key (stripe-live-key, severity high)
How to rotate / revoke:
1. Dashboard > Developers > API keys > the key's menu > Roll key. Choose an expiry for the old key ...
Rewriting history does not un-leak a secret. Once a commit was pushed, assume it was copied ...Related MCP server: secrets-le-mcp
Install
You need Python 3.10+ and git on your PATH.
Claude Code
claude mcp add secretscan -- uvx secretscan-mcpClaude Desktop (add to claude_desktop_config.json)
{
"mcpServers": {
"secretscan": {
"command": "uvx",
"args": ["secretscan-mcp"]
}
}
}Or with pip: pip install secretscan-mcp, then run secretscan-mcp.
Try asking
"Scan C:\code\myapp for committed secrets."
"Has anything secret ever been committed to this repo, even if it was deleted later?"
"Is my .env file ignored and untracked?"
"I leaked a GitHub token in an old commit. What exactly do I do?"
"Give me a remediation checklist for this repo, in order."
"Show me what I'd put in .secretscan-ignore to accept the current findings."
Tools
Tool | What it does |
| Scan the files |
| Stream |
| Are |
| What the credential is, step-by-step rotation at the provider (AWS, GitHub, GitLab, Slack, Stripe, Google, Anthropic, OpenAI, npm, PyPI, SendGrid, JWT, URL passwords, private keys), how to check for misuse, and why history rewriting does not un-leak it. |
| Scans tree and history and returns an ordered checklist: rotate, check for misuse, remove from the tree, optionally rewrite history ( |
| The lines to put in |
What it detects
AWS access key IDs and secret keys; GitHub (classic and fine-grained), GitLab, Slack (tokens and webhooks), Stripe (live
and test), Google API, Anthropic, OpenAI, npm, PyPI and SendGrid keys; JWTs (the header must decode as JSON); PEM
private key blocks; passwords embedded in URLs; and generic assignments such as API_TOKEN = "..." that pass entropy,
character-class, length and placeholder filters.
False-positive control is part of the design: hashes, UUIDs, base64 images, lorem ipsum, os.environ[...] and
${VAR} references, password: str, changeme-style placeholders, lockfile integrity hashes and identifier-like values
are all in the test corpus and must produce zero findings.
The ignore file (baseline)
<repo root>/.secretscan-ignore holds one fingerprint per line, # starts a comment:
f-b5d779ed381cbf95 # test token in the docs, already revokedA fingerprint is a 16-hex-character SHA-256 prefix of the rule and the value. It identifies a finding without containing it. A line that is not a fingerprint is an error, and the error never echoes the line, in case someone pasted a raw secret.
Security
Findings are always redacted. A finding is: type, file, line, commit, fingerprint, and the value as first 4 characters plus length. Secrets shorter than 16 characters show no characters at all. For provider tokens the 4 characters are the non-secret type marker (
AKIA,ghp_).No tool returns a raw secret.
Findinghas no field that can hold one; the raw value exists only inside the detector, long enough to compute the fingerprint and the preview. The source line is never printed.A last line of defence. Every tool result and every error message is re-checked against the high-confidence rules. If anything matches (for example, a file named like a token), the tool refuses to return it. Error messages never echo user input that could be a secret (unknown ids, ignore-file lines).
Read-only. The server never writes a file, makes no network connection, and runs only
git ls-files,git log,git check-ignoreandgit rev-parse, as argument lists (never a shell).core.fsmonitoris switched off and--no-ext-diff --no-textconvare used, so scanning an untrusted clone does not run its code.Remediation is text.
git filter-repoand BFG commands are printed for you to run. History rewriting needs the secret text, and the server will not print it, so the replacements file is yours to fill in.Fingerprints are truncated hashes of the value. For high-entropy tokens that is safe to share. A weak, guessable password could in principle be confirmed by hashing guesses, so do not publish the ignore file for repos that hold such values.
The honest limit: a leak is a leak. Removing a secret from history does not make it safe. Rotate it.
Limits
Pattern-based. No finding does not prove there are no secrets; a finding is not proof of a live credential (nothing is verified against the provider, because that needs the network).
Generic detection needs a digit in the value and, for non-password names, 16+ characters. Pass-phrases made of words only, and short passwords under a non-password name, are not detected. UUID-valued secrets are skipped by design.
Lockfiles, minified files, images,
node_modules,vendor,.venvand files over 1 MB are skipped, in the tree and in history.History status (
PRESENT/REMOVED) is tracked per distinct value across the scanned window; a value moved between files within one commit counts as unchanged. Only the newestmax_commitsare walked..gitignoreis applied through git, so a directory that is not a repository is scanned without it (the output says so).
Tests
pip install ".[test]" "ruff==0.16.0" "mypy==2.3.0"
ruff check src tests && mypy --strict src
pytest testsThe tests build real git repositories in temp directories and plant fake secrets assembled at test time (the only
literal is AWS's documented dummy AKIAIOSFODNN7EXAMPLE). They cover detection for every rule, a corpus of benign
look-alikes, history detection of a secret added then deleted, moves, odd file names, --all, truncation, the
baseline, and a stdio test that launches the installed server, drives all six tools over MCP, and asserts that no
planted value or 16-character slice of one appears in any output or error.
License
MIT
Available Tools
6 toolscheck_gitignoreARead-onlyIdempotent
Check whether secret-bearing files (.env, *.pem, *.key, id_rsa, credentials.json, *.tfvars, ...) are ignored and untracked in a git repository.
Reports: secret-looking files that ARE tracked (an ignore rule no longer helps; includes the
git rm --cached command as text), untracked-but-not-ignored ones that the next git add . would commit,
common secret file names that no ignore rule covers yet, and tracked files that match .gitignore anyway.
Looks at file names only; use scan_tree to look inside files.
Args: path: a directory inside a git repository.
Inputs: path (required). Returns: result
explain_findingARead-onlyIdempotent
Explain a finding: what the credential is, how to rotate or revoke it at the provider (step by step), how to check whether it was abused, and why rewriting git history does not un-leak it.
Args: id: a finding id such as f-0123456789abcdef from scan_tree/scan_history (valid until the server restarts), or a rule id such as aws-access-key-id or github-token to get the guidance without a finding.
Inputs: id (required). Returns: result
make_baselineARead-onlyIdempotent
Return the lines to put in /.secretscan-ignore so the CURRENT findings are accepted (a baseline) and only new ones are reported later. Only fingerprints are listed, never values. This server does not write the file: copy the text into it yourself, after checking each finding really is a false positive or already rotated. Accepting a live secret hides it; rotate real ones instead.
Args: path: project directory. include_history: also include secrets found in git history. max_commits: history depth if include_history is true.
Inputs: path (required), max_commits, include_history. Returns: result
scan_historyARead-onlyIdempotent
Scan git history for secrets, including ones already deleted from the current files.
Streams git log -p and looks at every added and removed line. Each distinct secret is reported once with
the commit that added it and, if it is gone from the newest commit, the commit that removed it. REMOVED means
'not in the current files', NOT 'safe': anyone who cloned in between still has it, so rotate it.
Args: path: a directory inside a git repository. max_commits: how many commits to walk back from HEAD (newest first). The report says if older ones were not scanned. all_branches: also walk every branch, tag and stash ref (git log --all) instead of only HEAD. max_findings: cap on findings listed.
Inputs: path (required), max_commits, all_branches, max_findings. Returns: result
scan_treeARead-onlyIdempotent
Scan the files of a project directory for secrets. Read-only; values are redacted.
Detects AWS, GitHub, GitLab, Slack, Stripe, Google, OpenAI, Anthropic, npm, PyPI and SendGrid keys, JWTs,
PEM private key blocks, passwords inside URLs, and generic high-entropy values assigned to names like
password/secret/token/api_key. In a git repository it scans exactly what git add . would pick up
(tracked files plus untracked files that are not ignored), so .gitignore is respected. It skips binaries,
files over 1 MB, lockfiles and vendored directories (node_modules, vendor, .venv, ...). It does not follow symlinks.
Each finding shows: severity, id (f-), rule, file:line, and the value as 'first 4 chars + length' (short secrets show no characters). Findings listed in /.secretscan-ignore are suppressed.
Args: path: project directory (absolute or relative to the server's working directory). max_findings: cap on findings listed, highest severity first.
Inputs: path (required), max_findings. Returns: result
suggest_remediationARead-onlyIdempotent
Scan a project (working tree and git history, if it is a repository) and return an ORDERED remediation checklist: rotate first, look for misuse, remove from the tree, optionally rewrite history, prevent recurrence. History rewriting is given as git filter-repo and BFG command text for you to run; this server never executes them and never prints the secret values they need (you fill in a replacements file yourself).
Args: path: project directory. max_commits: history depth to scan if the directory is a git repository.
Inputs: path (required), max_commits. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a distinct output shape: tree scan, history scan, filename-only gitignore audit, finding explanation, ordered remediation checklist, and baseline generation. The main overlap is that suggest_remediation internally re-scans working tree plus history, which could be confused with simply running scan_tree/scan_history, and explain_finding vs suggest_remediation both give rotation guidance. Descriptions largely resolve this, but the boundary is not razor-sharp.
All six tools follow a consistent verb_noun snake_case pattern: scan_tree, scan_history, check_gitignore, explain_finding, suggest_remediation, make_baseline. No mixed conventions or vague names.
Six tools is well-scoped for a secret-scanning server; each maps to a distinct stage of detect/audit/explain/remediate/baseline. Nothing feels padded or missing at the count level.
The lifecycle is well covered: detect (tree/history), prevent (gitignore audit), explain, remediate, and accept baseline. Minor gaps: no way to enumerate the rule catalog directly (you must guess rule ids for explain_finding), no single-file or stdin scan target, and no option to have the server write the ignore file, so agents must hand-copy output.
Maintenance
Related MCP Connectors
Scan text and git diffs for committed credentials using real vendor key formats plus entropy.
Scan configs, files, or text for leaked secrets and obvious misconfigurations. Nothing stored.
Checks AI-written code for leaked keys and made-up packages, on your machine. Never uploads code.
Security scanner for AI-written code: SAST, secrets, dependencies, IaC, containers and DAST.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to autonomously scan repositories and staged changes for leaked secrets, move exposed credentials into environment files, purge secrets from Git history, and verify remediation through deterministic tools.MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to scan code or text content for hardcoded API keys, passwords, tokens, and private keys, reporting each finding by type, confidence, key name, and position. Secret values are never returned, so credentials can be located and addressed without leaving the machine.1MIT
- AlicenseAqualityBmaintenanceSecurity checks for code an AI agent is about to trust. vetcode_guard checks a command before it installs packages or adds an MCP server: made-up names, look-alikes, malware advisories, brand-new releases, and the archive read without running it. vetcode_scan reads a folder for malware, supply-chain attacks, attacks on agents, leaked secrets and risky config. Local, zero dependencies.42MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to inspect git working trees and history for exposed credentials without letting raw secrets reach the model, with false-positive filtering, baseline support, and remediation guidance.MIT