Skip to main content
Glama

pack

Create a tarball from a local package directory to preview files that would be published to npm. Optionally dry-run to list files without creating a tarball.

Instructions

Create a tarball from a package (preview what would be published)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesAbsolute path to the package directory
dryRunNoList files without creating tarball

Implementation Reference

  • The `pack` tool handler function. It takes `path` (absolute path to package directory) and optional `dryRun` (boolean to list files without creating tarball). It runs `npm pack --json` via the `run()` helper and returns the JSON output.
    server.tool(
      "pack",
      "Create a tarball from a package (preview what would be published)",
      {
        path: z.string().describe("Absolute path to the package directory"),
        dryRun: z.boolean().optional().describe("List files without creating tarball"),
      },
      async ({ path, dryRun }) => {
        const args = ["pack"];
        if (dryRun) args.push("--dry-run");
        args.push("--json");
        try {
          const { stdout } = await run(args, path);
          return { content: [{ type: "text", text: stdout }] };
        } catch (e: any) {
          return {
            content: [{ type: "text", text: `Error: ${e.stderr || e.message}` }],
            isError: true,
          };
        }
      },
    );
  • src/index.ts:256-278 (registration)
    Registration of the `pack` tool via `server.tool('pack', ...)`. Defines the tool name as 'pack' with description 'Create a tarball from a package (preview what would be published)'.
    // ── npm pack ──
    server.tool(
      "pack",
      "Create a tarball from a package (preview what would be published)",
      {
        path: z.string().describe("Absolute path to the package directory"),
        dryRun: z.boolean().optional().describe("List files without creating tarball"),
      },
      async ({ path, dryRun }) => {
        const args = ["pack"];
        if (dryRun) args.push("--dry-run");
        args.push("--json");
        try {
          const { stdout } = await run(args, path);
          return { content: [{ type: "text", text: stdout }] };
        } catch (e: any) {
          return {
            content: [{ type: "text", text: `Error: ${e.stderr || e.message}` }],
            isError: true,
          };
        }
      },
    );
  • Input schema for the `pack` tool using Zod: `path` (required string), `dryRun` (optional boolean).
    {
      path: z.string().describe("Absolute path to the package directory"),
      dryRun: z.boolean().optional().describe("List files without creating tarball"),
    },
  • The `run()` helper function that executes npm commands. Wraps `execFile` with the configured npm binary and optional .npmrc token arguments.
    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);
    }
  • src/index.ts:1252-1255 (registration)
    Sandbox registration of the `pack` tool (noop handler for testing).
    sandbox.tool("pack", "Create a tarball from a package", {
      path: z.string().describe("Absolute path to the package directory"),
      dryRun: z.boolean().optional().describe("List files without creating tarball"),
    }, noop);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must fully disclose behavioral traits. It mentions creating a tarball but does not explain side effects (e.g., where the file is saved, whether it overwrites existing files) or required permissions. The 'preview' hint is vague without elaboration on default behavior when dryRun is false.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence that front-loads the core action and includes a clarifying parenthetical. Every word serves a purpose, with no unnecessary detail.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simplicity of the tool (2 parameters, no output schema), the description fails to cover important context such as output file location, error scenarios, or default behavior. The 'preview' hint is insufficient for complete understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% coverage with descriptions for both parameters ('path' and 'dryRun'). The description adds no additional meaning beyond what the schema already provides, so it meets the baseline expectation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Create a tarball from a package (preview what would be published)'. It uses a specific verb ('Create') and resource ('tarball from a package'), and the parenthetical distinguishes it from publishing, differentiating from sibling tools like 'publish'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for previewing before publishing via the parenthetical, but it does not explicitly state when to use this tool over alternatives (e.g., 'publish' or 'pack' with dryRun). No conditional guidance or exclusions are provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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