Skip to main content
Glama

publish

Publish packages to the npm registry with options for access control, distribution tags, and dry-run verification.

Instructions

Publish a package to the npm registry

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesAbsolute path to the package directory
tagNoDist-tag (default: latest)
accessNoAccess level for scoped packages
dryRunNoRun publish without actually publishing
otpNoOne-time password for 2FA

Implementation Reference

  • The registration and handler logic for the 'publish' MCP tool, which executes `npm publish` via the `run` helper function.
    server.tool(
      "publish",
      "Publish a package to the npm registry",
      {
        path: z.string().describe("Absolute path to the package directory"),
        tag: z.string().optional().describe("Dist-tag (default: latest)"),
        access: z
          .enum(["public", "restricted"])
          .optional()
          .describe("Access level for scoped packages"),
        dryRun: z
          .boolean()
          .optional()
          .describe("Run publish without actually publishing"),
        otp: z.string().optional().describe("One-time password for 2FA"),
      },
      async ({ path, tag, access, dryRun, otp }) => {
        const args = ["publish"];
        if (tag) args.push("--tag", tag);
        if (access) args.push("--access", access);
        if (dryRun) args.push("--dry-run");
        if (otp) args.push("--otp", otp);
        try {
          const { stdout, stderr } = await run(args, path);
          return { content: [{ type: "text", text: stdout + stderr }] };
        } 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