Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/angular/cli/src/commands/mcp/mcp-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { FIND_EXAMPLE_TOOL } from './tools/examples';
import { MODERNIZE_TOOL } from './tools/modernize';
import { ZONELESS_MIGRATION_TOOL } from './tools/onpush-zoneless-migration/zoneless-migration';
import { LIST_PROJECTS_TOOL } from './tools/projects';
import { SCHEMATICS_TOOLS } from './tools/schematics';
import { type AnyMcpToolDeclaration, registerTools } from './tools/tool-registry';

/**
Expand All @@ -47,7 +48,12 @@ const STABLE_TOOLS = [
* The set of tools that are available but not enabled by default.
* These tools are considered experimental and may have limitations.
*/
export const EXPERIMENTAL_TOOLS = [BUILD_TOOL, MODERNIZE_TOOL, ...SERVE_TOOLS] as const;
export const EXPERIMENTAL_TOOLS = [
BUILD_TOOL,
MODERNIZE_TOOL,
...SCHEMATICS_TOOLS,
...SERVE_TOOLS,
] as const;

export async function createMcpServer(
options: {
Expand Down
13 changes: 13 additions & 0 deletions packages/angular/cli/src/commands/mcp/tools/schematics/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/

import { LIST_SCHEMATICS_TOOL } from './list-schematics';
import { RUN_SCHEMATIC_TOOL } from './run-schematic';

export { LIST_SCHEMATICS_TOOL, RUN_SCHEMATIC_TOOL };
export const SCHEMATICS_TOOLS = [LIST_SCHEMATICS_TOOL, RUN_SCHEMATIC_TOOL] as const;
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/

import { z } from 'zod';
import { createStructuredContentOutput } from '../../utils';
import { type McpToolContext, type McpToolDeclaration, declareTool } from '../tool-registry';
import { loadSchematicsMetadata } from './utils';

const listInputSchema = z.object({
workspacePath: z
.string()
.describe('Path to the workspace angular.json (or any file within the workspace).'),
});

const listOutputSchema = z.object({
schematics: z.array(
z.object({
name: z.string(),
aliases: z.array(z.string()).optional(),
description: z.string().optional(),
hidden: z.boolean().optional(),
private: z.boolean().optional(),
required: z.array(z.string()).optional(),
options: z
.array(
z.object({
name: z.string(),
description: z.string().optional(),
type: z.union([z.string(), z.array(z.string())]).optional(),
enum: z.array(z.any()).optional(),
default: z.any().optional(),
required: z.boolean().optional(),
alias: z.string().optional(),
prompt: z.string().optional(),
}),
)
.optional(),
}),
),
});

export type ListSchematicsInput = z.infer<typeof listInputSchema>;
export type ListSchematicsOutput = z.infer<typeof listOutputSchema>;

async function handleListSchematics(input: ListSchematicsInput, context: McpToolContext) {
// Always use injected loader if present (for tests)
const { meta } = await loadSchematicsMetadata(
input.workspacePath,
context.logger,
typeof context.schematicMetaLoader === 'function' ? context.schematicMetaLoader : undefined,
);
const serialized = meta.map((m) => ({
name: m.name,
aliases: m.aliases,
description: m.description,
hidden: m.hidden,
private: m.private,
required: m.required,
options: m.options?.map((o) => ({
name: o.name,
description: o.description,
type: o.type,
enum: o.enum,
default: o.default,
required: o.required,
alias: o.alias,
prompt: o.prompt,
})),
}));

return createStructuredContentOutput<ListSchematicsOutput>({
schematics: serialized,
});
}

export const LIST_SCHEMATICS_TOOL: McpToolDeclaration<
typeof listInputSchema.shape,
typeof listOutputSchema.shape
> = declareTool({
name: 'list_schematics',
title: 'List Angular Schematics',
description: `
<Purpose>
Enumerates all schematics provided by @schematics/angular with full option metadata (types, defaults, enums, prompts, required flags).
</Purpose>
<Use Cases>
* Discover generators available before planning code changes.
* Inspect required options for a schematic prior to execution.
* Provide intelligent suggestions to users based on option types and prompts.
</Use Cases>
<Operational Notes>
* Resolution uses Node's module loader. If a schematic collection cannot be resolved, this tool returns an empty list.
* Hidden/private schematics are included for transparency.
* Use 'run_schematic' to actually execute a schematic after reviewing options here.
* Official docs: https://angular.dev/tools/cli/schematics and https://angular.dev/cli/generate
</Operational Notes>
`,
inputSchema: listInputSchema.shape,
outputSchema: listOutputSchema.shape,
isLocalOnly: true,
isReadOnly: true,
factory: (context) => (input) => handleListSchematics(input, context),
});
Loading