ng_update
Update Angular packages and run migrations to maintain project compatibility and apply framework changes.
Instructions
Run 'ng update' to update Angular packages and run migrations.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| packages | Yes | ||
| 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'. | |
| next | No | Use the prerelease version, including beta and RCs. | |
| force | No | Ignore peer dependency version mismatches. | |
| allowDirty | No | Allow updating when the repository contains modified or untracked files. | |
| createCommits | No | Create source control commits for updates and migrations. | |
| from | No | Version from which to migrate from (only with migrate-only and single package). | |
| to | No | Version up to which to apply migrations (only with migrate-only and single package). | |
| migrateOnly | No | Only perform a migration, do not update the installed version. | |
| name | No | The name of the migration to run (only with migrate-only and single package). | |
| verbose | No | Display additional details about internal operations during execution. |
Implementation Reference
- src/tools.ts:146-224 (schema)Defines the input schema, description, and parameters for the 'ng_update' tool.{ name: "ng_update", description: "Run 'ng update' to update Angular packages and run migrations.", inputSchema: { type: "object", properties: { packages: { oneOf: [ { type: "string", description: "The name of the package to update (e.g., @angular/core)", }, { type: "array", items: { type: "string" }, description: "The names of packages to update.", }, ], }, 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'.", }, next: { type: "boolean", description: "Use the prerelease version, including beta and RCs.", default: false, }, force: { type: "boolean", description: "Ignore peer dependency version mismatches.", default: false, }, allowDirty: { type: "boolean", description: "Allow updating when the repository contains modified or untracked files.", default: false, }, createCommits: { type: "boolean", description: "Create source control commits for updates and migrations.", default: false, }, from: { type: "string", description: "Version from which to migrate from (only with migrate-only and single package).", }, to: { type: "string", description: "Version up to which to apply migrations (only with migrate-only and single package).", }, migrateOnly: { type: "boolean", description: "Only perform a migration, do not update the installed version.", default: false, }, name: { type: "string", description: "The name of the migration to run (only with migrate-only and single package).", }, verbose: { type: "boolean", description: "Display additional details about internal operations during execution.", default: false, }, }, required: ["packages", "appRoot"], }, },
- src/requestHandler.ts:11-13 (registration)Registers the list tools handler, exposing the 'ng_update' tool schema in the tools list.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: tools, }));
- src/requestHandler.ts:15-18 (registration)Registers the call tool handler, which dispatches 'ng_update' calls to handleToolCall based on tool name.// Call tool handler server.setRequestHandler(CallToolRequestSchema, async (request) => handleToolCall(request.params.name, request.params.arguments ?? {}, server) );
- src/toolHandler.ts:4-84 (handler)Generic handler for tool calls. Dispatches via switch on tool name to construct and run 'npx ng ...' commands. 'ng_update' has no specific case and returns an 'Unknown tool' error.export async function handleToolCall( name: string, args: any, server: any ): Promise<CallToolResult> { try { let command = ""; let commandArgs: string[] = []; let cwd = args.appRoot || process.cwd(); switch (name) { 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; } 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; } case "ng_new": { command = "npx"; commandArgs = ["ng", "new", args.name]; if (args.directory) { cwd = args.directory; } if (args.options) { for (const [key, value] of Object.entries(args.options)) { commandArgs.push(`--${key}`, String(value)); } } break; } 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; } default: return { content: [{ type: "text", text: `Unknown tool: ${name}` }], isError: true, }; } const output = await runCommand(command, commandArgs, cwd); return { content: [{ type: "text", text: output }], isError: false, }; } catch (error) { return { content: [ { type: "text", text: error instanceof Error ? error.message : String(error), }, ], isError: true, }; } }