access
Manage npm package access levels and permissions. Set visibility to public or restricted, grant or revoke team permissions, and view current access settings.
Instructions
Set or view access level on published packages
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Action to perform | |
| package | No | Package name | |
| level | No | Access level (for set action) | |
| team | No | Team name in org:team format (for grant/revoke) | |
| permission | No | Permission level (for grant action) | |
| otp | No | One-time password for 2FA |
Implementation Reference
- src/index.ts:487-542 (handler)Registration and handler implementation for the "access" tool, which manages npm package access levels using the npm CLI.
server.tool( "access", "Set or view access level on published packages", { action: z.enum(["list", "get", "set", "grant", "revoke"]).describe("Action to perform"), package: z.string().optional().describe("Package name"), level: z .enum(["public", "restricted"]) .optional() .describe("Access level (for set action)"), team: z.string().optional().describe("Team name in org:team format (for grant/revoke)"), permission: z .enum(["read-only", "read-write"]) .optional() .describe("Permission level (for grant action)"), otp: z.string().optional().describe("One-time password for 2FA"), }, async ({ action, package: pkg, level, team, permission, otp }) => { const args = ["access"]; switch (action) { case "list": args.push("list", "packages"); if (pkg) args.push(pkg); break; case "get": args.push("get", "status"); if (pkg) args.push(pkg); break; case "set": if (level === "public") args.push("public"); else args.push("restricted"); if (pkg) args.push(pkg); break; case "grant": args.push("grant", permission || "read-only"); if (team) args.push(team); if (pkg) args.push(pkg); break; case "revoke": args.push("revoke"); if (team) args.push(team); if (pkg) args.push(pkg); break; } if (otp) args.push("--otp", otp); try { const { stdout } = await run(args); return { content: [{ type: "text", text: stdout || "Done" }] }; } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.stderr || e.message}` }], isError: true, }; } }, );