Back to Browse

Pkgtruth MCP Server

by Hxckya
Developer ToolsLow Risk10.0MCP RegistryLocal
Free

Server data from the Official MCP Registry

Catches hallucinated and slopsquatted npm packages before an agent installs them.

About

Catches hallucinated and slopsquatted npm packages before an agent installs them.

Security Report

10.0
Low Risk10.0Low Risk

Valid MCP server (2 strong, 3 medium validity signals). No known CVEs in dependencies. Package registry verified. Imported from the Official MCP Registry.

10 files analyzed · 1 issue found

Security scores are indicators to help you make informed decisions, not guarantees. Always review permissions before connecting any MCP server.

Permissions Required

This plugin requests these system permissions. Most are normal for its category.

HTTP Network Access

Connects to external APIs or services over the internet.

env_vars

Check that this permission is expected for this type of plugin.

file_system

Check that this permission is expected for this type of plugin.

Shell Command Execution

Runs commands on your machine. Be cautious — only use if you trust this plugin.

What You'll Need

Set these up before or after installing:

Alternate npm registry to verify against. Defaults to https://registry.npmjs.org.Optional

Environment variable: PKGTRUTH_REGISTRY

Alternate downloads API used for adoption figures. Defaults to https://api.npmjs.org.Optional

Environment variable: PKGTRUTH_DOWNLOADS_API

Where adoption figures are cached between runs. Defaults to ~/.cache/pkgtruth.Optional

Environment variable: PKGTRUTH_CACHE_DIR

Per-request timeout in milliseconds. Defaults to 8000.Optional

Environment variable: PKGTRUTH_TIMEOUT_MS

How to Install

Add this to your MCP configuration file:

{
  "mcpServers": {
    "io-github-hxckya-pkgtruth": {
      "env": {
        "PKGTRUTH_REGISTRY": "your-pkgtruth-registry-here",
        "PKGTRUTH_CACHE_DIR": "your-pkgtruth-cache-dir-here",
        "PKGTRUTH_TIMEOUT_MS": "your-pkgtruth-timeout-ms-here",
        "PKGTRUTH_DOWNLOADS_API": "your-pkgtruth-downloads-api-here"
      },
      "args": [
        "-y",
        "pkgtruth"
      ],
      "command": "npx"
    }
  }
}

Documentation

View on GitHub

From the project's GitHub README.

pkgtruth

npm CI node license

Ground truth about npm packages, for AI coding agents and CI.

pkgtruth catching a hallucinated package and a slopsquat

Your agent just wrote npm install unused-imports. That package is not the linter plugin it meant. It is a name an attacker registered because models kept inventing it — and npm has since replaced it with a security placeholder.

pkgtruth catches that before it reaches your lockfile.

Why this exists

Large language models invent package names. Measured across models, 19.7% of generated package names were hallucinated, and when researchers re-ran the prompts, 43% of those names came back every single time.

That reproducibility is the whole attack. An attacker does not need to compromise a maintainer, poison a build server, or find a vulnerability. They watch what models invent, register the name, and wait. The technique is called slopsquatting, and it is already happening in the wild.

The standing security advice is that agents with package-management capabilities should not install anything without a review gate. pkgtruth is that gate, in a form an agent can call on its own.

Install

As an MCP server (for coding agents)

{
  "mcpServers": {
    "pkgtruth": {
      "command": "npx",
      "args": ["-y", "pkgtruth"]
    }
  }
}

Two tools become available:

ToolUse it when
check_packageAbout to add, import, or recommend one dependency
check_dependenciesAbout to write a package.json or run an install command

As a CLI (for humans and CI)

npx pkgtruth check express unused-imports
npx pkgtruth scan .

scan reads every dependency in a package.json and exits non-zero when something is blocking, so it drops straight into CI:

- name: Block hallucinated and slopsquatted dependencies
  run: npx pkgtruth scan . --fail-on danger

What it checks

SignalMeaning
Not in registryThe name is fabricated. Nothing to install.
npm security placeholdernpm removed malicious code published under this name.
Impersonates a popular packageA near-identical name with a fraction of the adoption.
Install-time scriptspreinstall/install/postinstall run code on npm install.
DeprecatedUpstream says stop using it.
Very new / almost no adoptionDays old with single-digit installs.
No repositoryNo source to audit.
UnmaintainedNo release in years.

Verdicts are SAFE, CAUTION, DANGER, HALLUCINATED, or UNKNOWN. Every one arrives with the evidence behind it — an agent should never have to take "DANGER" on faith, and neither should you.

Design notes

Network failures never open the gate. If the registry is unreachable, the verdict is UNKNOWN, never SAFE. A degraded network must not silently turn a security check into a no-op.

Popular packages are not flagged. Checked against a real 18-dependency project, zero false positives. A gate that cries wolf gets switched off.

No build step. Two direct dependencies — the MCP SDK and zod, both only needed for the server. npx pkgtruth starts immediately.

Limitations

Read these before trusting it:

  • npm only. PyPI, crates.io, and Go modules are not covered yet.
  • Registry metadata only. It does not analyze package source code, so a legitimate-looking package with a malicious payload can still pass.
  • Not a replacement for npm audit or Snyk. Those find known CVEs in code you already trust. pkgtruth asks the earlier question: should this package be here at all?
  • New legitimate packages will get CAUTION. That is deliberate. Newness genuinely is a risk signal; use --fail-on danger so it does not block.

Options

--json              Machine-readable output
--fail-on <level>   danger (default) | caution

--fail-on caution also blocks packages that could not be verified at all, since "we could not check" is not a pass.

Exit codes: 0 clean, 1 blocking packages found, 2 usage or runtime error.

Configuration

VariableDefaultPurpose
PKGTRUTH_TIMEOUT_MS8000Per-request timeout
PKGTRUTH_RETRIES3Retries for 429/5xx/network errors
PKGTRUTH_MAX_CONCURRENCYper-hostOverride request pacing
PKGTRUTH_REGISTRYnpmAlternate registry
PKGTRUTH_DOWNLOADS_APInpmAlternate downloads API
PKGTRUTH_CACHE_DIR~/.cache/pkgtruthWhere adoption figures are cached
PKGTRUTH_DISK_TTL_MS6 hoursHow long a cached figure stays usable
PKGTRUTH_NO_DISK_CACHEunsetSet to 1 to disable the cache

On speed and rate limits

Adoption figures come from npm's downloads API, which throttles bursts and cannot batch scoped names — a project with several @scope/pkg dependencies would spend its whole budget on every scan.

Three things keep that in check: the bulk endpoint resolves all unscoped names in one request, requests to that host are paced serially, and figures are cached on disk for six hours. Weekly download counts move slowly, so a six-hour-old number is no less true.

A warm scan of ~18 dependencies takes about 1.4 seconds. A cold one after heavy use may return UNKNOWN for some packages — that is the intended failure mode. A throttled lookup never becomes SAFE; re-run, and the cache will answer.

Cached figures are keyed by the API they came from, so pointing PKGTRUTH_DOWNLOADS_API at a private registry never reuses npm's numbers.

Contributing

Issues and pull requests are welcome at github.com/hxckya/pkgtruth.

Two things make a report especially useful: a legitimate package that gets flagged, and a malicious one that slips through. Both are regression tests waiting to be written.

npm test                 # offline
npm run test:online      # includes live registry checks

License

MIT © hxckya

Reviews

No reviews yet

Be the first to review this server!