Skip to main content
Glama

Prisma MCP Server

Official
by prisma
Apache 2.0
4
44,192
  • Linux
  • Apple
loadSchemaFiles.ts1.65 kB
import path from 'node:path' import { FilesResolver, FsEntryType, realFsResolver } from './resolver' export type LoadedFile = [filePath: string, content: string] /** * Given folder name, returns list of all files composing a single prisma schema * @param folderPath */ export async function loadSchemaFiles( folderPath: string, filesResolver: FilesResolver = realFsResolver, ): Promise<LoadedFile[]> { const type = await filesResolver.getEntryType(folderPath) return processEntry(folderPath, type, filesResolver) } async function processEntry( entryPath: string, entryType: FsEntryType | undefined, filesResolver: FilesResolver, ): Promise<LoadedFile[]> { if (!entryType) { return [] } if (entryType.kind === 'symlink') { const realPath = entryType.realPath const realType = await filesResolver.getEntryType(realPath) return processEntry(realPath, realType, filesResolver) } if (entryType.kind === 'file') { if (path.extname(entryPath) !== '.prisma') { return [] } const content = await filesResolver.getFileContents(entryPath) if (typeof content === 'undefined') { return [] } return [[entryPath, content]] } if (entryType.kind === 'directory') { const dirEntries = await filesResolver.listDirContents(entryPath) const nested = await Promise.all( dirEntries.map(async (dirEntry) => { const fullPath = path.join(entryPath, dirEntry) const nestedEntryType = await filesResolver.getEntryType(fullPath) return processEntry(fullPath, nestedEntryType, filesResolver) }), ) return nested.flat() } return [] }

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/prisma/prisma'

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