Skip to main content
Glama

Prisma MCP Server

Official
by prisma
Apache 2.0
4
44,213
  • Linux
  • Apple
tests.ts1.88 kB
import { NewPrismaClient } from '../../_utils/types' import testMatrix from './_matrix' // @ts-ignore import type { PrismaClient } from './generated/prisma/client' declare const newPrismaClient: NewPrismaClient<PrismaClient, typeof PrismaClient> testMatrix.setupTestSuite( () => { let client: PrismaClient test('should log queries', async () => { client = newPrismaClient({ log: [ { emit: 'event', level: 'query', }, { emit: 'stdout', level: 'query', }, ], }) const queryLogPromise = ((): Promise<any> => new Promise((resolve) => { // @ts-expect-error client.$on('query', (data) => { if ('query' in data) { resolve(data) } }) }))() const consoleInfoMock = jest.spyOn(console, 'log').mockImplementation() await client.user.findMany() const consoleCalls = [...consoleInfoMock.mock.calls] consoleInfoMock.mockRestore() const queryLogEvents = await queryLogPromise expect(queryLogEvents).toHaveProperty('timestamp') expect(queryLogEvents).toHaveProperty('query') expect(queryLogEvents).toHaveProperty('params') expect(queryLogEvents).toHaveProperty('duration') expect(queryLogEvents).toHaveProperty('target') expect(queryLogEvents.query).toMatchInlineSnapshot(`"db.User.aggregate([ { $project: { _id: 1, }, }, ])"`) expect(consoleCalls.join('/n')).toMatchInlineSnapshot( `"prisma:query,db.User.aggregate([ { $project: { _id: 1, }, }, ])"`, ) }) }, { optOut: { from: ['cockroachdb', 'mysql', 'postgresql', 'sqlite', 'sqlserver'], reason: 'Only testing MongoDB provider(s) to replicate this issue', }, skipDefaultClientInstance: true, }, )

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