Skip to content

mcp command list_projects incorrectly constructs sourceRoot for multi-project workspaces #32812

@midthun

Description

@midthun

Command

other

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

The Angular CLI MCP list_projects tool incorrectly constructs the sourceRoot by joining it with project.root, even though sourceRoot is already workspace-relative in angular.json.

This results in invalid paths for projects in a standard multi-project workspace created with --no-create-application.

Minimal Reproduction

Steps to reproduce

ng new my-workspace --no-create-application
cd my-workspace
ng generate application app-one

This produces the following in angular.json:

{
  "root": "projects/app-one",
  "sourceRoot": "projects/app-one/src"
}

Run the Angular CLI MCP tool:

list_projects

Expected behavior

sourceRoot should be reported exactly as defined in angular.json:

projects/app-one/src

Actual behavior

sourceRoot is constructed as:

projects/app-one/projects/app-one/src

This appears to come from:

const sourceRoot = posix.join(project.root, project.sourceRoot ?? 'src');

Impact

  • Incorrect sourceRoot paths returned by list_projects
  • Downstream tools may fail to locate source files
  • Causes incorrect assumptions about workspace structure (e.g. expecting a root /src)

Proposed fix

Do not join project.root with project.sourceRoot, since sourceRoot is already workspace-relative:

const sourceRoot = project.sourceRoot ?? posix.join(project.root, 'src');

Exception or Error


Your Environment

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI       : 21.2.3
Angular           : 21.2.5
Node.js           : 24.10.0
Package Manager   : npm 11.6.1
Operating System  : darwin arm64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package                   │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build            │ 21.2.3            │ ^21.2.3           │
│ @angular/cli              │ 21.2.3            │ ^21.2.3           │
│ @angular/common           │ 21.2.5            │ ^21.2.0           │
│ @angular/compiler         │ 21.2.5            │ ^21.2.0           │
│ @angular/compiler-cli     │ 21.2.5            │ ^21.2.0           │
│ @angular/core             │ 21.2.5            │ ^21.2.0           │
│ @angular/forms            │ 21.2.5            │ ^21.2.0           │
│ @angular/platform-browser │ 21.2.5            │ ^21.2.0           │
│ @angular/router           │ 21.2.5            │ ^21.2.0           │
│ ng-packagr                │ 21.2.1            │ ^21.2.0           │
│ rxjs                      │ 7.8.2             │ ~7.8.0            │
│ typescript                │ 5.9.3             │ ~5.9.2            │
│ vitest                    │ 4.1.0             │ ^4.0.8            │
└───────────────────────────┴───────────────────┴───────────────────┘

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions