Skip to content

Conversation

clydin
Copy link
Member

@clydin clydin commented Oct 15, 2025

The file traversal logic in the list_projects MCP tool did not previously handle symbolic link loops. In a repository with a symlink pointing to a parent directory, this could cause the tool to enter an infinite loop, consuming CPU and memory until it crashed or was terminated.

This commit enhances the findAngularJsonFiles function to make it resilient to such loops. It now uses fs.stat to retrieve the inode of each directory and tracks visited inodes in a Set. If a directory with a previously seen inode is encountered, it is skipped, effectively breaking the infinite loop.

This change adds a minor performance overhead due to the extra stat call per directory, but this is a trade-off for the increase in robustness and stability when operating on complex or untrusted file systems.

…loops

The file traversal logic in the `list_projects` MCP tool did not previously handle symbolic link loops. In a repository with a symlink pointing to a parent directory, this could cause the tool to enter an infinite loop, consuming CPU and memory until it crashed or was terminated.

This commit enhances the `findAngularJsonFiles` function to make it resilient to such loops. It now uses `fs.stat` to retrieve the inode of each directory and tracks visited inodes in a Set. If a directory with a previously seen inode is encountered, it is skipped, effectively breaking the infinite loop.

This change adds a minor performance overhead due to the extra `stat` call per directory, but this is a trade-off for the increase in robustness and stability when operating on complex or untrusted file systems.
@clydin clydin added the target: major This PR is targeted for the next major release label Oct 15, 2025
@clydin clydin added the action: merge The PR is ready for merge by the caretaker label Oct 16, 2025
@clydin clydin merged commit 53180a8 into angular:main Oct 16, 2025
34 checks passed
@clydin clydin deleted the mcp/list_projects-inodes branch October 16, 2025 01:50
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: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants