Skip to main content
Glama
push-based

Angular Toolkit MCP

by push-based
file.resolver.ts1.62 kB
import { existsSync } from 'fs'; import { readFile } from 'fs/promises'; import * as path from 'path'; export const fileResolverCache = new Map<string, Promise<string>>(); /** * Resolves a file content from the file system, caching the result * to avoid reading the same file multiple times. * * This function returns a Promise that resolves to the file content. * This is important to avoid reading the same file multiple times. * @param filePath */ export async function resolveFileCached(filePath: string): Promise<string> { const normalizedPath = path.normalize(filePath); if (!existsSync(normalizedPath)) { throw new Error(`File not found: ${normalizedPath}`); } if (fileResolverCache.has(normalizedPath)) { const cachedPromise = fileResolverCache.get(normalizedPath); if (cachedPromise) { return cachedPromise; } } const fileReadOperationPromise = resolveFile(filePath) .then((content) => { fileResolverCache.set(normalizedPath, Promise.resolve(content)); return content; }) .catch((ctx) => { fileResolverCache.delete(normalizedPath); throw ctx; }); fileResolverCache.set(normalizedPath, fileReadOperationPromise); return fileReadOperationPromise; } /** * Resolves a file content from the file system directly, bypassing any cache. * * @param filePath */ export async function resolveFile(filePath: string): Promise<string> { const normalizedPath = path.normalize(filePath); if (!existsSync(normalizedPath)) { throw new Error(`File not found: ${normalizedPath}`); } return readFile(normalizedPath, 'utf-8'); }

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/push-based/angular-toolkit-mcp'

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