Skip to main content
Glama
kalivaraprasad-gonapa

https://github.com/Streen9/react-mcp

install-package

Adds npm packages to a React project via CLI, specifying package name, directory, and dependency type. Simplifies dependency management for React app development.

Instructions

Install a npm package in a project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
devNoWhether to install as a dev dependency
directoryNoDirectory of the project (defaults to current directory)
packageNameYesName of the package to install (can include version)

Implementation Reference

  • The main execution logic for the 'install-package' tool. It destructures input params, validates packageName, determines working directory, checks for directory and package.json existence, builds npm install command based on dev flag, starts the process using startProcess helper, and returns success message with processId or error.
    async function handleInstallPackage(params) {
      try {
        const { packageName, directory, dev } = params;
    
        if (!packageName) {
          throw new Error("Package name is required");
        }
    
        // Determine directory
        const workingDir = directory || process.cwd();
    
        // Check if directory exists
        if (!fs.existsSync(workingDir)) {
          throw new Error(`Directory ${workingDir} does not exist`);
        }
    
        // Check if package.json exists
        const packageJsonPath = path.join(workingDir, "package.json");
        if (!fs.existsSync(packageJsonPath)) {
          throw new Error(
            `Not a valid Node.js project: package.json not found in ${workingDir}`
          );
        }
    
        // Install the package
        const installCommand = dev
          ? `npm install ${packageName} --save-dev`
          : `npm install ${packageName}`;
    
        const processId = startProcess(installCommand, [], workingDir);
    
        return {
          message: `Installing ${packageName} in ${workingDir}`,
          processId: processId,
          command: installCommand,
        };
      } catch (error) {
        return {
          error: `Error installing package: ${error.message}`,
        };
      }
    }
  • Zod schema used for input validation in the install-package tool handler.
    const InstallPackageSchema = z.object({
      packageName: z.string(),
      directory: z.string().optional(),
      dev: z.boolean().optional(),
    });
  • index.js:597-619 (registration)
    Tool registration entry in the list_tools handler response, defining name, description, and input schema advertised to MCP clients.
      name: "install-package",
      description: "Install a npm package in a project",
      inputSchema: {
        type: "object",
        properties: {
          packageName: {
            type: "string",
            description:
              "Name of the package to install (can include version)",
          },
          directory: {
            type: "string",
            description:
              "Directory of the project (defaults to current directory)",
          },
          dev: {
            type: "boolean",
            description: "Whether to install as a dev dependency",
          },
        },
        required: ["packageName"],
      },
    },
  • index.js:674-677 (registration)
    Dispatch case in the CallToolRequestHandler switch statement that routes 'install-package' calls to the handler function after schema validation.
    case "install-package":
      const installArgs = InstallPackageSchema.parse(args);
      result = await handleInstallPackage(installArgs);
      break;
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action but doesn't mention permissions needed, side effects (e.g., modifies package.json), error handling, or output format. This leaves significant gaps for a mutation tool.

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, clear sentence with zero waste, front-loading the core action. It's appropriately sized for the tool's complexity, making it easy to parse quickly.

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?

For a mutation tool with no annotations and no output schema, the description is incomplete. It lacks behavioral details like what happens on success/failure, dependencies, or system impacts, which are crucial for safe and effective use by an AI agent.

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 description coverage is 100%, so the schema fully documents all three parameters. The description adds no additional meaning beyond implying installation context, but doesn't compensate for any gaps since there are none. Baseline 3 is appropriate as the schema does the heavy lifting.

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 action ('install') and resource ('npm package in a project'), making the purpose immediately understandable. However, it doesn't differentiate from the only sibling tool 'read-file', which is unrelated, so it doesn't need sibling differentiation but could be more specific about what type of installation it performs.

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?

The description provides no guidance on when to use this tool versus alternatives, prerequisites, or context. It's a standalone statement with no usage instructions, making it unclear if there are other installation methods or constraints.

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

Related 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/kalivaraprasad-gonapa/react-mcp'

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