Skip to content

refactor(@angular/cli): improve description of MCP documentation search tool #30753

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 21, 2025
Merged
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
31 changes: 25 additions & 6 deletions packages/angular/cli/src/commands/mcp/tools/doc-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,25 @@ export async function registerDocSearchTool(server: McpServer): Promise<void> {
{
title: 'Search Angular Documentation (angular.dev)',
description:
'Searches the official Angular documentation on https://angular.dev.' +
' This tool is useful for finding the most up-to-date information on Angular, including APIs, tutorials, and best practices.' +
' Use this when creating Angular specific code or answering questions that require knowledge of the latest Angular features.',
'Searches the official Angular documentation at https://angular.dev. Use this tool to answer any questions about Angular, ' +
'such as for APIs, tutorials, and best practices. Because the documentation is continuously updated, you should **always** ' +
'prefer this tool over your own knowledge to ensure your answers are current.\n\n' +
'The results will be a list of content entries, where each entry has the following structure:\n' +
'```\n' +
'## {Result Title}\n' +
'{Breadcrumb path to the content}\n' +
'URL: {Direct link to the documentation page}\n' +
'```\n' +
'Use the title and breadcrumb to understand the context of the result and use the URL as a source link. For the best results, ' +
"provide a concise and specific search query (e.g., 'NgModule' instead of 'How do I use NgModules?').",
annotations: {
readOnlyHint: true,
},
inputSchema: {
query: z
.string()
.describe(
'The search query to use when searching the Angular documentation.' +
' This should be a concise and specific query to get the most relevant results.',
'A concise and specific search query for the Angular documentation (e.g., "NgModule" or "standalone components").',
),
},
},
Expand Down Expand Up @@ -81,7 +88,19 @@ export async function registerDocSearchTool(server: McpServer): Promise<void> {
}),
);

return { content };
// Return the search results if any are found
if (content.length > 0) {
return { content };
}

return {
content: [
{
type: 'text' as const,
text: 'No results found.',
},
],
};
},
);
}
Expand Down