npm-mcp
npm-mcp is an MCP server that lets an AI assistant manage npm packages and projects through npm CLI operations.
Publish, version, unpublish, and deprecate packages; preview publish contents with
pack.Search the registry and view package info, bugs/repo/docs URLs, and diffs between versions.
Manage owners, dist-tags, access levels, tokens, profile settings, and read-only npm config.
Install, uninstall, update, list, audit, prune, dedupe, link, explain, fund, and query dependencies.
Run CI clean installs and package.json scripts.
Run security audits/fixes, generate SBOMs, check registry connectivity, diagnose npm health, and manage cache.
Initialize package.json and get/set/delete package.json fields programmatically.
Authenticate via
NPM_TOKENor local npm login, with OTP support for 2FA operations.
Provides a comprehensive set of tools for managing npm packages, allowing AI assistants to publish packages, bump versions, search the registry, perform security audits, and manage project dependencies directly through the npm registry.
npm-mcp
MCP server that lets AI assistants manage npm packages. Publish, version, search, audit, install, and more -- all through Claude Code or any MCP client.
The MCP server requires Node.js 20 or newer. Individual npm CLI features may require a newer Node.js/npm combination as noted below.
When to Use
Task | Tool |
"Publish this package to npm" |
|
"Check for outdated dependencies" |
|
"Run a security audit on my packages" |
|
"Search npm for authentication libraries" |
|
"Bump the version and publish" |
|
"Check who owns this npm package" |
|
"View download stats for my package" |
|
For AI agents: See
llms.txtfor a machine-readable summary. Copytemplates/CLAUDE.mdortemplates/AGENTS.mdinto your project to teach your agent about this MCP.
Related MCP server: mcp-server-npm-plus
Why
You're in Claude Code building a library. You finish the code, and now you need to publish it. Instead of switching to a terminal:
You: publish this package to npm with public access
Claude: [calls publish tool] Published @yourorg/lib@1.0.0 successfullyThat's it. No context switching.
Setup
1. Install
git clone https://github.com/mikusnuz/npm-mcp.git
cd npm-mcp
npm install
npm run build2. Get npm token
Go to npmjs.com > Account > Access Tokens and create a
granular access token with access to the packages you need. Classic and
Automation tokens are no longer supported. A stage-only token uses the stage
workflow below. Existing npm login credentials also work.
3. Add to Claude Code
Edit ~/.claude/settings.json:
{
"mcpServers": {
"npm-mcp": {
"command": "node",
"args": ["/path/to/npm-mcp/dist/index.js"],
"env": {
"NPM_TOKEN": "npm_xxxxxxxxxxxx"
}
}
}
}Or if you've already run npm login locally, skip NPM_TOKEN -- it uses your ~/.npmrc automatically.
Tools
Publishing & Versioning
Tool | Description |
| Publish a package to npm registry |
| Stage, list, inspect, download, approve, or reject a pending package version |
| Bump package version (patch/minor/major/pre*) |
| Remove a package version |
| Deprecate a version (or undeprecate with empty message) |
| Preview what would be published |
Package Info
Tool | Description |
| View package info from registry |
| Search npm registry |
| Get bug tracker URL for a package |
| Get repository URL for a package |
| Get documentation URL for a package |
| Show diff between package versions |
Dependency Management
Tool | Description |
| Install packages |
| List unreviewed dependency install scripts without changing policy (npm 12+) |
| Approve named, reviewed dependencies with version pinning (npm 12+) |
| Deny install scripts for named dependencies across versions (npm 12+) |
| Remove packages |
| Update packages to latest semver-compatible version |
| Check for outdated packages |
| List installed packages |
| Explain why a package is installed |
| Reduce duplication in dependency tree |
| Remove extraneous packages |
| Show funding info for dependencies |
| Query packages using CSS-like selectors |
Security & Diagnostics
npm 12 blocks unapproved dependency install scripts. Call pending-scripts with
an absolute project path, review the packages, then pass explicit package names
to approve-scripts or deny-scripts. These commands update policy without
running scripts; rerun the intended install/build separately. There is no bulk
approval option. npm pins approvals when a trusted resolved version is available;
check its warnings if an older lockfile forces a name-only approval. For global
installs only, install.allowScripts accepts an explicit list of reviewed names.
Older npm versions do not support these options; select npm 12+ using NPM_PATH.
See npm script approval.
Tool | Description |
| Run security audit (with optional auto-fix) |
| Generate Software Bill of Materials (CycloneDX/SPDX) |
| Check npm environment health |
| Check registry connectivity |
Configuration & Auth
Tool | Description |
| Check current authenticated user |
| Manage access tokens (list/revoke) |
| Set or view access level on packages |
| Manage package owners (ls/add/rm) |
| Manage distribution tags (ls/add/rm) |
| View or modify npm profile settings |
| View npm configuration (read-only) |
Project Setup
Tool | Description |
| Initialize a new package.json |
| Manage package.json fields programmatically |
| Clean install from lockfile (for CI) |
| Run scripts defined in package.json |
| Symlink a local package for development |
| Manage the npm cache |
Examples
Publish a scoped package:
publish({ path: "/home/user/my-lib", access: "public" })Bump version and publish:
version({ path: "/home/user/my-lib", bump: "patch" })
publish({ path: "/home/user/my-lib" })Check what's inside before publishing:
pack({ path: "/home/user/my-lib", dryRun: true })Search for existing packages:
search({ query: "react state management", limit: 5 })View package details:
view({ package: "@yourorg/lib", field: "versions" })Install packages:
install({ path: "/home/user/my-app", packages: ["express", "cors"], saveDev: false })Check outdated dependencies:
outdated({ path: "/home/user/my-app" })Compare versions:
diff({ specs: ["lodash@4.17.20", "lodash@4.17.21"] })Generate SBOM:
sbom({ path: "/home/user/my-app", format: "spdx", production: true })Query dependencies:
query({ path: "/home/user/my-app", selector: ":root > .prod" })Auth
Staged publishing
Staged publishing requires npm CLI 11.15.0 or later and Node.js 22.14.0
or later. Check npm stage --help; NPM_PATH can select a separate npm
installation. See the staged publishing prerequisites.
stage({ action: "publish", path: "/home/user/my-lib", access: "public" })
stage({ action: "list", package: "@yourorg/lib" })
stage({ action: "view", stageId: "returned-stage-id" })
stage({ action: "download", stageId: "returned-stage-id", path: "/home/user/review" })
stage({ action: "approve", stageId: "returned-stage-id", otp: "123456" })
// Or reject the staged version:
stage({ action: "reject", stageId: "returned-stage-id", otp: "123456" })Staging does not publish the package; approval does. Approval and rejection
require maintainer 2FA. dryRun applies only to stage with action: "publish".
A direct publish with a stage-only token returns E_STAGE_REQUIRED. npm plans
to remove direct publishing with granular tokens in January 2027.
See npm staging and
token requirements.
pkg accepts JSON values directly: value: "my-package", value: true,
value: ["keyword"], or value: { test: "node --test" }. Strings stay strings;
do not stringify arrays or objects before passing them.
Method | How |
NPM_TOKEN (recommended) | Set |
npm login | Run |
Pass otp when npm requires 2FA, including staged approval/rejection and package
maintainer or token changes. Since August 2026, bypass-2FA tokens cannot bypass
the second factor for account or governance operations. Tokens expire; renew
the configured token when needed or refresh local credentials with npm login.
Environment Variables
Variable | Default | Description |
| -- | npm authentication token |
|
| Path to npm binary (if not in PATH) |
License
MIT
Available Tools
42 toolsaccessC
Set or view access level on published packages
Inputs: action (required), otp, team, level, +2 more.
approve-scriptsB
Approve reviewed dependency install scripts, pinned by npm to installed versions. Only changes policy; does not run scripts. Requires npm 12+. Never approve packages without reviewing them.
Inputs: path (required), packages (required).
auditB
Run a security audit on the package
Inputs: path (required), fix, level, production.
bugsA
Get the bug tracker URL for a package
Inputs: package (required).
cacheC
Manage the npm cache
Inputs: action (required), force.
ciA
Clean install dependencies from lockfile (for CI environments)
Inputs: path (required).
configA
View npm configuration (read-only for safety)
Inputs: action (required), key.
dedupeB
Reduce duplication in the dependency tree
Inputs: path (required), dryRun.
deny-scriptsA
Deny install scripts for named dependencies across all versions. Only changes package.json policy. Requires npm 12+.
Inputs: path (required), packages (required).
deprecateC
Deprecate a version of a package
Inputs: message (required), package (required), otp.
diffB
Show diff between package versions or between local and registry
Inputs: path, specs, package, diffNameOnly.
dist-tagC
Manage distribution tags
Inputs: action (required), package (required), tag.
docsB
Get the documentation URL for a package
Inputs: package (required).
doctorB
Run diagnostics to check npm environment health
Inputs: no named parameters.
explainB
Explain why a package is installed (show dependency chain)
Inputs: path (required), package (required).
fundC
Show funding information for installed packages
Inputs: path (required), package.
initB
Initialize a new package.json
Inputs: path (required), scope.
installC
Install packages in a project
Inputs: path (required), dryRun, global, saveDev, +3 more.
linkB
Symlink a local package for development
Inputs: path (required), package.
lsC
List installed packages in a project
Inputs: path (required), all, depth, global, +2 more.
outdatedC
Check for outdated packages in a project
Inputs: path (required), long, global.
ownerC
Manage package owners
Inputs: action (required), package (required), otp, user.
packB
Create a tarball from a package (preview what would be published)
Inputs: path (required), dryRun.
pending-scriptsARead-onlyIdempotent
List dependencies whose install scripts need review without changing package.json. Requires npm 12 or later.
Inputs: path (required).
pingA
Check connectivity to the npm registry
Inputs: no named parameters.
pkgC
Manage package.json fields programmatically
Inputs: path (required), field (required), action (required), value.
profileB
View or modify npm user profile settings
Inputs: action (required), otp, field, value.
pruneB
Remove extraneous packages not listed in package.json
Inputs: path (required), dryRun, production.
publishC
Publish a package to the npm registry
Inputs: path (required), otp, tag, access, +1 more.
queryB
Query installed packages using CSS-like selectors
Inputs: path (required), selector (required).
repoB
Get the repository URL for a package
Inputs: package (required).
run-scriptB
Run a script defined in package.json
Inputs: path (required), args, script.
sbomB
Generate a Software Bill of Materials (SBOM) for a project
Inputs: path (required), format, production.
searchC
Search npm registry for packages
Inputs: query (required), limit.
stageA
Stage a package, inspect pending versions, download a tarball, or approve/reject a stage. Approval publishes the version; rejection removes the staged version. Requires an npm CLI supporting npm stage.
Inputs: action (required), otp, tag, path, +4 more.
tokenC
Manage npm access tokens (list or revoke)
Inputs: action (required), otp, token.
uninstallB
Remove packages from a project
Inputs: path (required), packages (required), global.
unpublishB
Remove a package version from the registry
Inputs: package (required), otp, force.
updateB
Update packages in a project to their latest semver-compatible version
Inputs: path (required), dryRun, global, packages.
versionB
Bump the package version
Inputs: bump (required), path (required), preid, noGitTag.
viewC
View package information from the registry
Inputs: package (required), field.
whoamiA
Check which npm user is currently authenticated. If not logged in, set NPM_TOKEN env var in MCP config.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 42 tools
Most tools map to distinct npm commands, and descriptions clarify adjacent operations such as install/ci/update/prune and view/search/explain/diff. Some overlap remains among config/profile/token/access/owner and query/ls, but it is generally manageable.
Names consistently use lowercase npm CLI-style commands with hyphens for multiword tools (run-script, pending-scripts, deny-scripts), with no camelCase mixing. They are not uniformly verb_noun, but they are predictable and domain-appropriate.
42 tools is a heavy surface for an agent, though it reflects npm's broad CLI domain and each tool corresponds to a real npm command. It is comprehensive but likely to increase selection burden compared with a tighter curated set.
The surface covers core package lifecycle, registry publishing, dependency management, audits, tokens, and diagnostics. Minor gaps exist around login/logout, team/org/hook management, and rebuild-type operations, but most npm workflows are covered.
Maintenance
Related MCP Connectors
npm MCP — wraps the npm Registry API (free, no auth)
MCP server for hex.pm and hexdocs.pm: search, inspect, compare, and audit Elixir packages
One MCP server for all your MCP servers: code mode, per-tool permissions, approvals and audit.
Dive into the world of npm with our NPM Package Info MCP. Access crucial metadata about any npm
Related MCP Servers
- AlicenseCqualityDmaintenanceMCP server for searching npm packages1252 npm16MIT
- AlicenseBqualityDmaintenanceMCP server for npm — search packages, check bundle sizes, scan vulnerabilities, compare downloads, inspect dependencies.859 npm1MIT
- AlicenseAqualityDmaintenanceMCP server to search npm packages, view details, compare, check downloads, and inspect dependencies.639 npmMIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server for searching, inspecting, and evaluating NPM packages through health scoring and license risk assessments. It provides comprehensive package analysis including maintenance status, popularity trends, and security vulnerability reports to help users make informed dependency decisions.3MIT