ng_generate
Generate Angular components, services, and other artifacts using Angular CLI schematics to accelerate development workflow.
Instructions
Run 'ng generate' to create a new Angular artifact (component, service, etc.)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| schematic | Yes | The schematic to generate (e.g., component, service) | |
| name | Yes | The name of the artifact to generate | |
| path | No | The path where the artifact should be created, relative to the appRoot (do not include the app folder itself). For example, if the full path is 'webui/src/app/modules/alerts' and appRoot is 'webui', then path should be 'src/app/modules/alerts'. | src/app |
| 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 the schematic |
Implementation Reference
- src/toolHandler.ts:15-27 (handler)Specific implementation of the 'ng_generate' tool handler: constructs the 'npx ng generate' command arguments from input parameters (schematic, name, path, options).case "ng_generate": { command = "npx"; commandArgs = ["ng", "generate", args.schematic, args.name]; if (args.path) { commandArgs.push("--path", args.path); } if (args.options) { for (const [key, value] of Object.entries(args.options)) { commandArgs.push(`--${key}`, String(value)); } } break; }
- src/tools.ts:5-69 (schema)Input schema, description, and definition for the 'ng_generate' tool.{ name: "ng_generate", description: "Run 'ng generate' to create a new Angular artifact (component, service, etc.)", inputSchema: { type: "object", properties: { schematic: { type: "string", description: "The schematic to generate (e.g., component, service)", }, name: { type: "string", description: "The name of the artifact to generate", }, path: { type: "string", description: "The path where the artifact should be created, relative to the appRoot (do not include the app folder itself). For example, if the full path is 'webui/src/app/modules/alerts' and appRoot is 'webui', then path should be 'src/app/modules/alerts'.", default: "src/app", }, 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 the schematic", properties: { defaults: { type: "boolean", description: "Disable interactive input prompts for options with a default.", default: false, }, dryRun: { type: "boolean", description: "Run through and report activity without writing out results.", default: false, }, force: { type: "boolean", description: "Force overwriting of existing files.", default: false, }, help: { type: "boolean", description: "Shows a help message for this command in the console.", default: false, }, interactive: { type: "boolean", description: "Enable interactive input prompts.", default: true, }, }, additionalProperties: { type: "string" }, }, }, required: ["schematic", "name", "appRoot"], }, },
- src/index.ts:23-26 (registration)Registers the tools including 'ng_generate' by calling createToolDefinitions() and setting up handlers on the MCP server.const TOOLS = createToolDefinitions(); // Setup request handlers setupRequestHandlers(server, TOOLS);
- src/requestHandler.ts:11-13 (registration)Registers handler for listing available tools, exposing 'ng_generate' schema to clients.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: tools, }));
- src/requestHandler.ts:15-18 (registration)Registers generic call tool handler that dispatches 'ng_generate' calls to handleToolCall based on name.// Call tool handler server.setRequestHandler(CallToolRequestSchema, async (request) => handleToolCall(request.params.name, request.params.arguments ?? {}, server) );