Skip to main content
Glama

Prisma MCP Server

Official
by prisma
Apache 2.0
4
44,192
  • Linux
  • Apple
resolveOutput.ts1.49 kB
import fs from 'fs' import path from 'path' import { promisify } from 'util' const exists = promisify(fs.exists) async function resolveNodeModulesBase(cwd: string): Promise<string> { if (await exists(path.resolve(process.cwd(), 'prisma/schema.prisma'))) { return process.cwd() } if (path.relative(process.cwd(), cwd) === 'prisma' && (await exists(path.resolve(process.cwd(), 'package.json')))) { return process.cwd() } if (await exists(path.resolve(cwd, 'node_modules'))) { return cwd } if (await exists(path.resolve(cwd, '../node_modules'))) { return path.join(cwd, '../') } if (await exists(path.resolve(cwd, 'package.json'))) { return cwd } if (await exists(path.resolve(cwd, '../package.json'))) { return path.join(cwd, '../') } return cwd } export type ResolveOutputOptions = { defaultOutput: string baseDir: string // normally `schemaDir`, the dir containing the schema.prisma file } export async function resolveOutput(options: ResolveOutputOptions): Promise<string> { const defaultOutput = stripRelativePath(options.defaultOutput) if (defaultOutput.startsWith('node_modules')) { const nodeModulesBase = await resolveNodeModulesBase(options.baseDir) return path.resolve(nodeModulesBase, defaultOutput) } return path.resolve(options.baseDir, defaultOutput) } function stripRelativePath(pathString: string): string { if (pathString.startsWith('./')) { return pathString.slice(2) } return pathString }

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