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);

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