Skip to main content
Glama

ng_run

Execute custom architect targets in Angular projects using the 'ng run' command. Specify the target, app root path, and additional options to streamline development workflows.

Instructions

Run 'ng run' to execute a custom architect target

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
appRootYesThe absolute path to the first folder in the 'path' property. For example, if 'path' is 'webui/src/app/modules/alerts', then 'appRoot' should be the absolute path to 'webui'.
optionsNoAdditional options for ng run
targetYesThe target to run (e.g., app:build:production)

Implementation Reference

  • The switch case in handleToolCall that implements the 'ng_run' tool by constructing the command 'npx ng run <target>' with any provided options and passing it to the shared runCommand helper.
    case "ng_run": { command = "npx"; commandArgs = ["ng", "run", args.target]; if (args.options) { for (const [key, value] of Object.entries(args.options)) { commandArgs.push(`--${key}`, String(value)); } } break;
  • The tool definition including name, description, and input schema for 'ng_run', which requires 'target' and 'appRoot', and accepts 'options'.
    { name: "ng_run", description: "Run 'ng run' to execute a custom architect target", inputSchema: { type: "object", properties: { target: { type: "string", description: "The target to run (e.g., app:build:production)", }, appRoot: { type: "string", description: "The absolute path to the first folder in the 'path' property. For example, if 'path' is 'webui/src/app/modules/alerts', then 'appRoot' should be the absolute path to 'webui'.", }, options: { type: "object", description: "Additional options for ng run", additionalProperties: { type: "string" }, }, }, required: ["target", "appRoot"], }, },
  • Registers the list tools request handler that returns the array of tool definitions, including 'ng_run'.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: tools, }));
  • Registers the call tool request handler that dispatches to handleToolCall based on the tool name, which handles 'ng_run'.
    server.setRequestHandler(CallToolRequestSchema, async (request) => handleToolCall(request.params.name, request.params.arguments ?? {}, server) );
  • Shared helper function that spawns and executes the shell command, capturing output, used by the 'ng_run' handler and other ng tools.
    function runCommand( command: string, args: string[], cwd: string ): Promise<string> { return new Promise((resolve, reject) => { const proc = spawn(command, args, { cwd, shell: true }); let stdout = ""; let stderr = ""; proc.stdout.on("data", (data) => { stdout += data.toString(); }); proc.stderr.on("data", (data) => { stderr += data.toString(); }); proc.on("close", (code) => { if (code === 0) { resolve(stdout); } else { reject(stderr || `Process exited with code ${code}`); } }); proc.on("error", (err) => { reject(err); }); }); }

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/talzach/mcp-angular-cli'

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