mcp-server-npm-registry
# mcp-server-npm-registry
Free MCP server for npm package intelligence: package metadata, search, download statistics, known security vulnerabilities, and browser bundle size. No API keys required — powered by four public APIs (npm Registry, npm Downloads API, OSV.dev, and Bundlephobia).
## Tools
| Tool | Purpose | Data Source |
|---|---|---|
| `get_package_info` | Get metadata, dependencies, dist-tags, types, and size for a package | npm Registry |
| `search_packages` | Search npm packages by keyword and qualifiers with quality/popularity scores | npm Registry |
| `get_download_stats` | Get total, daily average, and optional per-day download counts | npm Downloads API |
| `check_package_vulnerabilities` | Check a package version for known security advisories and CVEs | OSV.dev |
| `get_bundle_size` | Measure minified and gzipped browser bundle size and top dependencies | Bundlephobia |
## Requirements
- Node.js `>=18`
## Quick start
```bash
npx -y mcp-server-npm-registry
```
## Client configuration
### Claude Desktop
```json
{
"mcpServers": {
"npm-registry": {
"command": "npx",
"args": ["-y", "mcp-server-npm-registry"]
}
}
}
```
### Claude Code
```bash
claude mcp add npm-registry -- npx -y mcp-server-npm-registry
```
### MCP Inspector
```bash
npx @modelcontextprotocol/inspector node build/index.js
```
## Tool reference
### `get_package_info`
Parameters:
- `package_name` (`string`, required): npm package name, e.g. `"react"` or `"@types/node"`.
- `version` (`string`, optional, default `"latest"`): Exact version (e.g. `"18.2.0"`) or dist-tag (e.g. `"next"`). Defaults to `"latest"`.
Example output:
```json
{
"name": "left-pad",
"version": "1.3.0",
"description": "String left pad",
"license": "WTFPL",
"homepage": "https://github.com/stevemao/left-pad#readme",
"repositoryUrl": "https://github.com/stevemao/left-pad",
"keywords": ["leftpad", "pad", "padding"],
"author": "azer",
"maintainers": ["stevemao", "cnpm"],
"dependencies": { "is-number": "^7.0.0" },
"peerDependencies": {},
"dependencyCount": 1,
"distTags": { "latest": "1.3.0", "next": "2.0.0-beta.1" },
"deprecated": null,
"hasTypes": true,
"moduleType": "commonjs",
"nodeEngine": ">=0.10",
"unpackedSize": 4128,
"fileCount": 5,
"npmUrl": "https://www.npmjs.com/package/left-pad"
}
```
### `search_packages`
Parameters:
- `query` (`string`, required): Search text, e.g. `"http client"` or `"keywords:typescript author:sindresorhus"`.
- `limit` (`number`, optional, default `10`): Maximum results to return (1-25). Default 10.
- `offset` (`number`, optional, default `0`): Number of results to skip for pagination. Default 0.
Example output:
```json
{
"query": "express framework",
"total": 1234,
"offset": 0,
"returned": 1,
"results": [
{
"name": "express",
"version": "4.19.2",
"description": "Fast, unopinionated, minimalist web framework",
"keywords": ["express", "framework"],
"publishedAt": "2024-03-25T20:20:38.000Z",
"publisher": "wesleytodd",
"npmUrl": "https://www.npmjs.com/package/express",
"homepage": "http://expressjs.com/",
"repositoryUrl": "https://github.com/expressjs/express",
"scores": { "final": 0.923, "quality": 0.988, "popularity": 0.877, "maintenance": 1 }
}
]
}
```
### `get_download_stats`
Parameters:
- `package_name` (`string`, required): npm package name, e.g. `"react"` or `"@types/node"`.
- `period` (`string`, optional, default `"last-week"`): `"last-day"`, `"last-week"`, `"last-month"`, `"last-year"` or a custom range `"YYYY-MM-DD:YYYY-MM-DD"`. Default `"last-week"`.
- `include_daily` (`boolean`, optional, default `false`): Include a per-day breakdown. Only allowed for periods of 92 days or fewer. Default false.
Example output:
```json
{
"package": "left-pad",
"period": "last-week",
"start": "2024-05-01",
"end": "2024-05-07",
"totalDownloads": 70000,
"dayCount": 7,
"dailyAverage": 10000,
"daily": null
}
```
### `check_package_vulnerabilities`
Parameters:
- `package_name` (`string`, required): npm package name, e.g. `"lodash"` or `"@angular/core"`.
- `version` (`string`, optional, default latest): Exact version to check, e.g. `"4.17.15"`. Defaults to the latest published version.
Example output:
```json
{
"package": "lodash",
"version": "4.17.15",
"versionSource": "requested",
"checkedAt": "2026-01-01T00:00:00.000Z",
"totalVulnerabilities": 1,
"truncated": false,
"severityCounts": { "CRITICAL": 0, "HIGH": 1, "MEDIUM": 0, "LOW": 0, "UNKNOWN": 0 },
"vulnerabilities": [
{
"id": "GHSA-35jh-r3h4-6jhm",
"aliases": ["CVE-2021-23337"],
"cves": ["CVE-2021-23337"],
"summary": "Command Injection in lodash",
"severity": "HIGH",
"cvssVector": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H",
"published": "2021-05-06T16:05:51Z",
"modified": "2024-01-01T00:00:00Z",
"fixedIn": ["4.17.21"],
"url": "https://osv.dev/vulnerability/GHSA-35jh-r3h4-6jhm",
"references": ["https://nvd.nist.gov/vuln/detail/CVE-2021-23337"]
}
]
}
```
### `get_bundle_size`
Parameters:
- `package_name` (`string`, required): npm package name, e.g. `"react"` or `"@mui/material"`.
- `version` (`string`, optional, default latest): Exact version to measure, e.g. `"18.2.0"`. Defaults to the latest published version.
Example output:
```json
{
"package": "left-pad",
"version": "1.3.0",
"versionSource": "requested",
"sizeBytes": 2048,
"sizeFormatted": "2.0 KB",
"gzipBytes": 1024,
"gzipFormatted": "1.0 KB",
"dependencyCount": 1,
"hasJSModule": false,
"hasSideEffects": true,
"isModuleType": false,
"peerDependencies": [],
"topDependencies": [{ "name": "is-number", "approximateSizeBytes": 548 }]
}
```
## Data sources, caching and limits
No API keys are required. All requests use an 8-second timeout (`8000` ms) with no automatic retries.
- **npm Registry**: `https://registry.npmjs.org`
- **npm Downloads API**: `https://api.npmjs.org`
- **OSV.dev**: `https://api.osv.dev/v1/query`
- **Bundlephobia**: `https://bundlephobia.com/api/size`
| Cache | Duration | Rationale |
|---|---|---|
| Package metadata | 5 min (300,000 ms) | metadata changes on publish |
| Search results | 2 min (120,000 ms) | rankings drift |
| Download stats | 1 h (3,600,000 ms) | counts update daily |
| OSV vulnerabilities | 30 min (1,800,000 ms) | new advisories appear during the day |
| Bundlephobia size | 24 h (86,400,000 ms) | exact-version builds are immutable |
Note: Bundlephobia first-time builds of a package can be slow and may exceed the 8-second timeout; all four services may rate-limit requests.
## Development
Scripts:
- `npm run clean`: Remove `build/`
- `npm run build`: Compile TypeScript to `build/`
- `npm run typecheck`: Type-check `src/` and `tests/`
- `npm test`: Run Vitest unit and integration tests
- `npm start`: Start the stdio MCP server (`node build/index.js`)
Project layout:
```
mcp-server-npm-registry/
├── .github/workflows/ci.yml
├── src/
│ ├── constants.ts
│ ├── index.ts
│ ├── server.ts
│ ├── types/index.ts
│ ├── utils/
│ ├── services/
│ └── tools/
├── tests/
├── LICENSE
├── README.md
├── package.json
├── tsconfig.json
├── tsconfig.test.json
└── vitest.config.ts
```
## License
MIT
TDQS
Scored across 5 tools
Each tool targets a distinct facet of the npm ecosystem: single-package metadata, keyword search, download counts, vulnerability advisories, and bundle size. There is no realistic way to confuse one with another, and descriptions reinforce the boundaries (e.g. 'one specific package' vs. 'search by keyword').
All names are snake_case verb_noun forms: get_package_info, search_packages, get_download_stats, check_package_vulnerabilities, get_bundle_size. The verbs (get/search/check) vary slightly but map naturally to the action type without breaking the pattern.
Five focused tools is a well-scoped surface for a read-only registry inspection server; each tool covers a genuinely different question an agent would ask. Nothing feels padded or redundant.
The core read-only lifecycle is covered: discovering packages, inspecting metadata, gauging adoption, assessing security, and evaluating browser cost. Minor gaps exist (no version history/dependency tree or package comparison), but agents can work around these via get_package_info and search.