PkgDiet
This server lets you evaluate npm dependencies before installation, get curated alternatives, and view the active project policy.
check_dependency: Check a single package for health, risk, and cost before installing.suggest_alternative: Get a lighter, healthier alternative for a package.get_policy: Retrieve the active PkgDiet dependency policy for the repository.
Enables CI/CD integration to parse package-lock.json diffs and block pull requests that introduce unhealthy dependencies.
Provides dependency intelligence for npm packages, enabling package health, size, maintenance, and alternative recommendations before installing or replacing dependencies.
π₯ PkgDiet
Dependency policy for AI-assisted JavaScript and TypeScript development.
The Problem: AI coding agents frequently hallucinate legacy, deprecated, or bloated npm packages (like request, moment, or obsolete TS typings) because their training data heavily favors older, ubiquitous libraries.
The Solution: PkgDiet is a deterministic guardrail. It checks proposed dependencies against registry health, deprecation status, and local project policy before they are installed, forcing agents to pivot to modern alternatives.
PkgDiet is local-first and opt-in. MCP provides guidance to AI clients; CI is the enforcement backstop.
PkgDiet's MCP server is listed on Glama. Ratings and directory metadata may change independently of this repository release. The Glama listing is not a security certification.
Quick Start
Evaluate a package before installing:
npx -y pkgdiet@2.0.1 check request momentRun the MCP server for your AI Agent:
npx -y pkgdiet@2.0.1 mcp(See All commands below for audit, ci, setup, and more)
Related MCP server: dependency-health-mcp
What PkgDiet does
Checks packages against a local
.pkgdietrc.jsonpolicy.Reports
ALLOW,WARN, orBLOCKverdicts.Uses available npm metadata: publish date, download trends, maintainer count, TypeScript coverage, and deprecation status.
Flags configured internal-name prefixes that may indicate dependency confusion attacks.
Suggests curated alternative candidates for selected packages.
Evaluates supported lockfile changes in CI pull requests.
Exposes read-only tools through a local MCP server for compatible AI clients.
Provides an internal-beta VS Code extension.
What PkgDiet does not cover
PkgDiet is not a security scanner. It reads public npm metadata and applies a local policy β it cannot confirm:
Whether a package contains malicious code.
Whether a package has known CVEs.
Whether a package's source is trustworthy.
Whether a package is compatible with your project.
Whether a package has had its supply chain compromised.
PkgDiet does not replace:
Vulnerability scanners: PkgDiet checks for package health, deprecation, and modernization (e.g., swapping
requestforundici). Tools likenpm auditcheck for known CVE vulnerabilities in packages you've already installed. Use both together.Code review & maintainer due diligence.
Lockfile integrity controls & package provenance review.
Secure CI configuration.
MCP tools provide guidance to compatible clients. They do not force an AI client to call a tool or follow its result.
What happens after setup?
PkgDiet creates or updates only the files shown in its confirmation preview. In a project, the normal workflow is:
.pkgdietrc.jsonstores the project policy.pkgdiet check <package>evaluates a package before installation.A compatible MCP client can call the same policy tools automatically.
The optional VS Code extension shows package diagnostics in
package.json.GitHub Actions enforces policy on dependency changes in PRs.
The policy file and CI workflow can be committed so the whole team shares them.
MCP is optional. CI enforcement works even when no AI client is configured.
How adoption works
Run
pkgdiet setupin a project β it previews every change and asks before writing.Review the proposed
.pkgdietrc.jsonand any optional integration files.Confirm the changes.
Configure a compatible MCP client with
pkgdiet agent-setup, if desired.Add the PkgDiet GitHub Action for CI enforcement.
Commit
.pkgdietrc.jsonand the workflow so the whole team shares the same policy.
MCP is optional. The CI gate works independently, so dependency policy can be enforced even when no AI client is configured.
Enterprise Rollout
You cannot force-enable PkgDiet globally across an organization via hidden hooks. PkgDiet is designed as a transparent, opt-in layer.
For organizational deployment (MDM payloads, reusable CI workflows, and global MCP settings), see the Enterprise Adoption Guide.
Example output
π‘ moment
Health: 100/100
Verdict: WARN
Reasons: Efficiency Flag β Better alternatives exist for moment.
Added Size: 4.29 MB
Alternatives: dayjs, date-fns, luxon
π΄ request
Health: 15/100
Verdict: BLOCK
Reasons: Health score below minimum (60). Package is deprecated.
Alternatives: undici, native fetch, axios, ky
π’ @babel/parser
Health: 94/100
Verdict: ALLOW
Added Size: 1.77 MBJSON output shape (pkgdiet check moment --json):
{
"name": "moment",
"verdict": "WARN",
"healthScore": 100,
"efficiencyFlag": true,
"alternatives": [
{ "replacement": "dayjs", "message": "Moment.js is in maintenance mode..." }
],
"costEstimate": {
"addedSizeMB": 4.29,
"ciInstallTimeSeconds": 0.09,
"monthlyCiCost100Builds": 0.036,
"serverlessColdStartClass": "10-50ms"
},
"flags": [],
"hasProvenance": false,
"integrityCheck": "missing",
"certified": false
}Field notes:
certified: falseβ indicates whether the package satisfied the configured certification conditions in your policy. It is not a universal safety certification.hasProvenance: falseβ indicates whether the inspected npm metadata included the provenance signal that PkgDiet checks. It is not a complete supply-chain attestation. Do not treat either field alone as a pass/fail security verdict.
MCP tools (for AI agents)
Tool | Purpose |
| Evaluate one package against the active policy |
| Evaluate multiple packages with bounded concurrency |
| Return curated replacement candidates |
| Return the effective policy and its validation status |
Manual MCP config (paste into your agent's config file):
{
"mcpServers": {
"pkgdiet": {
"command": "npx",
"args": ["-y", "pkgdiet@2.0.1", "mcp"]
}
}
}Or use the setup command to configure supported agents in the current project:
npx pkgdiet@2.0.1 agent-setup --detectThis previews and confirms before writing any configuration file.
Policy
Create .pkgdietrc.json in your project root, or run npx pkgdiet setup:
{
"minHealthScore": 70,
"blockDeprecated": true,
"internalNamePrefixes": ["@myorg/"],
"blockedPackages": ["request", "node-uuid"],
"environments": {
"ci": {
"minHealthScore": 80,
"failOn": "WARN"
}
}
}See docs/POLICY.md for the full schema reference.
All commands
Command | Purpose |
| Verdict for one or more packages |
| Full project audit β unused, unhealthy, oversized |
| Machine-readable JSON to stdout, diagnostics to stderr |
| Interactive policy and integration setup with confirmation |
| Configure MCP for supported AI agents in the project |
| Start the MCP server over stdio |
| CI gate β evaluate new dependencies in a PR |
| Validate your |
| Browse curated replacements |
| Detect health degradation in installed dependencies |
Setup vs Init:
setupis the interactive wizard that prompts you for policy and agent selections.initis the non-interactive, all-in-one setup command. Both commands preview the exact files they will create or update and ask for confirmation before writing.CI command:
pkgdiet cicompares the current lockfile with a base Git ref and evaluates newly added dependencies. It does not replacepkgdiet audit(which checks all dependencies).
CI / GitHub Actions
name: PkgDiet Dependency Gate
on:
pull_request:
branches: [main]
paths: [package.json, package-lock.json, yarn.lock, pnpm-lock.yaml]
permissions:
contents: read
jobs:
dependency-policy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with: { fetch-depth: 0 }
- run: npx -y pkgdiet@2.0.1 ci --base HEAD~1 --env ciOr use the reusable GitHub Action:
- uses: om-tajne/pkgdiet@v2
with:
base: ${{ github.event.pull_request.base.sha }}
environment: ci
fail-on: BLOCKSee docs/CI.md for all options and exit codes.
Requirements
Node.js 20 or later
npm, yarn, or pnpm project
Network access for registry health checks (can be disabled with
PKGDIET_NO_NETWORK=1)
Privacy and network behavior
PkgDiet does not require a PkgDiet account or hosted backend for the CLI, Core, or local MCP workflow.
When network checks are enabled, PkgDiet sends only the package name being evaluated to public npm registry and download-statistics endpoints (registry.npmjs.org, api.npmjs.org). It does not upload project source files, private policy contents, or any other project data.
Results may be cached locally in .pkgdiet-cache.json (24 h TTL by default). Local metrics, when enabled, are stored in .pkgdiet-metrics.json and are not sent to any PkgDiet server.
Disable network requests:
PKGDIET_NO_NETWORK=1 npx pkgdiet auditDisable local telemetry/metrics:
PKGDIET_TELEMETRY_DISABLED=1 npx pkgdiet auditor in .pkgdietrc.json:
{ "telemetry": false }If your project uses private or internal package names, note that those names may be sent to public npm endpoints when evaluating health. Teams in regulated environments should review this behavior before enabling network checks.
Integration status
Integration | Status |
Generic MCP stdio client | Supported |
Cursor | Tested configuration |
Claude Desktop | Tested configuration |
Cline | Tested configuration |
Antigravity | Tested configuration |
Windsurf | Rules integration only ( |
GitHub Copilot | Configuration generated; live client validation pending |
Claude Code | Tested configuration |
GitHub Action | Supported |
VS Code extension | Internal beta |
GitHub App | Experimental |
Dashboard | Experimental |
See docs/INTEGRATIONS.md for configuration paths and details.
Documentation
docs/POLICY.mdβ.pkgdietrc.jsonschema referencedocs/MCP.mdβ MCP tools and client setupdocs/CI.mdβ GitHub Action, CI command, and exit codesdocs/ARCHITECTURE.mdβ Technical architecturedocs/INTEGRATIONS.mdβ Tested client support matrixSECURITY.mdβ Private vulnerability reportingCHANGELOG.mdβ Version history and breaking changes
License
MIT β see LICENSE.
Available Tools
3 toolscheck_dependencyA
Check a dependency (e.g. npm package) for health, risk, and cost before installing.
| Name | Required | Description | Default |
|---|---|---|---|
| package | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden of disclosing behavior. The phrasing 'check ... before installing' implies a read-only, non-mutating operation, which is useful. However, it does not describe the output format, whether the check contacts a registry/network, auth requirements, or possible side effects.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single sentence with no filler. It front-loads the operation, states the resource, and enumerates what is checked. Every word contributes to the agent's understanding.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The tool is simple (one required string, no nested objects), and the description covers what it checks and when to use it. However, since there is no output schema, the description should say more about what the agent will receive back; 'health, risk, and cost' implies the result dimensions but not their shape or interpretation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema only declares 'package' as a required string with no description. The tool description adds meaning by identifying the value as a dependency such as an npm package. It does not, however, specify accepted formats (e.g. bare name vs. versioned specifier), so it only partially compensates for 0% schema description coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'Check' and the resource 'a dependency', and it names the evaluation dimensions: health, risk, and cost. It also gives an example ('npm package') and a usage stage ('before installing'). It stops short of 5 because it does not explicitly contrast this tool with its siblings suggest_alternative and get_policy.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
'before installing' provides clear usage context: this is a pre-install evaluation tool. It does not, however, state when not to use it or explicitly point to suggest_alternative or get_policy as alternatives, so it misses the highest bar.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_policyA
Get the active PkgDiet dependency policy for this repository.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
There are no annotations, so the description itself must convey behavior. 'Get' clearly signals a read-only retrieval, and the zero-parameter shape means there is no input-triggered side-effect risk. It does not disclose error or missing-policy behavior, but for a simple getter this is mostly sufficient.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single concise sentence that immediately states the action, target, and scope. There is no filler, repetition, or unnecessary detail.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a zero-parameter, no-output-schema getter, the description is sufficiently complete: an agent can invoke it without further setup and can infer that the return value is the active policy. No additional prerequisites or edge cases are necessary to understand the call.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has zero parameters and the schema description coverage is effectively 100%. The baseline for a zero-parameter tool is 4, and the description adds no conflicting or missing parameter information.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb ('Get') and a clearly identified resource ('active PkgDiet dependency policy for this repository'). This is distinct from the sibling tools check_dependency and suggest_alternative, which imply different actions.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies that this tool should be used when the active policy needs to be retrieved, and it scopes that to 'this repository.' However, it provides no explicit guidance about when to choose this tool over check_dependency or suggest_alternative.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
suggest_alternativeC
Suggest a lighter, healthier alternative for a package.
| Name | Required | Description | Default |
|---|---|---|---|
| package | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of disclosing behavior. It only states the action and gives no indication of side effects, whether this is read-only, or what the output looks like.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single concise sentence with the action and object front-loaded. The qualifiers 'lighter, healthier' add some vagueness but do not make the description bloated.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
With no annotations and no output schema, the description leaves the return format, input semantics, and behavioral context mostly unspecified. It is enough to guess the intent, but not sufficient for confident, correct invocation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, and the description only references 'a package' without clarifying the expected format, allowed values, or examples. It minimally confirms that the package is the input, but does not meaningfully compensate for the missing schema documentation.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb ('Suggest') and names a clear target ('lighter, healthier alternative for a package'), so the tool's basic purpose is understandable. It does not explicitly differentiate from sibling tools, but the intent is not ambiguous.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is no explicit guidance on when to use this tool versus alternatives like check_dependency or get_policy. The only usage signal is implied by the verb 'Suggest,' which is not enough for reliable tool selection.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
3 tool updates
v1.2.1- First observed
check_dependency - First observed
get_policy - First observed
suggest_alternative
TDQS
Scored across 3 tools
Each tool targets a distinct action: evaluating a dependency, suggesting an alternative, and retrieving policy. There is no overlap in purpose, so an agent can easily select the right tool.
All tool names follow a consistent verb_noun snake_case pattern (check_dependency, suggest_alternative, get_policy). The naming is predictable and uniform.
With only 3 tools, the set is tightly scoped to the domain of dependency health analysis. Each tool serves a clear, non-redundant purpose and fits within the ideal 3-15 tool range.
The tool surface covers checking, suggesting alternatives, and viewing policy, which supports a typical dependency-review workflow. A minor gap is the absence of any policy update or management tool, but this may be intentionally out of scope.
Maintenance
Related MCP Connectors
Packagephobia MCP β install-size analysis for npm packages
Provide AI-powered real-time analysis and intelligence on NPM packages, including security, dependβ¦
Detect malicious or vulnerable npm packages: registry search, OSV.dev and GitHub advisory lookups
Package intelligence for AI agents across npm, PyPI, crates.io and deps.dev. No API keys.
Related MCP Servers
- AlicenseAqualityAmaintenanceAudits local package folders to generate publish-readiness reports and previews of NPM tarball contents. It helps developers identify and resolve configuration issues like missing types or broken exports before releasing code.371 npmMIT
- AlicenseNot gradedqualityDmaintenanceMonitors and analyzes dependency health in Node.js projects, providing tools to check outdated packages, vulnerabilities, licenses, and suggest safe upgrades.8 npmMIT
- AlicenseAqualityFmaintenanceDependency security & health auditing for AI agents with no account or API key required.22MIT
- FlicenseAqualityCmaintenancePackage intelligence for AI coding agents that checks npm and PyPI package health, deprecation, vulnerabilities, bundle size, and compares alternatives.5-