Skip to main content
Glama
nrwl

Nx MCP Server

Official
by nrwl
read-json.ts877 B
import { join } from 'path'; import { findNxPackagePath } from '../find-nx-package-path'; import { importWorkspaceDependency } from '../workspace-dependencies'; import type * as NxFileUtils from 'nx/src/utils/fileutils'; import { readFileSync } from 'fs'; export async function readJsonFile<T>( jsonPath: string, workspacePath: string, ): Promise<T> { const importPath = await findNxPackagePath( workspacePath, join('src', 'utils', 'fileutils.js'), ); if (importPath) { const fileUtils = await importWorkspaceDependency<typeof NxFileUtils>(importPath); return fileUtils.readJsonFile(join(workspacePath, jsonPath), { allowTrailingComma: true, expectComments: true, }) as any; } else { const filePath = join(workspacePath, jsonPath); const content = readFileSync(filePath, 'utf8'); return JSON.parse(content); } }

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