🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

leakrank-guard

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leakrank-guard

Scans your code changes for leaked secrets and insecure configuration, and returns actionable fixes to your AI coding agent. MCP server plus CLI for Claude Code, Cursor, Codex and Windsurf.

latest
npmnpm
Version
0.2.3
Version published
Maintainers
1
Created
Source

LeakRank Guard

Catches leaked secrets and insecure configuration in the code your AI agent just wrote, and hands the agent an exact fix plus the list of keys you need to rotate.

leakrank-guard is the local CLI and stdio MCP server for LeakRank Guard. It collects the files you changed, sends them to the LeakRank scanning service over an authenticated HTTPS API, and returns findings your coding agent can act on directly.

npx leakrank-guard init

Works with Claude Code, Cursor, Codex and Windsurf.

What it does

  • Scans the files in your git working tree for hardcoded secrets (API keys, tokens, private keys, connection strings) and insecure configuration (exposed source maps, wildcard CORS, secrets referenced from client-side bundles, and similar patterns).
  • Runs a static pass first, then an LLM triage pass on the flagged lines to drop false positives and write a concrete fix.
  • Returns, per finding: severity, file and line, masked evidence, a fix summary, an optional unified diff, and the exact secrets that need rotating.
  • Exposes all of this to your coding agent as MCP tools, so scanning happens as part of the agent's normal loop instead of being a step you remember to run.
  • Also runs headless in CI via leakrank-guard scan --fail-on high --json.

What it does not do

  • It is not a penetration test and does not probe your running application.
  • It does not make your application secure. It finds a specific class of mistakes (leaked credentials and risky configuration) in the code it is given, and it will miss things.
  • It does not rotate, revoke, or change any credential for you. Rotation is always your action.
  • It does not run the analysis on your machine, and it does not run on your agent's tokens. See What leaves your machine.
  • It has no free tier. Scanning requires an active LeakRank Guard subscription.

60-second quickstart

# 1. Link this machine (opens your browser, no key to paste)
npx leakrank-guard login

# 2. From inside your project, wire Guard into whichever agents you use
npx leakrank-guard init

# 3. Sanity check
npx leakrank-guard status
npx leakrank-guard scan --baseline

Then, in your agent, ask it to run guard_scan_baseline once. After that it scans each change on its own.

Requirements: Node.js 18 or newer, git on your PATH, and a git repository (Guard scans the git working tree).

Installation

Run this from the root of your project:

npx leakrank-guard init

init will:

  • Ask for an API key, or start a browser login if you press Enter. The key is stored in your OS keychain when available, otherwise in ~/.config/leakrank/config.json with 0600 permissions.
  • Detect which of Claude Code, Cursor, Codex and Windsurf are present.
  • Register the MCP server for each detected agent (command npx, args -y leakrank-guard mcp).
  • Drop a short rules file so the agent knows to scan after each change.

Re-running init is safe. It rewrites the MCP entry in place and skips rules sections that are already there.

No agent config file ever contains your API key. The MCP server reads the key from your keychain or config file at runtime.

Manual MCP configuration

If you would rather wire it up yourself, the server is always the same stdio command:

command: npx
args:    ["-y", "leakrank-guard", "mcp"]

Claude Code. Either run:

claude mcp add leakrank-guard -- npx -y leakrank-guard mcp

or create .mcp.json in the project root:

{
  "mcpServers": {
    "leakrank-guard": {
      "command": "npx",
      "args": ["-y", "leakrank-guard", "mcp"]
    }
  }
}

Cursor. .cursor/mcp.json in the project root:

{
  "mcpServers": {
    "leakrank-guard": {
      "command": "npx",
      "args": ["-y", "leakrank-guard", "mcp"]
    }
  }
}

Codex. Append to ~/.codex/config.toml:

[mcp_servers.leakrank_guard]
command = "npx"
args = ["-y", "leakrank-guard", "mcp"]

Windsurf. ~/.codeium/windsurf/mcp_config.json:

{
  "mcpServers": {
    "leakrank-guard": {
      "command": "npx",
      "args": ["-y", "leakrank-guard", "mcp"]
    }
  }
}

Any other MCP client that can launch a stdio server works too: point it at npx -y leakrank-guard mcp.

Authentication

