unpublish
Remove a package version from the npm registry using the npm-mcp server. Specify package name with optional version, force option for entire packages, and OTP for 2FA authentication.
Instructions
Remove a package version from the registry
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| package | Yes | Package name with optional version (e.g. pkg@1.0.0) | |
| force | No | Force unpublish (required for entire package) | |
| otp | No | One-time password for 2FA |
Implementation Reference
- src/index.ts:156-178 (handler)Implementation of the 'unpublish' tool handler.
server.tool( "unpublish", "Remove a package version from the registry", { package: z.string().describe("Package name with optional version (e.g. pkg@1.0.0)"), force: z.boolean().optional().describe("Force unpublish (required for entire package)"), otp: z.string().optional().describe("One-time password for 2FA"), }, async ({ package: pkg, force, otp }) => { const args = ["unpublish", pkg]; if (force) args.push("--force"); if (otp) args.push("--otp", otp); try { const { stdout, stderr } = await run(args); return { content: [{ type: "text", text: stdout + stderr }] }; } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.stderr || e.message}` }], isError: true, }; } }, );