FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(@angular/cli): enforce MCP roots in get_best_practices tool by herdiyana256 · Pull Request #33653 · angular/angular-cli · GitHub

fix(@angular/cli): enforce MCP roots in get_best_practices tool - #33653

Merged
dgp1130 merged 3 commits into
angular:mainfrom
herdiyana256:fix-mcp-best-practices-roots-bypass
Aug 13, 2026
Merged

fix(@angular/cli): enforce MCP roots in get_best_practices tool#33653
dgp1130 merged 3 commits into
angular:mainfrom
herdiyana256:fix-mcp-best-practices-roots-bypass

Conversation

Copy link
Copy Markdown
Contributor

`getVersionSpecificBestPractices()` resolves an npm package (and reads a file path declared in that package's `package.json`) starting from a caller-supplied `workspacePath`, without checking it against the client's declared MCP roots. Every other workspace-path-consuming MCP tool (`run_target`, `devserver_start`/`stop`/`wait_for_build`) validates this through `resolveWorkspaceAndProject()`'s `isAllowedWorkspacePath()` check; this tool never did.

Exports `isAllowedWorkspacePath()` from `workspace-utils.ts` and calls it in `getVersionSpecificBestPractices()` before resolving anything, falling back to the bundled guide when the path is outside the allowed roots, matching this file's existing fallback behavior for every other failure case in the function.

getVersionSpecificBestPractices() resolves an npm package (and reads a
file path declared in that package's package.json) starting from a
caller-supplied workspacePath, without checking it against the client's
declared MCP roots. Every other workspace-path-consuming MCP tool
(run_target, devserver_start/stop/wait_for_build) validates this through
resolveWorkspaceAndProject()'s isAllowedWorkspacePath() check; this tool
never did.

Export isAllowedWorkspacePath() from workspace-utils.ts and call it in
getVersionSpecificBestPractices() before resolving anything, falling back
to the bundled guide when the path is outside the allowed roots, matching
this file's existing fallback behavior for every other failure case.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Code Review

This pull request integrates workspace path validation into the best practices MCP tool. It exports isAllowedWorkspacePath and uses it within getVersionSpecificBestPractices to ensure the user-provided workspace path is within the allowed MCP roots, falling back to the bundled guide if it is not. Feedback suggests wrapping the isAllowedWorkspacePath check in a try-catch block to gracefully handle potential errors (such as non-existent paths or connection failures) and prevent unhandled exceptions.

…practices tool

isAllowedWorkspacePath can throw if the workspace path does not exist
(realpathSync) or if listRoots() fails against the connected client.
Wrap the check in a try-catch and fall back to the bundled guide on
any failure, matching this function's existing fallback behavior.

Copy link
Copy Markdown
Contributor Author

Gentle bump on this one. It has been open two weeks without a reviewer assigned. #33654, from the same MCP batch, was reviewed and merged within a few days, so I suspect this one just slipped past the queue rather than being deliberately parked.

Happy to rebase or split it if that helps. @clydin if you are the right person for the MCP tools area, would you mind taking a look or routing it to whoever is?

…tool

Aligns get_best_practices with resolveWorkspaceAndProject, which throws
when a caller-supplied workspacePath falls outside the client's declared
MCP roots rather than silently falling back. The try/catch now wraps only
the isAllowedWorkspacePath call so genuine verification failures (e.g. a
non-existent path) still fall back to the bundled guide, while a path
outside the roots surfaces an actionable error pointing at list_projects.
clydin added the target: patch This PR is targeted for the next patch release label Aug 11, 2026
clydin added the action: merge The PR is ready for merge by the caretaker label Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Final shape keeps the two outcomes distinct: verification failures (bad path, unreadable roots) degrade to the bundled guide, while a path that resolves but sits outside the declared roots throws with the same list_projects hint as resolveWorkspaceAndProject. CI is green across the board.

dgp1130 merged commit 24fd8fc into angular:main Aug 13, 2026
41 checks passed

dgp1130 commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

This PR was merged into the repository. The changes were merged into the following branches:

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/cli target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL