Skip to main content
Glama
prisma

Prisma MCP Server

Official
by prisma
ppgInfo.ts1.31 kB
import { ServerState } from '@prisma/dev/internal/state' /** * Collects information about whether the given url connects to a Prisma Postgres remote or local database. * Mimicking parts of the tracking logic in the Prisma VSCode extension. */ export async function getPpgInfo(connectionString: string) { const url = new URL(connectionString) const isLocalhost = url.hostname === 'localhost' || url.hostname === '127.0.0.1' || url.hostname === '[::1]' || url.hostname === '[0:0:0:0:0:0:0:1]' let type: 'remote' | 'local' | undefined if (url.protocol === 'prisma+postgres:' && url.hostname === 'accelerate.prisma-data.net') { type = 'remote' } else if ((url.protocol === 'postgres:' || url.protocol === 'postgresql:') && url.hostname === 'db.prisma.io') { type = 'remote' } else if (url.protocol === 'prisma+postgres:' && isLocalhost) { type = 'local' } else if ((url.protocol === 'postgres:' || url.protocol === 'postgresql:') && isLocalhost) { const servers = await ServerState.scan() for (const server of servers) { if ( server.status === 'running' && [server.databasePort, server.shadowDatabasePort].includes(parseInt(url.port ?? '')) ) { type = 'local' } } } return type ? { ppg: { type } } : {} }

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

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