
Import Guardian
io.github.Baneado98由 GitHub 账号 Baneado98 发布v0.3.0更新于 Oct 25, 2026
Catch AI-hallucinated (slopsquatted) npm imports in generated code before npm install.
概览
一个本地 MCP 服务器,用实时 npm 注册表核对 AI 生成代码中的 npm 导入,在安装前标出臆造或可疑的包名。
- 可以做什么
- 扫描一段生成的 JS/TS 代码,检查其中引用的每个 npm 包,给出 CLEAN、REVIEW 或 BLOCK 结论,并在疑似臆造或高风险时给出最接近的真实包名建议。核对一份明确的包名清单,或对单个包做深度检查,包括是否存在、发布时长、版本、源码仓库、周下载量以及与热门包的相近程度。能把带作用域和子路径的导入归并为基础包名,并跳过 Node 内置模块和本地路径。README 另述了付费的锁文件审计和免费 HTTP 接口,但不属于本地工具集。
- 适用场景
- 适合在助手编写或修改会新增 npm 依赖的代码时使用,在运行安装命令前发现臆造或新近抢注的包名。可作为代码生成流程中的只读防护栏。
- 运行要求
- 通过 stdio 在本地运行,通常用 npx 从 import-guardian-mcp 这个 npm 包启动,因此需要 Node.js,并能访问 npm 注册表和下载统计接口。未声明任何认证、环境变量或请求头。
安装
在 SourceWeft 中
- 打开 控制台中的 Import Guardian,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
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
Verdicts: 🟢 CLEAN · 🟠 REVIEW · 🔴 BLOCK.
Use it as an MCP server (free)
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).audit_lockfile🔒 (premium) — the deep one. Give it a lockfile from npm (package-lock.json), yarn (yarn.lock), pnpm (pnpm-lock.yaml), PyPI (requirements.txt/poetry.lock/Pipfile.lock) or Go (go.mod/go.sum) and it resolves the whole transitive tree and audits every package for dependency confusion, transitive typosquats / homoglyph clones, maintainer-takeover fingerprints, nonexistent pins, and install-script risk. See below.
Deep lockfile audit (premium) 🔒
scan_code_imports looks at the handful of imports you can see. audit_lockfile looks at the hundreds you can't — the fully resolved dependency graph in your lockfile — and finds the supply-chain attacks an LLM cannot reason about from source alone:
Seven ecosystems. The same resolved-graph engine runs over npm / yarn / pnpm, PyPI (requirements.txt, poetry.lock, Pipfile.lock), Go modules (go.mod, go.sum), Rust / Cargo (Cargo.lock, Cargo.toml), Java (Maven pom.xml, Gradle build.gradle / .kts / gradle.lockfile) and PHP / Composer (composer.json, composer.lock) — each cross-checked against its own public index (npm registry, PyPI, the Go module proxy, crates.io, Maven Central, Packagist). On crates.io the matcher knows the -/_ equivalence (rustdecimal vs rust_decimal); on Maven an internal groupId:artifactId unclaimed on Central is the dependency-confusion target; on Composer an internal vendor/package unregistered on Packagist while a private repo is merged with the public index is the confusion target, and a Packagist-abandoned package is flagged as a takeover risk. Large lockfiles are bounded: direct + private-source packages are always live-checked first, then transitive up to a cap, so one call never fans out to tens of thousands of requests.
Pay per call via x402 (USDC on Base) or a prepaid Stripe key. The free POST /audit returns the verdict and issue counts by severity, but withholds which packages are affected and why — that's the paid report. This deep engine runs server-side only and is never shipped in the npm package.
Example
Free HTTP API
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.
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.
来源:README.md,提交 4a7985c
工具
0版本历史
1- v0.3.0最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分