Skip to content

refactor(@angular/cli): provide a find examples MCP server tool #30717

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

clydin
Copy link
Member

@clydin clydin commented Jul 15, 2025

The built-in stdio MCP server (ng mcp) for the Angular CLI now includes a tool that can find Angular code usage examples. The code examples are indexed and stored locally within the Angular CLI install. This removes the need for network requests to find the examples. It also ensures that the examples are relevant for the version of Angular currently being used. This tool requires Node.js 22.16 or higher. Lower versions will not have this specific tool available for use.
The tool is currently disabled by default but can be enabled for experimental purposes via the NG_MCP_CODE_EXAMPLES=1 environment variable.

@clydin clydin force-pushed the mcp/find-examples branch 7 times, most recently from 2ee5662 to e0991f1 Compare July 22, 2025 00:53
@clydin clydin marked this pull request as ready for review July 22, 2025 00:53
@clydin clydin added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Jul 22, 2025
@clydin clydin force-pushed the mcp/find-examples branch from e0991f1 to 22d76fc Compare July 22, 2025 15:14
@clydin clydin requested review from alan-agius4 and devversion July 22, 2025 16:39
queryStatement = db.prepare('SELECT * from examples WHERE examples MATCH ? ORDER BY rank;');
}

const sanitizedQuery = sanitizeSearchQuery(query);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no library we can use for sanitization, or do we just avoid another dependency? I'd prefer us not having to maintain this.

Copy link
Member Author

@clydin clydin Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's particular to the Sqlite FTS5 query microsyntax. It's mainly about wrapping query substrings to avoid unintentionally using some of the more esoteric query features like column filters via -. The entire query string is properly escaped due to the prepared statement usage.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no library for this? It feels like logic that can be hard to revisit in the future

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no. It's not SQL. it's a custom microsyntax for the FTS5 extension that's being used as a string literal in the parent SQL query.

The built-in stdio MCP server (`ng mcp`) for the Angular CLI now includes
a tool that can find Angular code usage examples. The code examples are
indexed and stored locally within the Angular CLI install. This removes
the need for network requests to find the examples. It also ensures that
the examples are relevant for the version of Angular currently being used.
This tool requires Node.js 22.16 or higher. Lower versions will not have
this specific tool available for use.
The tool is currently disabled by default but can be enabled for experimental
purposes via the `NG_MCP_CODE_EXAMPLES=1` environment variable.
@clydin clydin force-pushed the mcp/find-examples branch from 22d76fc to d6835ff Compare July 25, 2025 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/cli target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants