Skip to content

Commit 481ce18

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 647c059 commit 481ce18

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,13 @@ export async function createMcpServer(
6565
},
6666
);
6767

68-
let toolDeclarations = [
68+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
69+
let toolDeclarations: McpToolDeclaration<any, any>[] = [
6970
BEST_PRACTICES_TOOL,
7071
DOC_SEARCH_TOOL,
7172
LIST_PROJECTS_TOOL,
72-
FIND_EXAMPLE_TOOL,
7373
];
74-
75-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
76-
const experimentalToolDeclarations: McpToolDeclaration<any, any>[] = [];
74+
const experimentalToolDeclarations = [FIND_EXAMPLE_TOOL];
7775

7876
if (context.readOnly) {
7977
toolDeclarations = toolDeclarations.filter((tool) => tool.isReadOnly);
@@ -83,12 +81,17 @@ export async function createMcpServer(
8381
toolDeclarations = toolDeclarations.filter((tool) => tool.isLocalOnly);
8482
}
8583

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

91-
for (const toolName of context.experimentalTools) {
94+
for (const toolName of enabledExperimentalTools) {
9295
const tool = experimentalToolsMap.get(toolName);
9396
if (tool) {
9497
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)