datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
model User {
id String @id @default(cuid())
name String?
email String @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
// Optional for WebAuthn support
Authenticator Authenticator[]
mcpRequestLogs McpRequestLog[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Account {
userId String
type String
provider String
providerAccountId String
refresh_token String?
access_token String?
expires_at Int?
token_type String?
scope String?
id_token String?
session_state String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@id([provider, providerAccountId])
}
model Session {
sessionToken String @unique
userId String
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model VerificationToken {
identifier String
token String
expires DateTime
@@id([identifier, token])
}
// Optional for WebAuthn support
model Authenticator {
credentialID String @unique
userId String
providerAccountId String
credentialPublicKey String
counter Int
credentialDeviceType String
credentialBackedUp Boolean
transports String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@id([userId, credentialID])
}
model McpRequestLog {
id String @id @default(cuid())
timestamp DateTime @default(now())
functionName String
parameters Json? // Store parameters as JSON
results Json? // Store results as JSON
userId String? // Optional: to link logs to users
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId])
@@index([timestamp])
}
// MARK: OAUTH SERVER
model OauthClient {
id String @id @default(cuid())
clientId String @unique @map("client_id")
clientSecret String? @map("client_secret")
tokenEndpointAuthMethod String @map("token_endpoint_auth_method")
name String
description String?
logoUri String? @map("logo_uri")
redirectUris String[] @map("redirect_uris")
grantTypes String[] @map("grant_types")
scope String?
userId String? @map("user_id")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
authorizationCodes OauthAuthorizationCode[]
tokens OauthToken[]
@@map("oauth_client")
}
model OauthAuthorizationCode {
authorizationCode String @id @map("authorization_code")
expiresAt DateTime @map("expires_at")
redirectUri String @map("redirect_uri")
scope String?
authorizationDetails Json? @map("authorization_details")
codeChallenge String? @map("code_challenge")
codeChallengeMethod String? @map("code_challenge_method")
clientId String @map("client_id")
client OauthClient @relation(fields: [clientId], references: [id], onDelete: Cascade)
userId String @map("user_id")
createdAt DateTime @default(now()) @map("created_at")
@@map("oauth_authorization_code")
}
model OauthToken {
accessToken String @id @map("access_token")
accessTokenExpiresAt DateTime @map("access_token_expires_at")
refreshToken String? @unique @map("refresh_token")
refreshTokenExpiresAt DateTime? @map("refresh_token_expires_at")
scope String?
authorizationDetails Json? @map("authorization_details")
clientId String @map("client_id")
client OauthClient @relation(fields: [clientId], references: [id], onDelete: Cascade)
userId String @map("user_id")
createdAt DateTime @default(now()) @map("created_at")
@@map("oauth_token")
}