Skip to content

refactor(@angular/cli): add a get best practices guide MCP tool #30725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2025
Merged
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
3 changes: 3 additions & 0 deletions packages/angular/cli/src/commands/mcp/mcp-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import path from 'node:path';
import { z } from 'zod';
import type { AngularWorkspace } from '../../utilities/config';
import { VERSION } from '../../utilities/version';
import { registerBestPracticesTool } from './tools/best-practices';
import { registerDocSearchTool } from './tools/doc-search';

export async function createMcpServer(context: {
Expand Down Expand Up @@ -48,6 +49,8 @@ export async function createMcpServer(context: {
},
);

registerBestPracticesTool(server);

server.registerTool(
'list_projects',
{
Expand Down
45 changes: 45 additions & 0 deletions packages/angular/cli/src/commands/mcp/tools/best-practices.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* @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 type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { readFile } from 'node:fs/promises';
import path from 'node:path';

export function registerBestPracticesTool(server: McpServer): void {
server.registerTool(
'get_best_practices',
{
title: 'Get Angular Coding Best Practices Guide',
description:
'You **MUST** use this tool to retrieve the Angular Best Practices Guide ' +
'before any interaction with Angular code (creating, analyzing, modifying). ' +
'It is mandatory to follow this guide to ensure all code adheres to ' +
'modern standards, including standalone components, typed forms, and ' +
'modern control flow. This is the first step for any Angular task.',
annotations: {
readOnlyHint: true,
openWorldHint: false,
},
},
async () => {
const text = await readFile(
path.join(__dirname, '..', 'instructions', 'best-practices.md'),
'utf-8',
);

return {
content: [
{
type: 'text',
text,
},
],
};
},
);
}