Skip to main content
Glama

run_build

Execute build commands like npm run build or yarn build to compile projects, supporting multiple package managers and providing error reporting for development workflows.

Instructions

Run build command in the current directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandNoBuild command to run (e.g., "npm run build", "yarn build")npm run build
directoryNoDirectory to run the build in (default: current directory)

Implementation Reference

  • The main handler function that runs the build command using execSync with configurable command and directory, returning success output or throwing error.
    private async runBuild(args: any) {
      const command = args?.command || 'npm run build';
      const directory = args?.directory || process.cwd();
      
      try {
        const output = execSync(command, { 
          cwd: directory, 
          encoding: 'utf8',
          timeout: 300000 // 5 minutes
        });
        
        return {
          content: [
            {
              type: 'text',
              text: `Build successful!\nCommand: ${command}\nDirectory: ${directory}\nOutput:\n${output}`
            }
          ]
        };
      } catch (error: any) {
        throw new Error(`Build failed: ${error.message}\nStderr: ${error.stderr || 'N/A'}`);
      }
    }
  • JSON schema defining the input parameters for the run_build tool: command (string, default 'npm run build') and optional directory (string).
    inputSchema: {
      type: 'object',
      properties: {
        command: {
          type: 'string',
          description: 'Build command to run (e.g., "npm run build", "yarn build")',
          default: 'npm run build'
        },
        directory: {
          type: 'string',
          description: 'Directory to run the build in (default: current directory)'
        }
      }
    }
  • src/index.ts:45-62 (registration)
    Tool registration in the ListToolsRequestSchema handler, providing name, description, and input schema.
    {
      name: 'run_build',
      description: 'Run build command in the current directory',
      inputSchema: {
        type: 'object',
        properties: {
          command: {
            type: 'string',
            description: 'Build command to run (e.g., "npm run build", "yarn build")',
            default: 'npm run build'
          },
          directory: {
            type: 'string',
            description: 'Directory to run the build in (default: current directory)'
          }
        }
      }
    },
  • src/index.ts:139-140 (registration)
    Handler dispatch for 'run_build' in the CallToolRequestSchema switch statement, calling the runBuild method.
    case 'run_build':
      return await this.runBuild(args);
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 what the tool does but doesn't describe execution behavior (e.g., whether it runs synchronously/asynchronously, error handling, output format, or side effects like file system changes). For a command execution tool, this leaves significant gaps.

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 with zero waste. It's appropriately sized and front-loaded, directly stating the tool's purpose without unnecessary elaboration.

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 executing build commands (which can have side effects, require specific environments, or produce outputs) and the lack of annotations and output schema, the description is insufficient. It doesn't address behavioral aspects, error conditions, or what the agent should expect after 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?

Schema description coverage is 100%, with both parameters well-documented in the schema. The description adds no additional parameter semantics beyond implying execution context, so it meets the baseline score of 3 where 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 ('run build command') and context ('in the current directory'), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'run_test' or 'check_package_json', which might also involve command execution in similar contexts.

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. The description doesn't mention prerequisites (e.g., whether dependencies must be installed first), when to choose this over sibling tools like 'run_test', or any exclusions (e.g., not for production builds).

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/TeodorTrotea/mcptest'

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