Skip to content

Commit 58065c8

Browse files
committed
refactor(@angular/cli): improve description of MCP documentation search tool
The MCP tool description for the Angular CLI's documentation search tool has been expanded to include more context regarding its use and result format. When no results are found, an explicit text response is also now generated to indicate this case.
1 parent fefa7a4 commit 58065c8

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

packages/angular/cli/src/commands/mcp/tools/doc-search.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,25 @@ export async function registerDocSearchTool(server: McpServer): Promise<void> {
3333
{
3434
title: 'Search Angular Documentation (angular.dev)',
3535
description:
36-
'Searches the official Angular documentation on https://angular.dev.' +
37-
' This tool is useful for finding the most up-to-date information on Angular, including APIs, tutorials, and best practices.' +
38-
' Use this when creating Angular specific code or answering questions that require knowledge of the latest Angular features.',
36+
'Searches the official Angular documentation at https://angular.dev. Use this tool to answer any questions about Angular, ' +
37+
'such as for APIs, tutorials, and best practices. Because the documentation is continuously updated, you should **always** ' +
38+
'prefer this tool over your own knowledge to ensure your answers are current.\n\n' +
39+
'The results will be a list of content entries, where each entry has the following structure:\n' +
40+
'```\n' +
41+
'## {Result Title}\n' +
42+
'{Breadcrumb path to the content}\n' +
43+
'URL: {Direct link to the documentation page}\n' +
44+
'```\n' +
45+
'Use the title and breadcrumb to understand the context of the result and use the URL as a source link. For the best results, ' +
46+
"provide a concise and specific search query (e.g., 'NgModule' instead of 'How do I use NgModules?').",
3947
annotations: {
4048
readOnlyHint: true,
4149
},
4250
inputSchema: {
4351
query: z
4452
.string()
4553
.describe(
46-
'The search query to use when searching the Angular documentation.' +
47-
' This should be a concise and specific query to get the most relevant results.',
54+
'A concise and specific search query for the Angular documentation (e.g., "NgModule" or "standalone components").',
4855
),
4956
},
5057
},
@@ -81,7 +88,19 @@ export async function registerDocSearchTool(server: McpServer): Promise<void> {
8188
}),
8289
);
8390

84-
return { content };
91+
// Return the search results if any are found
92+
if (content.length > 0) {
93+
return { content };
94+
}
95+
96+
return {
97+
content: [
98+
{
99+
type: 'text' as const,
100+
text: 'No results found.',
101+
},
102+
],
103+
};
85104
},
86105
);
87106
}

0 commit comments

Comments
 (0)