ng_add
Add npm packages to an Angular workspace using the 'ng add' command. Specify the package name, app root path, and optional settings to integrate dependencies efficiently.
Instructions
Run 'ng add' to add a package to the Angular workspace
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| appRoot | Yes | 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 | No | Additional options for ng add | |
| package | Yes | The npm package to add (e.g., @angular/material) |
Implementation Reference
- src/toolHandler.ts:28-36 (handler)Specific handler logic for the 'ng_add' tool within the switch statement in handleToolCall. Prepares the 'npx ng add' command with the package name and any options.case "ng_add": { command = "npx"; commandArgs = ["ng", "add", args.package]; if (args.options) { for (const [key, value] of Object.entries(args.options)) { commandArgs.push(`--${key}`, String(value)); } } break;
- src/tools.ts:70-93 (schema)Defines the tool's name, description, and input schema requiring 'package' and 'appRoot' parameters.{ name: "ng_add", description: "Run 'ng add' to add a package to the Angular workspace", inputSchema: { type: "object", properties: { package: { type: "string", description: "The npm package to add (e.g., @angular/material)", }, 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 add", additionalProperties: { type: "string" }, }, }, required: ["package", "appRoot"], }, },
- src/requestHandler.ts:11-13 (registration)Registers the request handler for listing tools, providing the tool definitions including 'ng_add'.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: tools, }));
- src/requestHandler.ts:16-18 (registration)Registers the request handler for calling tools, which invokes handleToolCall to execute 'ng_add'.server.setRequestHandler(CallToolRequestSchema, async (request) => handleToolCall(request.params.name, request.params.arguments ?? {}, server) );
- src/index.ts:22-23 (registration)Instantiates the tool definitions array containing 'ng_add' by calling createToolDefinitions().// Create tool definitions const TOOLS = createToolDefinitions();