Skip to main content
Glama

install

Add npm packages to a project directory with options for dev dependencies, exact versions, global installation, and dry-run preview.

Instructions

Install packages in a project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesAbsolute path to the package directory
packagesNoPackage names to install (empty = install all from package.json)
saveDevNoSave as devDependency
saveExactNoSave exact version instead of semver range
globalNoInstall globally
dryRunNoPreview install without making changes

Implementation Reference

  • Primary tool handler for 'install'. Constructs npm install args (packages, saveDev, saveExact, global, dryRun), executes via the run() helper, and returns stdout/stderr or an error response.
    server.tool(
      "install",
      "Install packages in a project",
      {
        path: z.string().describe("Absolute path to the package directory"),
        packages: z.array(z.string()).optional().describe("Package names to install (empty = install all from package.json)"),
        saveDev: z.boolean().optional().describe("Save as devDependency"),
        saveExact: z.boolean().optional().describe("Save exact version instead of semver range"),
        global: z.boolean().optional().describe("Install globally"),
        dryRun: z.boolean().optional().describe("Preview install without making changes"),
      },
      async ({ path, packages, saveDev, saveExact, global: isGlobal, dryRun }) => {
        const args = ["install"];
        if (packages && packages.length > 0) args.push(...packages);
        if (saveDev) args.push("--save-dev");
        if (saveExact) args.push("--save-exact");
        if (isGlobal) args.push("-g");
        if (dryRun) args.push("--dry-run");
        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,
          };
        }
      },
    );
  • Input schema for 'install': validates path (string), packages (optional string array), saveDev, saveExact, global, dryRun (optional booleans).
    {
      path: z.string().describe("Absolute path to the package directory"),
      packages: z.array(z.string()).optional().describe("Package names to install (empty = install all from package.json)"),
      saveDev: z.boolean().optional().describe("Save as devDependency"),
      saveExact: z.boolean().optional().describe("Save exact version instead of semver range"),
      global: z.boolean().optional().describe("Install globally"),
      dryRun: z.boolean().optional().describe("Preview install without making changes"),
  • src/index.ts:405-406 (registration)
    Registration of the 'install' tool on the primary server via server.tool().
    server.tool(
      "install",
  • src/index.ts:1286-1293 (registration)
    Secondary (sandbox) registration of 'install' tool with a noop handler in createSandboxServer().
    sandbox.tool("install", "Install packages in a project", {
      path: z.string().describe("Absolute path to the package directory"),
      packages: z.array(z.string()).optional().describe("Package names to install"),
      saveDev: z.boolean().optional().describe("Save as devDependency"),
      saveExact: z.boolean().optional().describe("Save exact version"),
      global: z.boolean().optional().describe("Install globally"),
      dryRun: z.boolean().optional().describe("Preview install"),
    }, noop);
  • Helper function run() that executes npm commands via execFile with timeout, maxBuffer, and NO_COLOR env.
    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, the description carries the full burden, but it only states 'Install packages', which implies a write operation. It does not disclose side effects (e.g., modifying node_modules or lockfiles), network calls, or required permissions.

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

Conciseness4/5

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

The description is a single, front-loaded sentence with no fluff. It is concise, but the extreme brevity may sacrifice necessary detail, warranting a slight reduction from a perfect score.

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 has 6 parameters, no output schema, and no annotations, the description is insufficient. It does not explain what the tool returns, whether it runs install scripts, or any other behavioral aspects critical for correct invocation.

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% description coverage, so the schema already documents each parameter. The description adds no extra meaning beyond the schema, meeting the baseline of 3.

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

Purpose4/5

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

The description clearly states the verb 'install' and resource 'packages in a project', distinguishing it from sibling tools like 'uninstall' or 'update'. However, it lacks specificity about the package manager (e.g., npm) and does not mention that it works with a package.json.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives like 'ci' (clean install) or 'update'. There is no mention of prerequisites, such as requiring a package.json present, or exclusions.

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