Guard authenticates with a Bearer API key tied to your subscription.

npx leakrank-guard login

This is an OAuth 2.0 Device Authorization Grant (RFC 8628). The CLI prints a URL and a short code, opens your browser, and waits while you approve. Nothing is pasted through the terminal.

The resulting key is stored, in order of preference:

  • Your OS keychain, under service leakrank-guard, account api-key (requires the optional @napi-rs/keyring native module; if it is unavailable, Guard silently falls back to step 2).
  • ~/.config/leakrank/config.json, written with mode 0600.

At runtime the key is resolved as: LEAKRANK_API_KEY environment variable → config file → keychain.

For CI, set LEAKRANK_API_KEY as a secret instead of running login.

Environment variables

VariableRequiredPurpose
LEAKRANK_API_KEYNoOverrides the stored key. Intended for CI and headless machines.
LEAKRANK_SITE_URLNoOverrides the API base URL. Defaults to https://leakrank.com.

CLI reference

CommandWhat it does
leakrank-guard loginLink this machine through your browser and store the key.
leakrank-guard initDetect your agents, register the MCP server, write the rules file.
leakrank-guard scanScan changed and untracked files in the working tree. 1 credit.
leakrank-guard scan --baselineScan every tracked and untracked file. 10 credits.
leakrank-guard statusPrint plan, subscription status, remaining credits, renewal date.
leakrank-guard mcpRun the stdio MCP server. Agents launch this; you normally do not.
leakrank-guard --versionPrint the installed version.
leakrank-guard helpUsage summary.

scan options

OptionEffect
--baselineFull-repo scan instead of the working-tree diff.
--fail-on <low|medium|high|critical>Exit 1 if any finding is at or above that severity. Default: never fail on findings.
--jsonEmit the raw JSON response instead of the human-readable report.

Exit codes

CodeMeaning
0Scan completed and no --fail-on threshold was crossed.
1Not a git repository, the scan failed, or findings crossed --fail-on.
2Out of credits.

CI example

- name: LeakRank Guard
  run: npx -y leakrank-guard scan --baseline --fail-on high
  env:
    LEAKRANK_API_KEY: ${{ secrets.LEAKRANK_API_KEY }}

MCP tools

ToolPurposeWhen the agent should call itCost
guard_scan_diffScan the current working-tree changes, or an explicit files array of {path, content}.After finishing any code change, before telling the user it is done.1 credit
guard_scan_baselineScan the whole repository.Once at install, or when the user explicitly asks for a full re-scan.10 credits
guard_statusReport subscription status and remaining credits.When a scan reports no credits, or when the user asks.Free

Every tool returns a JSON text block. Failures (no API key, not a git repository, out of credits, API error) come back as MCP tool errors with an actionable error field, not as a crashed server.

initialize and tools/list work without any credentials, so an agent can always discover the tools. Only the scanning calls need an active subscription.

Credit costs: each change scan is 1 credit and a full baseline is 10. Your monthly allowance and renewal date are shown by guard_status and leakrank-guard status.

What leaves your machine

Be clear-eyed about this: Guard is a hosted scanning service, and your changed file contents are uploaded to it.

When a scan runs, the CLI:

  • Asks git which files changed (git diff --name-only HEAD plus untracked files), or lists all tracked files for a baseline.
  • Skips binaries, images, archives, fonts, source maps, lockfiles, and anything under node_modules, .git, .next, dist, build, out, vendor, .venv, __pycache__. Files over ~180 KB and files containing NUL bytes are skipped too, and no more than 400 files are sent.
  • Sends the remaining file paths and contents over HTTPS to https://leakrank.com/api/guard/scan, authenticated with your API key.

On the server, a static pass narrows those files down to flagged lines. Only those flagged slices (the rule that matched, the file path, the line number, and up to ~240 characters of the source line) are passed to LeakRank's LLM provider for triage and fix generation, on LeakRank's own account. Your coding agent's tokens are never spent on the analysis.

What is stored

  • A scan record: your subscription id, scan type, number of files scanned, credits used, model usage, and the findings.
  • Findings contain the file path, line number, masked evidence (for example sk_l...9f2a), the fix summary and diff, and the names of secrets to rotate.
  • Raw secret values are masked before storage. The file contents you upload are used to run the scan and are not kept as part of the scan record.

