Skip to main content
Glama

explain

Show why a specific npm package is installed by displaying its dependency chain. Provide the absolute path to the package directory and the package name to get the reason for its presence.

Instructions

Explain why a package is installed (show dependency chain)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesAbsolute path to the package directory
packageYesPackage name to explain

Implementation Reference

  • The tool handler that executes 'npm explain --json <pkg>' and returns the dependency chain output.
    server.tool(
      "explain",
      "Explain why a package is installed (show dependency chain)",
      {
        path: z.string().describe("Absolute path to the package directory"),
        package: z.string().describe("Package name to explain"),
      },
      async ({ path, package: pkg }) => {
        const args = ["explain", pkg, "--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 defining the 'path' (absolute directory) and 'package' (package name to explain) parameters using Zod.
    {
      path: z.string().describe("Absolute path to the package directory"),
      package: z.string().describe("Package name to explain"),
    },
  • src/index.ts:766-785 (registration)
    Tool registration on the MCP server via server.tool() — this is the primary registration.
    server.tool(
      "explain",
      "Explain why a package is installed (show dependency chain)",
      {
        path: z.string().describe("Absolute path to the package directory"),
        package: z.string().describe("Package name to explain"),
      },
      async ({ path, package: pkg }) => {
        const args = ["explain", pkg, "--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:1361-1364 (registration)
    Sandbox-only registration (noop handler) for the explain tool, used in sandbox mode.
    sandbox.tool("explain", "Explain why a package is installed", {
      path: z.string().describe("Absolute path to the package directory"),
      package: z.string().describe("Package name to explain"),
    }, noop);
  • The run() helper that executes npm CLI commands via execFile. Used by the explain handler to run 'npm explain --json'.
    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);
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It only states the tool shows a dependency chain, but does not reveal if it requires network access, modifies state, or needs permissions. As a read tool, it is non-destructive, but the description lacks details on output format or side effects.

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 sentence that efficiently conveys the tool's main function. Every word is necessary, with no redundancy or fluff.

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 tool's complexity (explaining dependency chains), the description lacks details on output format, depth, or how the path is used. No output schema exists, so additional context on return values is missing. The description is insufficient for an agent to fully understand the tool's behavior.

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?

Schema coverage is 100% with both parameters described. The description adds no additional meaning beyond the schema (e.g., path is 'absolute path', package is 'package name'). Baseline score of 3 applies as schema does the heavy lifting.

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: to explain why a package is installed by showing its dependency chain. This distinguishes it from sibling tools like 'ls' (list packages) or 'outdated' (check updates), making the purpose specific and unambiguous.

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 context (when you need to understand package dependencies) but does not explicitly state when to use this tool over alternatives like 'ls' or 'audit'. No exclusion criteria or alternative suggestions 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