# npm Package Health (`tankster_ai/npm-package-health`) Actor

Check up to 1,000 npm packages per run for deprecation, known vulnerabilities, licence, maintainers, download volume and staleness, with a risk score for each. Also works as an MCP tool for AI agents.

- **URL**: https://apify.com/tankster_ai/npm-package-health.md
- **Developed by:** [Tankster AI](https://apify.com/tankster_ai) (community)
- **Features:** Limited permissions, Single-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 package health reports

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## npm Package Health and Vulnerability Checker

**Is this npm package safe to depend on?** This Actor answers with one health report per package, built only from public data: whether the version you use is **deprecated**, when the package was **last published**, how many **maintainers** it has, its **licence** and **source repository**, whether it ships **TypeScript types**, its **weekly downloads**, the **known vulnerabilities** of that exact version from [OSV.dev](https://osv.dev) (with IDs, severity and the versions that fix them), and a simple **risk score** that lists every point it adds.

Use it two ways:

- 📋 **Batch run**: paste up to 1,000 package names and get one dataset row per package, ready to export as JSON, CSV or Excel.
- 🤖 **MCP server for AI agents**: your coding agent calls `check_package` or `check_packages` before it adds or upgrades a dependency.

### What does each report contain?

| Field | What it means |
|---|---|
| `version`, `latestVersion`, `isLatest` | The version checked (the one you named, a dist-tag's version, or the latest) and the latest |
| `deprecated`, `deprecationMessage` | npm's deprecation flag and message for the checked version |
| `latestDeprecated`, `latestDeprecationMessage` | The same for the latest version: in practice, whether the whole package is deprecated |
| `versionPublishedAt`, `latestPublishedAt`, `lastPublishedAt`, `daysSinceLastPublish` | Publish dates; the last publish counts any version, prereleases included |
| `maintainersCount` | Maintainers listed in the npm registry |
| `license`, `repositoryUrl` | The licence the checked version declares (`license`, or the older `licenses` field) and the source repository |
| `types`, `typesPackage` | `bundled` (the package declares its own types), `definitelytyped` (an `@types` package exists) or `none` |
| `weeklyDownloads` | Downloads in the last 7 days npm has data for |
| `vulnerabilities`, `vulnerabilityCount`, `vulnerabilityCounts`, `malicious` | Known vulnerabilities of this version from OSV.dev: ID, aliases (CVE), summary, severity, CVSS v3 score, the version that fixes the range this version is in, a link, and the advisory's `source` (its database and licence) |
| `vulnerabilityDataNotice` | Credit and licences for the advisory data, on every report that has any (see [Data sources and licences](#data-sources-and-licences)) |
| `riskScore`, `riskLevel`, `riskFactors` | The risk score below, with each factor's points and reason |

A package that cannot be checked gets an **error item** instead, with `status: "error"`, an `error` code and a plain `message`: `invalid_name`, `invalid_version`, `not_found`, `unpublished`, `version_not_found`, `no_versions`, `packument_too_large`, `answer_too_large` (an OSV or downloads answer over 16 MiB), `internal_error` (the Actor failed on this package; retry), `upstream_unavailable` (retry later) or `upstream_bad_response`. **Error items are free.**

Inputs that resolve to the same version (`react`, `react@latest` and `react@19.3.1`, when 19.3.1 is the latest) are one report and one charge. In a batch run the later ones are listed in the `OUTPUT` record's `duplicates`; in `check_packages` they come back as `status: "duplicate"` items, free.

### How to run a batch

Put package names in **Packages**, one per line. Add `@version` for an exact version or a dist-tag (`lodash@4.17.21`, `next@canary`); leave it out for the latest. Version ranges such as `^1.2.0` are not accepted, because a report is about one version. Duplicates are checked once.

```json
{ "packages": ["react", "express@4.17.1", "lodash@4.17.20", "request", "typescript"] }
```

The dataset has one item per unique package, in the order you gave them. The **Overview** view shows one row per package; the **Vulnerabilities** view shows one row per advisory. The run's `OUTPUT` record summarises how many packages were reported and how many were error items.

#### Example report (shortened)

```json
{
  "status": "ok",
  "input": "lodash@4.17.20",
  "name": "lodash",
  "version": "4.17.20",
  "latestVersion": "4.18.1",
  "deprecated": false,
  "maintainersCount": 1,
  "license": "MIT",
  "types": "definitelytyped",
  "typesPackage": "@types/lodash",
  "weeklyDownloads": 211307245,
  "vulnerabilityCount": 4,
  "vulnerabilities": [{
    "id": "GHSA-35jh-r3h4-6jhm",
    "aliases": ["CVE-2021-23337"],
    "summary": "Command Injection in lodash",
    "severity": "high",
    "cvssScore": 7.2,
    "fixedVersions": ["4.17.21"],
    "url": "https://osv.dev/vulnerability/GHSA-35jh-r3h4-6jhm"
  }],
  "riskScore": 61,
  "riskLevel": "high",
  "riskFactors": [
    { "factor": "known_vulnerabilities", "points": 56, "detail": "Known vulnerabilities in this version: 2 high, 2 moderate" },
    { "factor": "single_maintainer", "points": 5, "detail": "One maintainer" }
  ]
}
```

### How the risk score works

The score is the sum of these points, capped at 100. Every point added is listed in `riskFactors` with its reason, so you can check it or apply your own rules to the raw fields.

| Factor | Points |
|---|---|
| `malicious`: an advisory says this version contains malicious code | 100 |
| `known_vulnerabilities`: per critical / high / moderate / low / unknown-severity advisory | 35 / 20 / 8 / 2 / 8 (at most 60 in total) |
| `package_deprecated`: the latest version is deprecated | 30 |
| `version_deprecated`: the checked version is deprecated with its own message (not the same message as the deprecated latest, which `package_deprecated` already counts) | 20 |
| `stale_2_years`: no version published for over 2 years | 15 |
| `stale_4_years`: no version published for over 4 years (instead of the above) | 25 |
| `no_maintainers`: no maintainers listed | 10 |
| `single_maintainer`: one maintainer | 5 |
| `no_license`: no licence declared | 10 |
| `no_repository`: no source repository declared | 5 |
| `low_downloads`: under 1,000 downloads last week | 5 |

Levels: below 25 is `low`, below 50 `medium`, below 75 `high`, and 75 or more `critical`. The score is a triage aid built from public metadata and known advisories. It is not a security audit, and a low score does not prove a package is safe.

Severity comes from the advisory's label (GitHub's critical, high, moderate, low). When an advisory has no label but has a CVSS v3 vector, the Actor computes the base score and rates it with the CVSS bands. Otherwise it is `unknown`.

### How to connect an AI agent (MCP)

This Actor also runs in **Standby mode** as an MCP server. Point your MCP client at:

```
https://<username>--npm-package-health.apify.actor/mcp
Authorization: Bearer <your Apify API token>
```

Apify Console shows the exact URL in the Actor's **Server** tab. For example, in Claude Code:

```
claude mcp add --transport http npm-health https://<username>--npm-package-health.apify.actor/mcp --header "Authorization: Bearer <your Apify API token>"
```

Two tools, both **read-only**:

- 🔍 **`check_package`**: one package, as `name` or `name@version`. Returns the report above.
- 📦 **`check_packages`**: up to 50 packages in one call. Returns one result per unique package, in order.

### Pricing

You pay per package reported (pay per event):

| Event | Price | When |
|---|---|---|
| `package-report` | **$0.003** | One package reported: a dataset item in a batch run, or a report returned by an MCP tool |

So 1,000 package reports cost $3 in report events, plus platform usage.

- **Free:** error items (an invalid name, a package or version that does not exist, a source that is unavailable), and any refused call.
- **Platform usage:** runs use 512 MB of memory by default. A batch of the five example packages takes a few seconds. In Standby, your server runs **in your own Apify account (single-tenant)**, so you also pay for its runs while they are up, including while they wait for requests until the idle timeout stops them. To change the idle timeout or the memory, open the Actor in Apify Console, select **Save as a new task**, change the task's **Settings**, and connect your MCP client to the task's hostname instead of the Actor's.
- **Run start:** if the Actor's pricing includes Apify's standard start event, it costs $0.00005 per run start at this Actor's memory (one event per start up to 1 GB).

#### Spending limits

- **Batch runs:** set the run's maximum cost. Before each package is looked up, the Actor checks that the limit can pay for its report. When it cannot, the run stops: the packages not yet checked are listed in the `OUTPUT` record (`notChecked`) and the status message, and nothing more is looked up or charged. The budget goes to the first packages in your list.
- **MCP calls:** the limit applies per run. Standby may start more runs (when one run is busy, after an idle timeout, or to replace a run), and each new run has its own limit. When the run you reach has spent its limit, paid calls are refused with `spending_limit` and nothing is charged. A `check_packages` call needs budget for every package in it; if it asks for more, it is refused and says how many the run can still take.
- **Your account's monthly usage hard limit** caps spending across all runs.

#### When something is wrong on Apify's side

- **Charge not confirmed:** once the Actor has sent a charge, Apify may apply it even if its answer is lost. So if Apify does not confirm a charge within a few seconds, the MCP reports are delivered with a `billingNotice` of `charge_unconfirmed`: the call may have been charged. If you were charged for something you did not receive, contact us with the run ID. A batch run stops instead of continuing; the report being saved when it happened is in the dataset, and the `OUTPUT` record names it (`chargeUnconfirmed`).
- **Billing unavailable:** if the Actor cannot even start a charge, no charge is sent: the reports are withheld with `billing_unavailable` and not charged. Retry in a minute.
- **Pricing or setup misconfigured:** if the Actor's pricing does not price the `package-report` event, or the Actor is not single-tenant, paid calls are refused with `pricing_misconfigured` or `tenancy_misconfigured` and nothing is charged. A batch run also refuses to start, charging nothing, if the pricing charges for every dataset item (which would charge the free error items).

### Where the data comes from

Only public, logged-out sources, through their documented public APIs, with no API keys:

- **npm registry** (`registry.npmjs.org`): the package's metadata, and the `@types` package's latest version.
- **npm downloads API** (`api.npmjs.org`): weekly downloads. Up to 128 unscoped packages share one bulk request, the documented limit.
- **OSV.dev** (`api.osv.dev`): known vulnerabilities for one package version, every page of the answer.

The Actor sends an identifying User-Agent, limits how many requests it makes to each source at once, retries failures with backoff, waits as long as a source asks with `Retry-After` (or gives up if that is more than 20 seconds), and reuses each answer for 5 minutes within a run. Each package costs at most two registry requests, one OSV request (more only when OSV pages a very long answer), and a share of one downloads request (one whole request for a scoped package).

### Data sources and licences

- **npm registry and downloads API:** used under the [npm Open-Source Terms](https://docs.npmjs.com/policies/open-source-terms), which allow the public APIs and rule out unreasonable volumes, naming 5,000,000 requests a month by any single individual, organization or group as clearly too many. That line applies to this Actor's whole operation, all users' runs together, not to one run. So each run sends at most 10,000 requests to npm (registry and downloads API together; a 1,000-package batch needs about 2,200), and a package checked after that gets a free, retryable `upstream_unavailable` item. We watch the total across runs and will contact npm before it comes near the line.
- **OSV.dev:** the vulnerability data. OSV.dev aggregates several databases, each under its own licence, as listed on its [data sources page](https://google.github.io/osv.dev/data/). npm advisories come from:
  - the **GitHub Advisory Database**, © GitHub, Inc., licensed [CC-BY 4.0](https://creativecommons.org/licenses/by/4.0/) (`GHSA-` IDs);
  - **OpenSSF Malicious Packages**, licensed [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0) (`MAL-` IDs).
- **What this Actor changes:** advisory IDs, aliases and summaries are reproduced unmodified. Severity labels are read from the advisory, and so are CVSS vectors. The CVSS base score, the fixed versions that apply to your version, and the risk score are derived by this Actor. Each vulnerability's `source` names its database, licence and link. Every report that carries advisory data repeats this credit in `vulnerabilityDataNotice`.

### Limits

- **1,000 packages** per batch run and **50 packages** per `check_packages` call.
- **Types** are read from `package.json` fields (`types`, `typings`, a `types` export condition) and DefinitelyTyped. When DefinitelyTyped's `@types` package is a stub saying the package ships its own types (as for TypeScript), the types count as `bundled`. A package that ships `.d.ts` files without declaring them, and has no such stub, shows `none` or `definitelytyped`.
- **Vulnerabilities** are what OSV.dev knows for that exact version. A clean result means no known advisory, not proof of safety.
- **Downloads** cover the last 7 days npm has data for (usually up to yesterday, UTC). A package npm has no download data for shows 0.
- **Package metadata over 64 MiB** is not read, and the package gets a `packument_too_large` error item. Most packages are far smaller, but a few with thousands of versions are not: in November 2026, `renovate`'s metadata was about 76 MB (over the limit), `vite`'s about 39 MB and Next.js's about 31 MB. Metadata over 8 MiB is read one package at a time, so large ones cannot exhaust the run's memory together.

### FAQ

**Does it need my npm token or any account?** No. It reads only public data, and it never logs in anywhere.

**Why is my version "not found"?** The registry has no such version or dist-tag. npm removes malicious versions, so an old version can disappear (for example `event-stream@3.3.6`).

**Can I check a private package?** No. Private packages need a login, and this Actor never uses one.

**Why does a package with no known vulnerabilities still score above 0?** Other factors add points too: deprecation, no publish for years, one maintainer, no licence or repository, or low downloads. `riskFactors` lists them.

# Actor input Schema

## `packages` (type: `array`):

npm package names, one per line, each optionally with an exact version or a dist-tag: react, @types/node, lodash@4.17.21, next@canary. Without a version the latest is checked. Ranges such as ^1.2.0 are not accepted. Up to 1,000 packages; duplicates are checked once.

## Actor input object example

```json
{
  "packages": [
    "react",
    "express@4.17.1",
    "lodash@4.17.20",
    "request",
    "typescript"
  ]
}
```

# Actor output Schema

## `reports` (type: `string`):

One item per unique package in the input, in input order: a health report or an error item.

## `summary` (type: `string`):

How many packages were reported (charged) and how many were error items (free), the packages not checked if the run stopped at its spending limit, and why it stopped.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "packages": [
        "react",
        "express@4.17.1",
        "lodash@4.17.20",
        "request",
        "typescript"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("tankster_ai/npm-package-health").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "packages": [
        "react",
        "express@4.17.1",
        "lodash@4.17.20",
        "request",
        "typescript",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("tankster_ai/npm-package-health").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "packages": [
    "react",
    "express@4.17.1",
    "lodash@4.17.20",
    "request",
    "typescript"
  ]
}' |
apify call tankster_ai/npm-package-health --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,tankster_ai/npm-package-health"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/M2BZZVe6rZJdc9ri7/builds/hvPfL5PNhMzhJ4RV0/openapi.json