Full details: leakrank.com/privacy.

Upgrading

npx leakrank-guard ... and the MCP entry npx -y leakrank-guard mcp resolve the latest published version, so most people never pin anything. To force a fresh copy:

npm cache clean --force
npx leakrank-guard@latest --version

If you installed globally:

npm install -g leakrank-guard@latest

Nothing about init needs to be re-run after an upgrade. Re-run it only if you add a new agent to the project.

Uninstalling

init only ever writes these. Remove the ones that apply:

Project files

PathWritten for
.mcp.json (the leakrank-guard key under mcpServers)Claude Code, when the claude CLI was not available
CLAUDE.md (the # LeakRank Guard section)Claude Code
.cursor/mcp.json (the leakrank-guard key)Cursor
.cursor/rules/leakrank.mdcCursor
AGENTS.md (the # LeakRank Guard section)Codex
.windsurf/rules/leakrank.mdWindsurf

Files outside the project

PathWritten for
~/.codex/config.toml (the [mcp_servers.leakrank_guard] block)Codex
~/.codeium/windsurf/mcp_config.json (the leakrank-guard key)Windsurf
~/.config/leakrank/config.jsonYour stored API key, if the keychain was unavailable
OS keychain entry, service leakrank-guard, account api-keyYour stored API key

If init registered the server through the Claude CLI, remove it with:

claude mcp remove leakrank-guard

Cancelling the subscription itself is done from your Paddle receipt email or from your LeakRank dashboard, not from the CLI.

Troubleshooting

command not found: leakrank-guard You do not need a global install. Use npx leakrank-guard <command>. If you did install globally, make sure npm's global bin directory (npm bin -g) is on your PATH.

Not linked to a LeakRank Guard subscription. The machine has no key. Run npx leakrank-guard login, or export LEAKRANK_API_KEY. If login succeeded but the key is not picked up, check that ~/.config/leakrank/config.json exists and is readable by you.

I do not have a subscription yet Start one at leakrank.com/guard. You can do it without leaving the login flow: run npx leakrank-guard login, open the printed URL, subscribe on that page, then approve the code in the same tab. The code stays valid for 30 minutes, and the terminal you started links itself as soon as you approve. If it does expire, just run login again once the subscription is active.

Not a git repository. Guard reads the file list from git. cd into your project root, or run git init first. Through MCP the same situation returns {"error":"not_a_git_repo"} rather than failing the tool call.

The agent does not show the Guard tools Restart the agent after init. MCP servers are launched at session start. Then confirm the server runs standalone:

echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | npx -y leakrank-guard mcp

You should get a JSON line listing guard_scan_diff, guard_scan_baseline and guard_status. If that works but the agent still shows nothing, the config file the agent actually reads is probably not the one init wrote. Check the manual configuration paths above.

No changed files to scan. An incremental scan looks at files that differ from HEAD plus untracked files. If you just committed everything, there is nothing to scan. Make a change, or run scan --baseline.

Out of credits. / exit code 2 Your allowance for the period is spent. leakrank-guard status shows the renewal date. Baseline scans cost 10 credits, so avoid running them in a loop.

subscription_inactive The subscription is paused, cancelled, or past due, so scans are refused with exit code 1. Restart it at leakrank.com/guard or check your billing status from your LeakRank dashboard. Through MCP, the tool result carries next_step and subscribe_url so your agent can tell you what to do.

Pricing

Guard is a paid subscription. Current plans, credit allowances and the free-scan alternative are on leakrank.com/guard. Prices are not duplicated here so this page cannot go stale.

License

The code in this npm package, the CLI and the stdio MCP adapter, is released under the MIT license. See LICENSE.

The hosted LeakRank scanning service that it talks to, including the detection rules, the triage pipeline and the LeakRank web app, is proprietary and is provided under the LeakRank terms. MIT covers this client, not the service behind it, and not your subscription.

Security disclosure

Found a vulnerability in this package or in the Guard API? Email support@leakrank.com with the details and, if you can, a minimal reproduction. Please do not open it publicly before we have had a chance to fix it. We will confirm receipt and keep you posted on the fix.

Keywords

mcp

FAQs

Package last updated on 29 Jul 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts