Skip to main content
Glama

gitleaks-mcp

CI License: MIT 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 Engine interface (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_staged

Scan only what is staged (what git commit would record).

scan_repo

Scan a repo's history. Optional log_opts, e.g. @{upstream}..HEAD.

scan_path

Scan a file or directory without git.

scan_text

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

  • gitleaks on your PATH (brew install gitleaks), or set GITLEAKS_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.js and 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 readOnlyHint annotations (src/server.ts).

  • Resources are read-only data the client can attach; prompts are reusable templates the user invokes.

  • Safety: no shell (execFile with 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 gitleaks

Test 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 tools
scan_pathScan files or directoryA
Read-onlyIdempotent

Scan a directory or single file on disk for secrets, without needing git.

Inputs: path (required), max_findings.

scan_repoScan git historyA
Read-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 changesA
Read-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 snippetA
Read-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

    A4/5.0

    Scored across 4 tools

    Disambiguation5/5

    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).

    Naming Consistency5/5

    All four tools follow a uniform scan_<target> pattern (scan_repo, scan_staged, scan_path, scan_text). The target nouns are clear and predictable.

    Tool Count5/5

    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.

    Completeness4/5

    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

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables 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.
      44
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables scanning diffs or code blobs for leaked secrets, returning a verdict with severity and masked findings, all processed locally with no data sent externally.
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables 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.
      1
      MIT