deprecate
Mark a specific version of an npm package as deprecated with a custom message, or remove deprecation by providing an empty string.
Instructions
Deprecate a version of a package
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| package | Yes | Package@version range (e.g. pkg@<1.0.0) | |
| message | Yes | Deprecation message (empty string to undeprecate) | |
| otp | No | One-time password for 2FA |
Implementation Reference
- src/index.ts:189-203 (handler)The async handler function for the 'deprecate' tool. It constructs npm deprecate CLI args with package, message, and optional OTP, executes via the run() helper, and returns success or error output.
async ({ package: pkg, message, otp }) => { const args = ["deprecate", pkg, message]; if (otp) args.push("--otp", otp); try { const { stdout, stderr } = await run(args); return { content: [{ type: "text", text: stdout + stderr || (message ? "Deprecated successfully" : "Undeprecated successfully") }], }; } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.stderr || e.message}` }], isError: true, }; } }, - src/index.ts:184-188 (schema)Zod schema for the 'deprecate' tool inputs: package (string, @version range), message (string, deprecation message or empty to undeprecate), and optional otp (string, for 2FA).
{ package: z.string().describe("Package@version range (e.g. pkg@<1.0.0)"), message: z.string().describe("Deprecation message (empty string to undeprecate)"), otp: z.string().optional().describe("One-time password for 2FA"), }, - src/index.ts:181-204 (registration)Primary registration of the 'deprecate' tool on the MCP server using server.tool() with name 'deprecate', description 'Deprecate a version of a package', the schema, and the handler.
server.tool( "deprecate", "Deprecate a version of a package", { package: z.string().describe("Package@version range (e.g. pkg@<1.0.0)"), message: z.string().describe("Deprecation message (empty string to undeprecate)"), otp: z.string().optional().describe("One-time password for 2FA"), }, async ({ package: pkg, message, otp }) => { const args = ["deprecate", pkg, message]; if (otp) args.push("--otp", otp); try { const { stdout, stderr } = await run(args); return { content: [{ type: "text", text: stdout + stderr || (message ? "Deprecated successfully" : "Undeprecated successfully") }], }; } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.stderr || e.message}` }], isError: true, }; } }, ); - src/index.ts:1233-1237 (registration)Secondary registration of the 'deprecate' tool in the Smithery sandbox server using a noop handler.
sandbox.tool("deprecate", "Deprecate a version of a package", { package: z.string().describe("Package@version range"), message: z.string().describe("Deprecation message"), otp: z.string().optional().describe("One-time password for 2FA"), }, noop); - src/index.ts:26-38 (helper)The run() helper function used by the deprecate handler to execute the npm CLI command with arguments and timeout.
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); }