gitleaks-mcp
Scans Git repositories for hardcoded secrets: inspects the staged index (what git commit would record), walks repository/commit history with optional log options such as @{upstream}..HEAD, and can also scan plain files or directories outside of Git. Findings are reported by rule, file, line and commit with secret values redacted.
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., "@gitleaks-mcp scan my staged changes for secrets"
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.
gitleaks-mcp
An MCP server that lets an AI agent scan code, staged changes and text snippets for hardcoded secrets using gitleaks.
Secrets never reach the model. Every scan runs with --redact, and the Match/Secret fields are dropped before results are returned. The agent only sees rule, file, line, commit and fingerprint.
Status of the engine: gitleaks is feature-complete and in security-patch-only mode; its author is now building Betterleaks. The scanner sits behind a small
Engineinterface (src/gitleaks.ts) so a Betterleaks backend can be added once v2 is stable without changing the tool contract.
Tools
Tool | What it does |
| Scan only what is staged (what |
| Scan a repo's history. Optional |
| Scan a file or directory without git. |
| Scan a string (a snippet or config you're about to write or share). |
All tools are read-only and take max_findings (default 50); the total count is always reported.
Also provided: resource gitleaks://about (engine version and guarantees) and prompt pre-push-check.
Related MCP server: secret-scanner
Example
Ask your agent "scan this snippet for secrets" (or call scan_text). The token is reported by rule and line, never by value:
{
"summary": "1 potential secret(s) found. Values are redacted.",
"findingsCount": 1,
"truncated": false,
"findings": [
{
"rule": "github-pat",
"description": "Uncovered a GitHub Personal Access Token, ...",
"file": "",
"startLine": 1,
"endLine": 1,
"fingerprint": ":github-pat:1"
}
]
}Typical prompts: "scan my staged changes before I commit", "check the commits I'm about to push", "does this config file contain secrets?"
Requirements
Node >= 20
gitleakson your PATH (brew install gitleaks), or setGITLEAKS_BIN
Use it
git clone https://github.com/matiasburni/gitleaks-mcp && cd gitleaks-mcp
npm install && npm run build
claude mcp add gitleaks -- node "$(pwd)/dist/src/index.js"Then ask: "scan my staged changes for secrets" or run the pre-push-check prompt.
Try it interactively with the MCP Inspector: npm run inspect.
How it works (MCP in 60 seconds)
Transport: stdio. The client launches
node dist/src/index.jsand exchanges JSON-RPC over stdin/stdout, so the server never writes logs to stdout (only stderr).Tools are actions the model calls, declared with a zod input schema and
readOnlyHintannotations (src/server.ts).Resources are read-only data the client can attach; prompts are reusable templates the user invokes.
Safety: no shell (
execFilewith an args array), redaction forced on, secret fields dropped, temp report deleted after each scan.
Develop
npm test # builds, then runs MCP-client end-to-end tests against real gitleaksTest secrets are assembled at runtime so no secret-shaped literal is committed.
Security
See SECURITY.md for the threat model, hardening and known limits (notably: only scan repositories you trust).
License
MIT - see LICENSE. Permissive on purpose, so you can reuse, fork and learn from it.
Available Tools
4 toolsscan_pathScan files or directoryARead-onlyIdempotent
Scan a directory or single file on disk for secrets, without needing git.
Inputs: path (required), max_findings.
scan_repoScan git historyARead-onlyIdempotent
Scan a git repository, including its commit history, for hardcoded secrets. Secret values are always redacted.
Inputs: path (required), log_opts, max_findings.
scan_stagedScan staged changesARead-onlyIdempotent
Scan only the changes currently staged in a git repository (what git commit would record). Use before committing.
Inputs: path (required), max_findings.
scan_textScan a text snippetARead-onlyIdempotent
Scan a string (e.g. a snippet, config or diff you are about to write or share) for secrets.
Inputs: text (required), max_findings.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool targets a distinct input source: a git repo with history, the staged index, a filesystem path, and a raw string. Overlap is minimal and the descriptions make the boundaries explicit (e.g. scan_staged vs scan_repo, scan_path without git).
All four tools follow a uniform scan_<target> pattern (scan_repo, scan_staged, scan_path, scan_text). The target nouns are clear and predictable.
Four tools is a tight, well-scoped surface for a secret-scanning server; each maps to a real distinct workflow (CI/history, pre-commit, on-disk, ad-hoc snippet). No tool feels redundant.
The main input modalities for secret scanning are covered, so agents have no dead ends for typical use. Minor gaps exist (e.g. no rule/config listing or baseline management), but these are workarounds rather than core failures.
Maintenance
Related MCP Connectors
Security scanner for AI agents: prompt injection, leaked secrets, PII, and SSRF-risk URL detection.
Find and redact leaked secrets, wallet keys and PII before an AI agent sends text.
Lets coding agents check their own code for leaked secrets, risky dependencies and AI-code mistakes
Secrets for developers and agents—secure context and workflows without exposing secret values.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to scan projects for leaked secrets and manage security incidents using GitGuardian's comprehensive API. It supports automated secret detection, honeytoken creation, and remediation workflows to secure codebases without context switching.44MIT
- 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
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to scan source code for secrets like API keys and passwords locally without network requests.2Apache 2.0
- 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