Skip to main content
Glama

unpublish

Remove a package version from the npm registry. Specify package and version, optionally use force for entire package, and provide OTP for two-factor authentication.

Instructions

Remove a package version from the registry

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
packageYesPackage name with optional version (e.g. pkg@1.0.0)
forceNoForce unpublish (required for entire package)
otpNoOne-time password for 2FA

Implementation Reference

  • The main 'unpublish' tool handler that runs 'npm unpublish' with the provided package name, optional --force, and --otp flags via the run() helper.
    // ── npm unpublish ──
    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,
          };
        }
      },
    );
  • Zod schema for the 'unpublish' tool input: package (string), force (optional boolean), otp (optional string).
    {
      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"),
    },
  • src/index.ts:156-178 (registration)
    Registration of the 'unpublish' tool via server.tool() with name, description, schema, and 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,
          };
        }
      },
    );
  • src/index.ts:1227-1231 (registration)
    Sandbox (Smithery) registration of the 'unpublish' tool with noop handler.
    sandbox.tool("unpublish", "Remove a package version from the registry", {
      package: z.string().describe("Package name with optional version"),
      force: z.boolean().optional().describe("Force unpublish"),
      otp: z.string().optional().describe("One-time password for 2FA"),
    }, noop);
  • The run() helper function used by the unpublish handler to execute npm commands via execFile.
    async function run(
      args: string[],
      cwd?: string,
    ): Promise<{ stdout: string; stderr: string }> {
      const fullArgs = [...args, ...npmrcArgs];
      const opts: { cwd?: string; timeout: number; env: NodeJS.ProcessEnv; maxBuffer: number } = {
        timeout: 120_000,
        maxBuffer: 10 * 1024 * 1024, // 10MB buffer for large outputs
        env: { ...process.env, NO_COLOR: "1" },
      };
      if (cwd) opts.cwd = cwd;
      return exec(NPM, fullArgs, opts);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, so the description must fully convey behavioral traits. It states the action but omits critical details like irreversibility, permission requirements, and consequences of force unpublishing an entire package.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single succinct sentence that directly communicates the tool's purpose. No unnecessary words, though additional behavioral context could be added without sacrificing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema and a destructive action, the description fails to provide sufficient context about side effects (e.g., breaking builds), revertibility, or post-unpublish behavior. Incomplete for safe decision-making.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema covers 100% of parameters with clear descriptions (e.g., 'Package name with optional version'). The description adds no extra meaning, meeting the baseline for full schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states 'Remove a package version from the registry' with a specific verb ('Remove') and resource ('package version'), clearly distinguishing it from siblings like 'publish' or 'deprecate'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like 'deprecate' (which preserves history) or when not to use it (e.g., if the package is depended upon). No explicit context provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mikusnuz/npm-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server