Skip to main content
Glama

npmInstall

Install npm dependencies in a specified directory using npm install command to manage project packages.

Instructions

執行npm install命令安裝依賴

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNo
optionsNo

Implementation Reference

  • The static method implementing the core logic of the npmInstall tool, executing 'npm install' in the specified directory with optional flags using promisified child_process.exec.
    static async executeInstall(path: string = '.', options: string = ''): Promise<{ stdout: string; stderr: string }> {
      try {
        console.log(`正在執行 npm install ${options} 在路徑 ${path}`);
        
        // 構建完整指令
        const command = `cd ${path} && npm install ${options}`;
        
        // 執行指令
        const { stdout, stderr } = await execPromise(command);
        
        if (stdout) {
          console.log('Install輸出:', stdout);
        }
        
        if (stderr && !stderr.includes('npm notice')) {
          console.error('Install錯誤:', stderr);
        }
        
        return { stdout, stderr };
      } catch (error) {
        console.error('Install執行失敗:', error);
        throw error;
      }
    }
  • main.ts:51-66 (registration)
    Registers the 'npmInstall' tool with the MCP server, including input schema definition using Zod and the async handler that calls NpmInstallTool.executeInstall.
    server.tool("npmInstall",
        "執行npm install命令安裝依賴",
        { path: z.string().optional(), options: z.string().optional() },
        async ({ path = ".", options = "" }) => {
            try {
                const result = await NpmInstallTool.executeInstall(path, options);
                return {
                    content: [{ type: "text", text: `Dependencies installed successfully: ${result.stdout}` }]
                };
            } catch (error) {
                return {
                    content: [{ type: "text", text: `Installation failed: ${error instanceof Error ? error.message : "Unknown error"}` }]
                };
            }
        }
    );
  • main.ts:53-53 (schema)
    Zod schema defining the input parameters for the npmInstall tool: optional path (defaults to '.') and options.
    { path: z.string().optional(), options: z.string().optional() },
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While '執行npm install命令' implies it runs a system command with potential side effects (installing dependencies), it doesn't disclose critical behavioral traits like whether it modifies files, requires internet access, has rate limits, or what happens on failure. The description is minimal and lacks operational context.

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 extremely concise with a single sentence that directly states the tool's function. There's no wasted language or unnecessary elaboration, making it front-loaded and efficient. Every word serves a clear purpose.

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 complexity of running npm install (which can modify files, require network access, and have various outcomes), the description is incomplete. With no annotations, no output schema, and 0% parameter coverage, it fails to provide sufficient context for safe and effective use. The description doesn't cover return values, error conditions, or behavioral implications.

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

Parameters2/5

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

The description provides no information about the two parameters ('path' and 'options'), and schema description coverage is 0%. The description doesn't compensate for this gap by explaining what these parameters mean, their expected formats, or how they affect the installation process. This leaves parameters completely undocumented.

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 ('執行npm install命令') and resource ('安裝依賴'), making the purpose understandable. It doesn't explicitly distinguish from sibling tools like 'npmBuild', but the verb 'install' versus 'build' provides implicit differentiation. The description is specific about what the tool does.

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 like 'npmBuild' or other dependency management approaches. It states what the tool does but offers no context about prerequisites, when it's appropriate, or what scenarios it's designed for.

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/GonTwVn/GonMCPtool'

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