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
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path to the package directory | |
| packages | No | Specific packages to update (empty = update all) | |
| global | No | Update global packages | |
| dryRun | No | Preview updates without making changes |
Implementation Reference
- src/index.ts:459-484 (handler)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, }; } }, );