import-guardian
Scans generated JavaScript/TypeScript code to detect AI-hallucinated or suspicious npm package imports before installation, providing a verdict of CLEAN, REVIEW, or BLOCK.
README
import-guardian ๐ช
Catch AI-hallucinated (slopsquatted) npm imports in generated code โ before you run npm install.
An LLM just wrote some code. It might import a package that doesn't exist โ a name the model confidently hallucinated. Attackers register exactly those names and ship malware. This is slopsquatting, and in 2026 it's one of the fastest-growing supply-chain attacks: code generators have been observed referencing 205,000+ unique non-existent package names, and real hallucinated packages (react-codeshift, a fake huggingface-cli with 30k+ downloads) have already shown up in the wild.
import-guardian reads the generated code, extracts every npm package it imports, and tells you which ones are real โ so an agent never installs a name its own model invented.
It's part of the guardian set: npm-guardian audits a package you've already chosen for CVEs and malicious behaviour, license-guardian audits the licenses of your dependencies (GPL/AGPL/BUSL traps) before you ship, and lockfile-guardian audits the resolved package-lock.json for integrity tampering and risky install scripts. import-guardian works one step earlier than all of them, at the moment the code โ and its dependency names โ are generated.
What it catches
| ๐ป Hallucinated | imports of packages that do not exist on npm โ the model invented the name. Returns BLOCK with a "did you mean" to the closest real package. |
| ๐ชค Fresh squats | packages that do exist but were published days ago, have no source repo, near-zero downloads, or are a 1โ2 edit typo of a popular library. Returns REVIEW. |
| ๐งฉ Import-aware | resolves import x from "@scope/pkg/sub" โ @scope/pkg, lodash/fp โ lodash; skips Node built-ins (fs, node:path) and local paths. Plain regex, no AST, zero runtime deps beyond the MCP SDK. |
Verdicts: ๐ข CLEAN ยท ๐ REVIEW ยท ๐ด BLOCK.
Use it as an MCP server (free)
{
"mcpServers": {
"import-guardian": { "command": "npx", "args": ["-y", "import-guardian-mcp"] }
}
}
Tools:
scan_code_importsโ give it a block of generated JS/TS; it extracts and checks every npm import. Run this on code you just generated, before its install command.check_packagesโ verify an explicit list of package names.verify_packageโ deep-check a single package name (existence, age, versions, repo, weekly downloads, edit distance to popular packages).
Example
scan_code_imports({ code: 'import shift from "react-codeshift";\nimport React from "react";' })
๐ REVIEW โ 1 referenced package(s) look risky.
๐ react-codeshift (risk 57/100)
โข No source repository linked.
โข Only 1 published version.
โข Only 3 downloads in the last week despite being 158 days old.
๐ข react (ok) โ established package.
Free HTTP API
POST /scan { "code": "import x from 'reqeusts'\nimport y from 'lodash'" }
GET /verify?name=express
Hosted at https://import-guardian.vercel.app ยท try /verify?name=express vs /verify?name=reqeusts.
Pay-per-call (x402)
The /pro/* routes are gated by x402. Your agent pays $0.02 USDC per call automatically โ no sign-up, no API key. Payment settles on-chain (USDC on Base). The server holds no private key; it only declares a public receiving address.
POST /pro/scan { "code": "โฆ" } # 402 โ pay โ result, no rate limit
How it works (and its limits)
- Existence + freshness come straight from the live npm registry (
registry.npmjs.org) and the download-stats API โ these are facts, not guesses, which is the moat: an agent can't reliably know on its own whether a name it generated is real and trusted. - "Did you mean" uses Levenshtein distance against a curated list of high-impact packages attackers impersonate.
- It does not execute or install anything (read-only), and it intentionally errs toward
REVIEWrather than silently passing a brand-new lookalike. It is a guardrail, not a guarantee โ pair it with npm-guardian for behavioural/CVE auditing of packages you decide to keep.
License
MIT.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.