Skip to main content
Glama
nrwl

Nx MCP Server

Official
by nrwl
npm-dependencies.ts1.38 kB
import { join } from 'path'; import { directoryExists, readDirectory } from '@nx-console/shared-file-system'; /** * Get a flat list of all node_modules folders in the workspace. * This is needed to continue to support Angular CLI projects. * * @param workspacePath * @returns */ export async function npmDependencies(workspacePath: string) { const nodeModules = join(workspacePath, 'node_modules'); const nodeModulesEncapsulated = join( workspacePath, '.nx', 'installation', 'node_modules' ); let nodeModulesDir = nodeModules; const res: string[] = []; if (!(await directoryExists(nodeModules))) { if (!(await directoryExists(nodeModulesEncapsulated))) { return res; } else { nodeModulesDir = nodeModulesEncapsulated; } } const dirContents = await readDirectory(nodeModulesDir); for (const npmPackageOrScope of dirContents) { if (npmPackageOrScope.startsWith('.')) { continue; } if (!(await directoryExists(join(nodeModulesDir, npmPackageOrScope)))) { continue; } if (npmPackageOrScope.startsWith('@')) { (await readDirectory(join(nodeModulesDir, npmPackageOrScope))).forEach( (p) => { res.push(join(nodeModulesDir, npmPackageOrScope, p)); } ); } else { res.push(join(nodeModulesDir, npmPackageOrScope)); } } return res; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nrwl/nx-console'

If you have feedback or need assistance with the MCP directory API, please join our Discord server