cache
Manage npm package cache by cleaning outdated files, verifying integrity, or listing contents to optimize storage and ensure reliable package installations.
Instructions
Manage the npm cache
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Action: clean (clear cache), verify (check integrity), ls (list contents) | |
| force | No | Force clean (required for clean action) |
Implementation Reference
- src/index.ts:909-929 (handler)The "cache" tool implementation, which executes npm cache commands using the `run` helper function.
server.tool( "cache", "Manage the npm cache", { action: z.enum(["clean", "verify", "ls"]).describe("Action: clean (clear cache), verify (check integrity), ls (list contents)"), force: z.boolean().optional().describe("Force clean (required for clean action)"), }, async ({ action, force }) => { const args = ["cache", action]; if (action === "clean" && force) args.push("--force"); try { const { stdout, stderr } = await run(args); return { content: [{ type: "text", text: stdout + stderr || "Done" }] }; } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.stderr || e.message}` }], isError: true, }; } }, );