Skip to main content
Glama

update

Update npm packages to their latest compatible versions in a project directory. Specify packages or update all, preview changes with dry run, or update global packages.

Instructions

Update packages in a project to their latest semver-compatible version

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesAbsolute path to the package directory
packagesNoSpecific packages to update (empty = update all)
globalNoUpdate global packages
dryRunNoPreview updates without making changes

Implementation Reference

  • The 'update' tool is registered using 'server.tool', and its handler implements the update logic by executing the 'npm update' command via the internal 'run' function.
    // ── npm update ──
    server.tool(
      "update",
      "Update packages in a project to their latest semver-compatible version",
      {
        path: z.string().describe("Absolute path to the package directory"),
        packages: z.array(z.string()).optional().describe("Specific packages to update (empty = update all)"),
        global: z.boolean().optional().describe("Update global packages"),
        dryRun: z.boolean().optional().describe("Preview updates without making changes"),
      },
      async ({ path, packages, global: isGlobal, dryRun }) => {
        const args = ["update"];
        if (packages && packages.length > 0) args.push(...packages);
        if (isGlobal) args.push("-g");
        if (dryRun) args.push("--dry-run");
        try {
          const { stdout, stderr } = await run(args, path);
          return { content: [{ type: "text", text: stdout + stderr || "Update 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