Skip to content

fix(@angular/cli): resolve installed @angular/core version in list_projects MCP tool - #34772

Open
FlorinAsavoaie wants to merge 1 commit into
angular:mainfrom
FlorinAsavoaie:fix/mcp-list-projects-framework-version
Open

FlorinAsavoaie wants to merge 1 commit into
angular:mainfrom
FlorinAsavoaie:fix/mcp-list-projects-framework-version

Conversation

@FlorinAsavoaie

Copy link
Copy Markdown

PR Checklist

Please check to confirm your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

The list_projects MCP tool works out frameworkVersion by walking up from the workspace directory to the first package.json that declares @angular/core, then passing the declared value to semver.minVersion. If the declared value isn't a semver range, semver.minVersion throws. That happens with pnpm/yarn catalogs (catalog:, catalog:angular), workspace:* and npm: aliases. The tool then reports a versioning error for the workspace (e.g. Invalid comparator: catalog:) and leaves frameworkVersion unset.

Issue Number: N/A

What is the new behavior?

The version now comes from the installed @angular/core/package.json, resolved with createRequire the same way the get_best_practices tool does it. How the dependency is declared no longer matters.

  • Resolution starts from the workspace's angular.json file rather than its directory. createRequire searches from the parent directory of the path it's given, so starting from the directory would skip the node_modules of nested workspaces such as apps/web.
  • If @angular/core isn't installed or its version can't be read, frameworkVersion is left unset and no error is reported.
  • The upward package.json search and its cache are removed.
  • The output schema is unchanged.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

…ojects MCP tool

The `list_projects` MCP tool determined `frameworkVersion` by walking up from the workspace
directory to the first `package.json` that declared `@angular/core` and passing the declared
value to `semver.minVersion`. Declared values that are not semver ranges, such as pnpm/yarn
catalogs (`catalog:`, `catalog:angular`), `workspace:*` or `npm:` aliases, made
`semver.minVersion` throw. The tool then reported a versioning error for the workspace (e.g.
`Invalid comparator: catalog:`) and left `frameworkVersion` unset.

The version is now read from the installed `@angular/core/package.json`, resolved with
`createRequire` in the same way as the `get_best_practices` tool, so the way the dependency
is declared no longer matters. The resolution starts from the workspace's `angular.json` file
rather than its directory, because `createRequire` searches from the parent directory of the
given path and would otherwise skip the `node_modules` of nested workspaces such as
`apps/web`. When `@angular/core` is not installed or its version cannot be read,
`frameworkVersion` is left unset and no error is reported. The upward `package.json` search
and its cache are removed; the output schema is unchanged.
@google-cla

google-cla Bot commented Nov 22, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors how the major version of @angular/core is determined for a workspace. It replaces a custom upward directory traversal and caching mechanism with Node.js module resolution via createRequire relative to the angular.json file. This change simplifies the code, robustly handles various dependency declaration formats (such as pnpm/yarn catalogs), and removes the reporting of versioning errors when the package is not installed. Additionally, comprehensive unit tests have been added to verify these resolution behaviors. I have no further feedback to provide as the implementation is clean and well-tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant