Skip to content

Commit 51d56f7

Browse files
committed
fix(@angular/cli): cache MCP best practices content and add tool annotations
Caches the content of the best practices instructions to avoid redundant file reads on subsequent uses of the tool. This can provide a minor performance improvement in cases where the tool is used multiple times during a single CLI process. Also, annotations have been added to the text to provide additional context for the assistant and allow for more tailored display of the information.
1 parent 88b1dc2 commit 51d56f7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/angular/cli/src/commands/mcp/tools/best-practices.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { readFile } from 'node:fs/promises';
1111
import path from 'node:path';
1212

1313
export function registerBestPracticesTool(server: McpServer): void {
14+
let bestPracticesText;
15+
1416
server.registerTool(
1517
'get_best_practices',
1618
{
@@ -27,7 +29,7 @@ export function registerBestPracticesTool(server: McpServer): void {
2729
},
2830
},
2931
async () => {
30-
const text = await readFile(
32+
bestPracticesText ??= await readFile(
3133
path.join(__dirname, '..', 'instructions', 'best-practices.md'),
3234
'utf-8',
3335
);
@@ -36,7 +38,11 @@ export function registerBestPracticesTool(server: McpServer): void {
3638
content: [
3739
{
3840
type: 'text',
39-
text,
41+
text: bestPracticesText,
42+
annotations: {
43+
audience: ['assistant'],
44+
priority: 0.9,
45+
},
4046
},
4147
],
4248
};

0 commit comments

Comments
 (0)