Command
other
Is this a regression?
The previous version in which this bug was not present was
No response
Description
The list_projects MCP tool can fail immediately with:
EBADF: bad file descriptor, lstat '/dev/fd/12'
This appears to happen when the MCP host provides a root path backed by a file descriptor such as /dev/fd/12. For me specifically this happens in Codex Mac app.
From reading the tool source, createListProjectsHandler() collects roots from MCP listRoots() and then passes them into findAngularJsonFiles(). The implementation assumes those roots are normal filesystem directories and performs operations such as stat(rootDir), realpathSync(root), and directory traversal. When the root is a descriptor-backed path like /dev/fd/12, those calls can fail with EBADF.
The tool currently ignores some filesystem errors (EACCES, EPERM, ENOENT, EBUSY) but not EBADF, so the tool aborts instead of skipping the invalid root or falling back gracefully.
This looks like a robustness issue in the tool: even if an MCP client provides an unusual root, the tool should not hard-fail during workspace discovery.
Minimal Reproduction
Minimal Reproduction
- Run the Angular CLI MCP tool list_projects in an environment where the MCP host exposes roots that resolve to
/dev/fd/<n> rather than stable directory paths. I use Codex mac app.
- Invoke the tool without arguments.
- Observe that it fails with:
EBADF: bad file descriptor, lstat '/dev/fd/12'
Relevant code path from the tool source:
createListProjectsHandler() obtains searchRoots from MCP listRoots()
- roots are normalized with
fileURLToPath(...)
- roots are passed to
findAngularJsonFiles(root, realAllowedRoots)
findAngularJsonFiles() calls stat(rootDir)
- root resolution also uses
ealpathSync(r) for allowed roots
Because the root is not a stable directory path, traversal fails before any Angular workspace parsing happens.
Exception or Error
`EBADF: bad file descriptor, lstat '/dev/fd/12'`
Your Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI : 21.2.3
Angular : 21.2.5
Node.js : 24.10.0
Package Manager : npm 11.12.1
Operating System : darwin arm64
┌───────────────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────────────┼───────────────────┼───────────────────┤
│ @angular/animations │ 21.2.5 │ ^21.2.0 │
│ @angular/build │ 21.2.3 │ ^21.2.0 │
│ @angular/cdk │ 21.2.3 │ ^21.2.0 │
│ @angular/cli │ 21.2.3 │ ^21.2.0 │
│ @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/material │ 21.2.3 │ ^21.2.0 │
│ @angular/platform-browser │ 21.2.5 │ ^21.2.0 │
│ @angular/platform-browser-dynamic │ 21.2.5 │ ^21.2.0 │
│ @angular/router │ 21.2.5 │ ^21.2.0 │
│ @angular/service-worker │ 21.2.5 │ ^21.2.0 │
│ ng-packagr │ 21.2.1 │ ^21.2.0 │
│ rxjs │ 7.8.2 │ ^7.8.2 │
│ typescript │ 5.9.3 │ ~5.9.3 │
│ vitest │ 4.1.0 │ ^4.0.18 │
└───────────────────────────────────┴───────────────────┴───────────────────┘
Anything else relevant?
No response
Command
other
Is this a regression?
The previous version in which this bug was not present was
No response
Description
The
list_projectsMCP tool can fail immediately with:EBADF: bad file descriptor, lstat '/dev/fd/12'This appears to happen when the MCP host provides a root path backed by a file descriptor such as
/dev/fd/12. For me specifically this happens in Codex Mac app.From reading the tool source,
createListProjectsHandler()collects roots from MCPlistRoots()and then passes them intofindAngularJsonFiles(). The implementation assumes those roots are normal filesystem directories and performs operations such asstat(rootDir),realpathSync(root), and directory traversal. When the root is a descriptor-backed path like/dev/fd/12, those calls can fail withEBADF.The tool currently ignores some filesystem errors (
EACCES,EPERM,ENOENT,EBUSY) but notEBADF, so the tool aborts instead of skipping the invalid root or falling back gracefully.This looks like a robustness issue in the tool: even if an MCP client provides an unusual root, the tool should not hard-fail during workspace discovery.
Minimal Reproduction
Minimal Reproduction
/dev/fd/<n>rather than stable directory paths. I use Codex mac app.EBADF: bad file descriptor, lstat '/dev/fd/12'Relevant code path from the tool source:
createListProjectsHandler()obtains searchRoots from MCPlistRoots()fileURLToPath(...)findAngularJsonFiles(root, realAllowedRoots)findAngularJsonFiles()callsstat(rootDir)ealpathSync(r)for allowed rootsBecause the root is not a stable directory path, traversal fails before any Angular workspace parsing happens.
Exception or Error
Your Environment
Anything else relevant?
No response