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
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path to the package directory | |
| production | No | Remove devDependencies | |
| dryRun | No | Preview changes without making them |
Implementation Reference
- src/index.ts:956-978 (handler)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, }; } }, );