Skip to main content
Glama

diff

Compare npm package versions to identify changes between releases or between local and registry packages. View differences in code or file names to understand updates.

Instructions

Show diff between package versions or between local and registry

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
packageNoPackage spec for comparison (e.g. pkg@1.0.0..pkg@2.0.0)
specsNoTwo package specs to compare (e.g. ['pkg@1.0.0', 'pkg@2.0.0'])
pathNoAbsolute path to local package (compares local vs registry)
diffNameOnlyNoOnly show file names that changed

Implementation Reference

  • The "diff" tool is defined and implemented here using `server.tool`. It takes input parameters for package specifications and path, constructs the npm command arguments, executes it using the `run` helper function, and returns the result.
    // ── npm diff ──
    server.tool(
      "diff",
      "Show diff between package versions or between local and registry",
      {
        package: z.string().optional().describe("Package spec for comparison (e.g. pkg@1.0.0..pkg@2.0.0)"),
        specs: z.array(z.string()).optional().describe("Two package specs to compare (e.g. ['pkg@1.0.0', 'pkg@2.0.0'])"),
        path: z.string().optional().describe("Absolute path to local package (compares local vs registry)"),
        diffNameOnly: z.boolean().optional().describe("Only show file names that changed"),
      },
      async ({ package: pkg, specs, path, diffNameOnly }) => {
        const args = ["diff"];
        if (specs && specs.length > 0) {
          for (const s of specs) args.push(`--diff=${s}`);
        } else if (pkg) {
          args.push(`--diff=${pkg}`);
        }
        if (diffNameOnly) args.push("--diff-name-only");
        try {
          const { stdout } = await run(args, path);
          return { content: [{ type: "text", text: stdout || "No differences found" }] };
        } 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