dedupe
Remove duplicate dependencies from npm packages to optimize project size and resolve version conflicts. Specify a package directory path to clean up redundant modules.
Instructions
Reduce duplication in the dependency tree
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path to the package directory | |
| dryRun | No | Preview changes without making them |
Implementation Reference
- src/index.ts:743-763 (handler)The 'dedupe' tool is registered and implemented in src/index.ts. It calls the 'run' helper function with the 'dedupe' npm command and provided arguments.
server.tool( "dedupe", "Reduce duplication in the dependency tree", { path: z.string().describe("Absolute path to the package directory"), dryRun: z.boolean().optional().describe("Preview changes without making them"), }, async ({ path, dryRun }) => { const args = ["dedupe"]; if (dryRun) args.push("--dry-run"); try { const { stdout, stderr } = await run(args, path); return { content: [{ type: "text", text: stdout + stderr || "Deduplication complete" }] }; } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.stderr || e.message}` }], isError: true, }; } }, );