Skip to main content
Glama

token

Manage npm access tokens to list existing tokens or revoke specific ones for security control.

Instructions

Manage npm access tokens (list or revoke)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesAction to perform
tokenNoToken ID to revoke (required for revoke)
otpNoOne-time password for 2FA

Implementation Reference

  • The tool named 'token' is implemented in src/index.ts. It handles 'list' and 'revoke' actions by running 'npm token ...' via the 'run' helper function.
    server.tool(
      "token",
      "Manage npm access tokens (list or revoke)",
      {
        action: z.enum(["list", "revoke"]).describe("Action to perform"),
        token: z.string().optional().describe("Token ID to revoke (required for revoke)"),
        otp: z.string().optional().describe("One-time password for 2FA"),
      },
      async ({ action, token, otp }) => {
        const args = ["token"];
        if (action === "list") {
          args.push("list", "--json");
        } else if (action === "revoke") {
          if (!token) {
            return {
              content: [{ type: "text", text: "Error: token ID is required for revoke action" }],
              isError: true,
            };
          }
          args.push("revoke", token);
        }
        if (otp) args.push("--otp", otp);
        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,
          };
        }
      },
    );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mikusnuz/npm-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server