pkgsentry
Checks npm packages and npm install commands using registry metadata, download statistics, install-script analysis, and malware/advisory data to return ALLOW/WARN/BLOCK before installation.
Checks PyPI packages and Python install commands using registry metadata, download statistics, and malware/advisory data to return ALLOW/WARN/BLOCK before installation.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
pkgsentry
Stops AI coding agents from installing hallucinated, typosquatted, or malicious packages.
Claude Code, Cursor, Codex and friends run npm install and pip install on your machine. Sometimes the package name is made up. Sometimes it's one letter off from a real one. Attackers register exactly those names. pkgsentry checks every package before the install runs.

npx pkgsentry setupThat's it. It finds the agents you have installed, lets you pick which to protect, shows you exactly what it will change, and asks before writing anything. Then it dares you to sneak a package past it.
Why this exists
Language models are good at naming packages that sound right. When you ask about common tasks they're nearly always correct. Ask about anything niche and they start inventing names.
We measured it. We asked Claude Haiku and Claude Sonnet (no web access) to name packages for about 480 programming tasks, then looked every name up:
Prompt | Unique names suggested | Don't exist on the registry |
Common tasks ("parse YAML", "hash passwords") | 220 | 0 (0%) |
Niche integrations, 3 alternatives each ("Victron VE.Direct driver", "Bambu Lab MQTT client") | 590 | 272 (46%) |
Every one of those 272 names is free for anyone to register. That attack has a name, slopsquatting, and it isn't hypothetical: when a security researcher registered huggingface-cli, a name models kept suggesting, it was downloaded thousands of times. Add classic typosquats (lodahs, reqeusts, scikit-lean) and an agent with shell access is one confident guess away from running someone else's postinstall script.
pkgsentry sits in front of that install.
Related MCP server: package-verify-mcp
What it does
$ npx pkgsentry check pypi reqeusts
BLOCK reqeusts (pypi)
- Doesn't exist on PyPI. Did you mean "requests"?pkgsentry check <npm|pypi> <name>[@version]...: ALLOW / WARN / BLOCK with reasons.--jsonfor machines.pkgsentry run -- <install command>: parses the command, checks every package, and only runs it if nothing is blocked. WARN asks first (or pass--yes).Claude Code hook: a
PreToolUsehook on Bash. Blocked installs are denied before they run, and the reason goes back to Claude so it can fix the name itself. Warnings ask you.MCP server: a
check_package/check_install_commandtool for Cursor, Windsurf, Codex, or any MCP client, plus a rules file telling the agent to use it.
It understands npm, pnpm, yarn, bun, npx, pnpm dlx, bunx, pip, pip3, python -m pip, uv pip, uv add, uvx, uv tool, pipx, poetry, and pdm, including -r requirements.txt files, compound commands (cd api && pip install ...), env prefixes, sudo, and bash -c "...".
Zero runtime dependencies. A supply-chain tool shouldn't bring its own supply chain.
Install
npx pkgsentry setup # interactive: pick agents, review changes, try it out
npx pkgsentry setup --yes # non-interactive: protect every detected agent
npx pkgsentry setup --dry-run # show the changes, write nothing
npx pkgsentry uninstall # removes exactly what setup addedIn a terminal, setup is interactive: arrow keys and space to pick agents, a summary of every file it will touch, then a quick game where you try to get a hallucinated or malicious package past it (using the real checker). In CI, with piped output, or with --plain, it prints the classic plain diff and asks a single yes/no question instead.
Agent | What | Enforcement |
Claude Code |
| Hard: blocked installs never run |
Cursor | MCP server in | Agent is instructed to check first |
Windsurf | MCP server in | Agent is instructed to check first |
Codex CLI |
| Agent is instructed to check first |
Every file is backed up to <file>.pkgsentry.bak before it's changed. Setup is idempotent. Want just one agent? npx pkgsentry setup cursor.
The MCP integrations depend on the agent following its rules. For hard enforcement anywhere, use pkgsentry run -- <command> or install globally (npm i -g pkgsentry) so the hook and MCP server start faster than through npx.
How scoring works
Every check collects signals. Each adds points. Some block outright.
Signal | Points | Notes |
Package doesn't exist | BLOCK | Likely hallucinated. Suggests the closest popular name. |
Known malware (OSV.dev) | BLOCK |
|
npm replaced it with a security placeholder | BLOCK | npm's |
Lookalike of a top-5,000 package | 50 | Edit distance 1 (names of 4-7 chars) or 2 (8+), adjacent swaps, |
First published < 7 days ago | 35 | |
First published < 30 days ago | 25 | |
Fewer than 50 downloads last week | 25 | npm downloads API, pypistats.org |
Fewer than 1,000 downloads last week | 10 | |
Install script that fetches or evals | 35 |
|
Any install script | 20 | npm only. Not counted for popular packages (esbuild, sharp...). |
Linked repository doesn't exist | 25 | GitHub/GitLab/Bitbucket/Codeberg. Uses |
No repository linked | 10 | |
Pinned version doesn't exist | 25 | |
Pinned version has known vulnerabilities | 25 | |
Deprecated | 10 | |
Some past versions were malware | 15 | |
Couldn't reach the registry | 30 | Fails toward WARN, never silently ALLOW. |
70+ is BLOCK, 25+ is WARN, anything lower is ALLOW. Popular packages (top 5,000 or 50k+ weekly downloads) are capped at WARN unless a hard-block signal fires, because heuristics alone should never stop you installing express.
So a two-day-old lookalike of lodash with nine downloads is blocked (50 + 35 + 25). A brand new, barely used package with a real repo gets a warning. A new package with an install script and no users is blocked.
The top-5,000 lists ship in data/ (from npm-high-impact and top-pypi-packages). Refresh them with npm run refresh-top. A GitHub Action opens a PR monthly.
Benchmark
200 package names: 100 bad, 100 good, half npm and half PyPI. Run it yourself with npm run bench.
Bad names blocked | Bad names blocked or warned | Good names blocked (false positives) | Good names warned | |
pkgsentry | 100% (100/100) | 100% | 0% (0/100) | 2% (2/100) |
without OSV.dev | 100% | 100% | 0% | 2% |
Category | Source | n | BLOCK | WARN | ALLOW |
Hallucinated (bad) | Names Claude Haiku / Sonnet suggested that don't exist on the registry | 50 | 50 | 0 | 0 |
Typosquats (bad) | Real malware from OSV.dev whose name is a lookalike of a top-1,000 package | 50 | 50 | 0 | 0 |
Popular (good) | Random sample of the top 5,000 | 50 | 0 | 0 | 50 |
Long tail (good) | Random sample of ranks 5,001-15,000, which pkgsentry's bundled list doesn't include | 50 | 0 | 2 | 48 |
The two warnings are falafel and matrx-ai, real packages whose linked GitHub repositories return 404. The signal is accurate, but they're not malicious.
Latency per package: ~10ms cached (p95 15ms), ~335ms uncached (p95 1.2s), measured on the machine that ran the benchmark.
Method
bench/collect.mjs builds bench/dataset.json. Every sample uses a fixed seed, so it's reproducible.
Hallucinated. Two rounds of prompts to Claude Haiku and Claude Sonnet running as subagents with tool access disabled, saved verbatim in
bench/sources/model-suggestions.jsonl. Round 1 asked for one package per common task; round 2 asked for three packages per niche integration. Every unique name was looked up on the registry, and we sampled 25 per ecosystem from those that don't exist.Typosquats. We sampled
MAL-*advisories from OSV.dev's public index (25,000 npm, 4,000 PyPI, since npm's feed is mostly spam and dependency-confusion packages) and kept those whose name is within plain Levenshtein distance 2 (or a separator variant) of a top-1,000 package, then sampled 25 per ecosystem. The selection uses its own simple Levenshtein, not pkgsentry's detector.Good. Random samples of real, popular packages and of the long tail just below the bundled list, so the false-positive number isn't just "it's on our allowlist".
What this benchmark does not show
Be skeptical of 100%. Here's why it's 100%:
All 50 hallucinated names don't exist, so they're blocked by a registry 404. That's the real-world case, since a hallucinated name is harmless until someone registers it, but it's the easy case.
All 50 malicious typosquats had already been removed by npm or PyPI (26 return 404, 24 are npm security placeholders). pkgsentry blocks them, but so would the registry by now.
That's why "without OSV.dev" scores the same. The heuristic signals (age, downloads, lookalike names, install scripts) protect you in the window between an attacker publishing and the registry reacting. This dataset doesn't measure that window. Measuring it properly means replaying malware against registry snapshots from when it was live. If you want to help build that, see CONTRIBUTING.md.
Anecdotally, live packages do get flagged by heuristics alone: expresss (1 edit from express, 739 downloads/week, no repo) is blocked, and react-codeshift (published this year, 15 downloads/week, no repo) gets a warning.
Configuration
Zero config by default. To trust packages your team uses (private registry packages would otherwise 404), add .pkgsentry.json to your repo:
{
"allow": ["internal-utils", "npm:@acme/*", "pypi:our-private-lib"],
"block": ["npm:event-stream"]
}Rules without a prefix apply to both ecosystems. A trailing * matches anything after it. block wins over allow. pkgsentry uses the nearest .pkgsentry.json walking up from the current directory, plus ~/.pkgsentry/config.json if it exists.
Environment variable | Effect |
| State directory (default |
| Skip the cache |
| Accurate repository checks via the GitHub API |
| Terminal colors |
Registry lookups are cached in ~/.pkgsentry/cache for 24 hours (missing packages for 1 hour, OSV results for 6). pkgsentry cache clear empties it.
Output
$ npx pkgsentry check npm lodahs expresss express
BLOCK lodahs (npm)
- Known malicious package (MAL-2025-25502): Malicious code in lodahs (npm)
- npm removed this package for malicious content and replaced it with a placeholder.
BLOCK expresss (npm) since 2016 ยท 739 downloads/week
- Name is 1 edit away from popular package "express". Possible typosquat.
- Low usage: 739 downloads last week.
- No source repository linked.
ALLOW express (npm) top-5000 npm packageExit codes: 0 ALLOW, 1 WARN, 2 BLOCK, 64 usage error. --json prints { verdict, results: [{ name, verdict, score, signals: [{ id, severity, points, message }], suggestion, ... }] }.
Use it as a library
import { createChecker, parseInstallCommand } from 'pkgsentry';
const { packages } = parseInstallCommand('pip install -r requirements.txt flask');
const results = await createChecker().checkAll(packages);Limitations
npm and PyPI only for now. Cargo, Go, and RubyGems are good first issues.
Packages from private registries look nonexistent to pkgsentry. Allowlist them.
npm installwith no arguments (installing frompackage.json) isn't checked yet.Cursor, Windsurf, and Codex enforcement relies on the agent following its rules file. Only the Claude Code hook can block on its own.
The command parser covers what agents actually type, not all of POSIX shell. If you find a bypass, please report it privately (see CONTRIBUTING.md).
Contributing
New ecosystems are the most useful contribution, and the adapter interface is small. See CONTRIBUTING.md.
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
This server cannot be deployed
Maintenance
Related MCP Connectors
Blocks typosquatted or hallucinated npm/PyPI packages before an AI agent installs them.
Package verdicts for AI coding agents: check npm, PyPI, Go and NuGet installs before they run.
Check packages for CVEs, slopsquatting, and CISA KEV before your AI agent installs them.
Package, dependency, CI and config safety checks for coding agents. Pay per call.
Related MCP Servers
- FlicenseAqualityDmaintenancePackage intelligence MCP server. Stops AI agents from installing hallucinated/malicious packages across 17 ecosystems. 22 tools, free, no auth.221-
- AlicenseAqualityDmaintenanceVerifies npm package names for safety, detecting typosquats and nonexistent packages before your coding agent installs them.23 npmMIT
- AlicenseNot gradedqualityDmaintenanceValidates and checks packages across 19 ecosystems to prevent AI agents from installing hallucinated, deprecated, or malicious packages.81 npmAGPL 3.0
- AlicenseNot gradedqualityDmaintenanceEnables AI coding agents to automatically verify npm packages against the live registry before installation, flagging hallucinated, slopsquatted, or otherwise suspicious packages with risk verdicts.MIT