# import-guardian [Health: Active]

**Category:** 🔒 Security  
**Repository:** https://github.com/Baneado98/import-guardian  
**GitHub Stars:** 0  
**npm Downloads (last month):** 154  
**Views:** 1  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/import-guardian

## Description
Catch AI-hallucinated (slopsquatted) npm imports in generated code before npm install.

## Tools
Capabilities this server exposes over MCP:

- **scan_code_imports** — Scan a block of JS/TS source code for HALLUCINATED / slopsquatted npm imports BEFORE you install anything or commit. Extracts every npm package the code imports/requires and checks each against the live npm registry: flags packages that DO NOT EXIST (AI hallucinations — the #1 slopsquatting attack vector in 2026, where attackers register the plausible fake name to ship malware) and packages that exist but look freshly-squatted (brand-new, no repo, near-typo of a popular lib, near-zero usage). Returns a CLEAN / REVIEW / BLOCK verdict with a 'did you mean' suggestion for each bad import. ALWAYS run this on code you (an AI) just generated before running its install command. The free tier handles a code fragment (≤2,000 chars AND ≤5 distinct imported packages); a whole file / repo dump, more than 5 packages, or pro=true routes to the premium unlimited scan (requires IMPORT_GUARDIAN_KEY).
- **check_packages** — Check an explicit list of npm package names for hallucination / slopsquatting (e.g. a dependency list you are about to install). Returns CLEAN / REVIEW / BLOCK per package with a 'did you mean' for fakes. The free tier verifies a small handful (≤5 names); a full dependency manifest or pro=true routes to the premium unlimited batch verify (requires IMPORT_GUARDIAN_KEY).
- **verify_package** — Verify a single npm package name exists and is not a slopsquat: registry existence, age, version history, repo, weekly downloads, and edit-distance to popular packages. Use right before adding a dependency you are not 100% sure is real. Always free.
- **audit_lockfile** — DEEP supply-chain audit of a RESOLVED lockfile — the premium product. Works across NINE ecosystems: npm (package-lock.json v1/v2/v3, yarn.lock classic/berry, pnpm-lock.yaml), Python/PyPI (requirements.txt, poetry.lock, Pipfile.lock), Go (go.mod, go.sum), Rust/Cargo (Cargo.lock, Cargo.toml), Java (Maven pom.xml, Gradle build.gradle/.kts + gradle.lockfile), PHP/Composer (composer.json, composer.lock), Ruby/RubyGems (Gemfile.lock, Gemfile), and .NET/NuGet (packages.lock.json, .csproj/Directory.Packages.props). It resolves the dependency graph and cross-checks each name against that ecosystem's LIVE public index (npm registry, PyPI, the Go module proxy, crates.io, Maven Central, Packagist, rubygems.org, nuget.org), auditing for: (1) DEPENDENCY CONFUSION — internal/private package names unclaimed on the public registry that an attacker can shadow (the highest-impact supply-chain attack), INCLUDING npm SCOPE-SHADOWING (a private @org/pkg whose whole @org scope is unclaimed), Maven groupId confusion, Composer vendor/package confusion, RubyGems private-source gem confusion, and NuGet feed confusion (the ORIGINAL Birsan 2021 vector — an internal package ID not reserved on nuget.org while a private feed is restored alongside it); (2) transitive TYPOSQUATS and homoglyph/Unicode-confusable clones (Damerau-Levenshtein + confusable folding, per-registry canonicalization incl. crates.io -/_ equivalence, Maven/Composer coordinate typos, RubyGems gem typos incl. the rest-client/rest_client class, and NuGet dotted-ID typos); (3) nonexistent pinned packages; (4) MAINTAINER-TAKEOVER fingerprints (dormant package republished, version burst, Packagist-ABANDONED packages, the RubyGems rest-client-hijack pattern); (5) INSTALL-SCRIPT VERSION-DIFFING — a package whose newest release ADDED a preinstall/postinstall/install/prepare hook the previous release did NOT have (the exact injection shape of event-stream / ua-parser-js); (6) INSTALL-SCRIPT PAYLOAD ANALYSIS — downloads the package tarball and statically analyzes the actual hook code (network egress, credential/env exfil, child-process exec, download-and-run, obfuscation) using an obfuscation-RESISTANT AST/token analyzer that decodes escapes and folds split strings, so a payload hidden as require("child_pro"+"cess") or global["ev"+"al"](…) is still caught; (7) Go `replace`→external-host HIJACK, live-verified against the module proxy; (8) KNOWN-MALWARE / known-vulnerability cross-reference of the EXACT resolved version against the live OSV.dev database (covers RubyGems and NuGet too); plus INSTALL-SCRIPT and provenance risk graded by REAL download counts. Returns CLEAN / REVIEW / BLOCK with per-package findings and 'did you mean'. Runs server-side behind payment (IMPORT_GUARDIAN_KEY or an x402 wallet); the free tier returns only the verdict and issue counts, withholding which packages are affected.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "import-guardian": {
    "command": "npx",
    "args": ["-y","import-guardian-mcp"]
  }
}
```

## Documentation

## What import-guardian does

import-guardian MCP server evaluates dependency names before they enter an install command. Its primary workflow accepts generated JavaScript or TypeScript, extracts imported npm packages, and checks whether those names exist and look legitimate. It can identify nonexistent packages, newly published packages, missing repositories, very low download activity, and names that closely resemble popular libraries.

The service reports three outcomes: CLEAN for packages that pass its checks, REVIEW for suspicious but existing packages, and BLOCK for imports that do not exist or match stronger malicious-package signals. A blocked name may include a suggestion for a nearby real package.

The server also accepts an explicit package list and can inspect a single package in greater depth. Its premium lockfile audit extends the review from visible imports to the resolved dependency graph. Supported inputs include npm package-lock.json, yarn.lock, pnpm-lock.yaml, Python requirements.txt, poetry.lock, Pipfile.lock, and Go mod or sum files.

## How it works

The import-guardian MCP server uses regular-expression extraction rather than an AST. Scoped subpaths are reduced to their package root, so imports such as `@scope/pkg/sub` are checked as `@scope/pkg`, while `lodash/fp` is checked as `lodash`. Node built-ins, including `fs` and `node:path`, and local paths are skipped.

The basic package checks use live registry information such as existence, release age, versions, repository details, and download activity. Similarity checks can identify spelling changes, transpositions, and other likely typosquats. The lockfile tool resolves the complete dependency tree and checks for dependency confusion, transitive typo or homoglyph clones, maintainer-takeover patterns, risky install scripts, and known malicious or vulnerable versions through OSV.dev.

For lockfile audits, deeper analysis can inspect npm package tarballs and PyPI source distributions in memory. It examines lifecycle hooks, setup files, build backends, and related code for behaviors such as credential or environment-data theft, network egress, process execution, obfuscation, and download-and-run logic. Go replacement directives are also checked against the Go module proxy.

## Setup and configuration

Run the import-guardian MCP server through `npx` using an MCP client configuration:

```json
{
  "mcpServers": {
    "import-guardian": {
      "command": "npx",
      "args": ["-y", "import-guardian-mcp"]
    }
  }
}
```

The README presents `audit_lockfile` as a premium tool; the other listed tools are the code and package checks.

## Tools and capabilities

- `scan_code_imports`: extracts npm imports from generated JavaScript or TypeScript and checks them.
- `check_packages`: verifies a supplied list of package names.
- `verify_package`: performs a deeper review of one package, including existence, age, versions, repository, downloads, and similarity to popular packages.
- `audit_lockfile`: audits resolved dependencies from supported npm, Yarn, pnpm, PyPI, and Go inputs.

## Limitations and notes

The import-guardian MCP server focuses on dependency names and resolved dependency metadata; `scan_code_imports` does not inspect arbitrary program behavior. Its import extraction is regex-based, so it is not a full language parser. The basic scan sees imports that are visible in source, whereas transitive dependencies require the premium lockfile audit.

Registry and advisory results can change as packages are published or databases are updated. A clean result therefore reflects the checks and data available at scan time, not a guarantee that a package is safe in every context.

_Full upstream README: https://allmcps.com/mcp/import-guardian/readme_

