Skip to main content
Glama

prune

Remove extraneous npm packages not listed in package.json to clean up project dependencies and reduce node_modules size.

Instructions

Remove extraneous packages not listed in package.json

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesAbsolute path to the package directory
productionNoRemove devDependencies
dryRunNoPreview changes without making them

Implementation Reference

  • Registration and implementation of the "prune" MCP tool.
    server.tool(
      "prune",
      "Remove extraneous packages not listed in package.json",
      {
        path: z.string().describe("Absolute path to the package directory"),
        production: z.boolean().optional().describe("Remove devDependencies"),
        dryRun: z.boolean().optional().describe("Preview changes without making them"),
      },
      async ({ path, production, dryRun }) => {
        const args = ["prune"];
        if (production) args.push("--omit=dev");
        if (dryRun) args.push("--dry-run");
        try {
          const { stdout, stderr } = await run(args, path);
          return { content: [{ type: "text", text: stdout + stderr || "Prune complete" }] };
        } catch (e: any) {
          return {
            content: [{ type: "text", text: `Error: ${e.stderr || e.message}` }],
            isError: true,
          };
        }
      },
    );

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