Skip to main content
Glama

npmBuild

Execute npm build commands to compile and prepare projects for deployment, handling dependencies and generating production-ready files.

Instructions

執行npm build命令構建專案

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNo
optionsNo

Implementation Reference

  • The static async executeBuild method in NpmBuildTool class that executes the npm build command using child_process.exec after changing to the specified path.
    static async executeBuild(path: string = '.', options: string = ''): Promise<{ stdout: string; stderr: string }> {
      try {
        console.log(`執行 npm build ${options} 在路徑 ${path}`);
        
        // 構建完整指令
        const command = `cd ${path} && npm run build ${options}`;
        
        // 執行指令
        const { stdout, stderr } = await execPromise(command);
        
        if (stdout) {
          console.log('Build輸出:', stdout);
        }
        
        if (stderr && !stderr.includes('npm notice')) {
          console.error('Build錯誤:', stderr);
        }
        
        return { stdout, stderr };
      } catch (error) {
        console.error('Build執行失敗:', error);
        throw error;
      }
    }
  • main.ts:34-48 (registration)
    Registers the 'npmBuild' tool with input schema for optional path and options, wraps the handler execution and formats success/error responses.
    server.tool("npmBuild",
        "執行npm build命令構建專案",
        { path: z.string().optional(), options: z.string().optional() },
        async ({ path = ".", options = "" }) => {
            try {
                const result = await NpmBuildTool.executeBuild(path, options);
                return {
                    content: [{ type: "text", text: `Build completed successfully: ${result.stdout}` }]
                };
            } catch (error) {
                return {
                    content: [{ type: "text", text: `Build failed: ${error instanceof Error ? error.message : "Unknown error"}` }]
                };
            }
        });
  • main.ts:36-36 (schema)
    Zod input schema defining optional path (project directory) and options (additional npm flags) parameters for the npmBuild tool.
    { 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. It states the tool executes an npm build command, implying it's a mutation operation that may modify files or produce output, but it doesn't disclose critical behaviors such as whether it requires specific permissions, what happens on failure, if it's idempotent, or any side effects like creating directories. This is a significant gap for a tool with potential destructive 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, efficient sentence that directly states the tool's purpose without any fluff. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly. Every word earns its place by conveying the core action.

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 a build tool with 2 parameters, no annotations, and no output schema, the description is incomplete. It lacks details on parameters, behavioral traits, expected outputs, error handling, and usage context. This makes it inadequate for an agent to reliably invoke the tool without additional assumptions or trial-and-error.

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 input schema has 2 parameters (path and options) with 0% description coverage, meaning no details are provided in the schema. The description adds no information about these parameters—it doesn't explain what 'path' refers to (e.g., project directory path) or what 'options' might include (e.g., npm build flags). This fails to compensate for the low schema coverage, leaving parameters largely 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 build命令構建專案' translates to 'execute npm build command to build project'), specifying the verb (execute npm build) and resource (project). It distinguishes from siblings like npmInstall, which installs dependencies rather than building. However, it doesn't specify what type of project or build output is expected, keeping it from a perfect score.

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 explicit guidance on when to use this tool versus alternatives is provided. The description implies usage for building projects with npm, but it doesn't mention prerequisites (e.g., needing npm installed, a package.json file), when not to use it, or compare it to other build tools in the sibling list. This leaves the agent with minimal context for decision-making.

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