owner
Manage npm package ownership by listing, adding, or removing owners for specific packages using clear actions.
Instructions
Manage package owners
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Action to perform | |
| package | Yes | Package name | |
| user | No | Username (required for add/rm) | |
| otp | No | One-time password for 2FA |
Implementation Reference
- src/index.ts:216-229 (handler)The handler function for the 'owner' tool, which constructs the npm command arguments and executes them.
async ({ action, package: pkg, user, otp }) => { const args = ["owner", action, pkg]; if (user && (action === "add" || action === "rm")) args.push(user); if (otp) args.push("--otp", otp); try { const { stdout } = await run(args); return { content: [{ type: "text", text: stdout }] }; } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.stderr || e.message}` }], isError: true, }; } }, - src/index.ts:210-215 (schema)Zod schema definition for the 'owner' tool arguments.
{ action: z.enum(["ls", "add", "rm"]).describe("Action to perform"), package: z.string().describe("Package name"), user: z.string().optional().describe("Username (required for add/rm)"), otp: z.string().optional().describe("One-time password for 2FA"), }, - src/index.ts:207-230 (registration)Full registration of the 'owner' tool using server.tool.
server.tool( "owner", "Manage package owners", { action: z.enum(["ls", "add", "rm"]).describe("Action to perform"), package: z.string().describe("Package name"), user: z.string().optional().describe("Username (required for add/rm)"), otp: z.string().optional().describe("One-time password for 2FA"), }, async ({ action, package: pkg, user, otp }) => { const args = ["owner", action, pkg]; if (user && (action === "add" || action === "rm")) args.push(user); if (otp) args.push("--otp", otp); try { const { stdout } = await run(args); return { content: [{ type: "text", text: stdout }] }; } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.stderr || e.message}` }], isError: true, }; } }, );