Skip to content

Commit 48c852a

Browse files
committed
refactor(@angular/cli): move find_examples and modernize to experimental
This change moves the `find_examples` and `modernize` tools to the experimental toolset. They can now be enabled by passing the `--experimental-tool <tool_name>` flag to the `ng mcp` command. For backward compatibility, the `find_examples` tool will also be enabled if the `NG_MCP_CODE_EXAMPLES=1` environment variable is set.
1 parent a7eb6f8 commit 48c852a

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

packages/angular/cli/src/commands/mcp/mcp-server.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,13 @@ export async function createMcpServer(
4646

4747
registerInstructionsResource(server);
4848

49-
let toolDeclarations = [
49+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
50+
let toolDeclarations: McpToolDeclaration<any, any>[] = [
5051
BEST_PRACTICES_TOOL,
5152
DOC_SEARCH_TOOL,
5253
LIST_PROJECTS_TOOL,
53-
MODERNIZE_TOOL,
54-
FIND_EXAMPLE_TOOL,
5554
];
56-
57-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
58-
const experimentalToolDeclarations: McpToolDeclaration<any, any>[] = [];
55+
const experimentalToolDeclarations = [FIND_EXAMPLE_TOOL, MODERNIZE_TOOL];
5956

6057
if (context.readOnly) {
6158
toolDeclarations = toolDeclarations.filter((tool) => tool.isReadOnly);
@@ -65,12 +62,17 @@ export async function createMcpServer(
6562
toolDeclarations = toolDeclarations.filter((tool) => tool.isLocalOnly);
6663
}
6764

68-
if (context.experimentalTools?.length) {
65+
const enabledExperimentalTools = new Set(context.experimentalTools);
66+
if (process.env['NG_MCP_CODE_EXAMPLES'] === '1') {
67+
enabledExperimentalTools.add('find_examples');
68+
}
69+
70+
if (enabledExperimentalTools.size > 0) {
6971
const experimentalToolsMap = new Map(
7072
experimentalToolDeclarations.map((tool) => [tool.name, tool]),
7173
);
7274

73-
for (const toolName of context.experimentalTools) {
75+
for (const toolName of enabledExperimentalTools) {
7476
const tool = experimentalToolsMap.get(toolName);
7577
if (tool) {
7678
toolDeclarations.push(tool);

packages/angular/cli/src/commands/mcp/tools/examples.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ export const FIND_EXAMPLE_TOOL = declareTool({
5555
isReadOnly: true,
5656
isLocalOnly: true,
5757
shouldRegister: ({ logger }) => {
58-
if (process.env['NG_MCP_CODE_EXAMPLES'] !== '1') {
59-
return false;
60-
}
61-
6258
// sqlite database support requires Node.js 22.16+
6359
const [nodeMajor, nodeMinor] = process.versions.node.split('.', 2).map(Number);
6460
if (nodeMajor < 22 || (nodeMajor === 22 && nodeMinor < 16)) {

0 commit comments

Comments
 (0)