Skip to content

Commit 540b6f0

Browse files
committed
refactor(@angular/cli): move find_examples to experimental
This change moves the `find_examples` tool to the experimental toolset. It can now be enabled by passing the `--experimental-tool find_examples` flag to the `ng mcp` command. For backward compatibility, the tool will also be enabled if the `NG_MCP_CODE_EXAMPLES=1` environment variable is set.
1 parent 6f4f213 commit 540b6f0

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
@@ -66,16 +66,13 @@ export async function createMcpServer(
6666
},
6767
);
6868

69-
let toolDeclarations = [
69+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
70+
let toolDeclarations: McpToolDeclaration<any, any>[] = [
7071
BEST_PRACTICES_TOOL,
7172
DOC_SEARCH_TOOL,
7273
LIST_PROJECTS_TOOL,
73-
MODERNIZE_TOOL,
74-
FIND_EXAMPLE_TOOL,
7574
];
76-
77-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
78-
const experimentalToolDeclarations: McpToolDeclaration<any, any>[] = [];
75+
const experimentalToolDeclarations = [FIND_EXAMPLE_TOOL, MODERNIZE_TOOL];
7976

8077
if (context.readOnly) {
8178
toolDeclarations = toolDeclarations.filter((tool) => tool.isReadOnly);
@@ -85,12 +82,17 @@ export async function createMcpServer(
8582
toolDeclarations = toolDeclarations.filter((tool) => tool.isLocalOnly);
8683
}
8784

88-
if (context.experimentalTools?.length) {
85+
const enabledExperimentalTools = new Set(context.experimentalTools);
86+
if (process.env['NG_MCP_CODE_EXAMPLES'] === '1') {
87+
enabledExperimentalTools.add('find_examples');
88+
}
89+
90+
if (enabledExperimentalTools.size > 0) {
8991
const experimentalToolsMap = new Map(
9092
experimentalToolDeclarations.map((tool) => [tool.name, tool]),
9193
);
9294

93-
for (const toolName of context.experimentalTools) {
95+
for (const toolName of enabledExperimentalTools) {
9496
const tool = experimentalToolsMap.get(toolName);
9597
if (tool) {
9698
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)