Skip to main content
Glama

dedupe

Remove duplicate dependencies from an npm package's dependency tree at a given path, with an optional dry-run to preview changes without applying them.

Instructions

Reduce duplication in the dependency tree

Input Schema

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

Implementation Reference

  • The `run` helper function that executes npm commands via execFile (promisified). It assembles arguments, sets timeout, and returns stdout/stderr.
    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);
    }
  • The handler function for the 'dedupe' tool. It runs `npm dedupe` (with optional --dry-run) and returns the output.
    // ── npm dedupe ──
    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,
          };
        }
      },
    );
  • Schema definition for the 'dedupe' tool: requires path (string), accepts optional dryRun (boolean).
    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"),
      },
  • src/index.ts:743-763 (registration)
    Registration of the 'dedupe' tool via server.tool() with its schema and handler.
    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,
          };
        }
      },
    );
Behavior2/5

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

With no annotations provided, the description fails to disclose behavioral traits like whether modifications are made permanently, if the operation is reversible, or any side effects on node_modules.

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

Conciseness3/5

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

The description is concise (one phrase) but lacks a complete sentence structure. It front-loads the purpose but could be slightly more detailed without losing brevity.

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?

Given the lack of annotations and output schema, the description is too sparse. It does not explain duplication detection, impact on the tree, or behavior with dryRun, leaving the agent underinformed.

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?

Schema coverage is 100% and the schema descriptions adequately explain path and dryRun. The tool description adds no extra meaning beyond what the schema provides, earning a baseline score of 3.

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 'Reduce duplication in the dependency tree' clearly states the verb (reduce duplication) and resource (dependency tree), distinguishing it from sibling tools like install, prune, or update.

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 is given on when to use this tool versus alternatives such as prune or update. The description lacks context on prerequisites or scenarios.

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