Cosmo Docs
Server

Database Schema

Prisma schema — all models, enums, and relations

The canonical schema is packages/server/src/prisma/schema.prisma. Generated enum constants live in packages/server/src/generated/prisma/enums.ts.

Auth & Identity

User

ColumnTypeDescription
idstring (CUID)Primary key
clerkIdstring?Clerk user ID (null for dev-mode users)
emailstringEmail address
namestring?Display name
avatarUrlstring?Profile picture URL
passwordHashstring?Null for OAuth-only users
createdAtDateTimeCreation timestamp
updatedAtDateTimeLast update

Session

CLI session tokens.

ColumnTypeDescription
idstring (CUID)Primary key
userIdstringFK → User
tokenstringJWT value
expiresAtDateTimeToken expiry
createdAtDateTimeCreation timestamp

ApiKey

ColumnTypeDescription
idstring (CUID)Primary key
orgIdstringFK → Organization
userIdstringFK → User (creator)
namestringHuman label
prefixstringFirst 8 chars, shown to user
hashstringbcrypt hash of full key
scopesstring[]Allowed scopes
expiresAtDateTime?Optional expiry
lastUsedDateTime?Last usage
createdAtDateTimeCreation timestamp

Multi-Tenancy

Organization

ColumnTypeDescription
idstring (CUID)Primary key
clerkIdstring?Clerk org ID (null for dev-mode orgs)
namestringDisplay name
slugstringURL-safe slug
planPlan enumCurrent billing plan
paymentCustomerIdstring?Stripe/Razorpay customer ID
paymentProviderBillingProvider?Payment provider for this org
logoUrlstring?Org logo URL
onboardingSeededbooleanWhether sample data was seeded
microsoftTenantIdstring?Microsoft 365 tenant ID
microsoftAdminConsentedAtDateTime?When M365 admin consent was granted
microsoftAdminConsentedBystring?User ID of the admin who granted M365 consent
createdAtDateTimeCreation timestamp
updatedAtDateTimeLast update

Plan enum

NO_PLAN  FREE  STANDARD  PREMIUM  ENTERPRISE

OrgMember

ColumnTypeDescription
idstring (CUID)Primary key
orgIdstringFK → Organization
userIdstringFK → User
roleOrgRole enumMember role
onboardingCompletedbooleanOnboarding done flag
workspaceOrderJSON?Custom sort order of workspace IDs
joinedAtDateTimeJoin timestamp

OrgRole enum

OWNER  ADMIN  MEMBER  VIEWER

OrgInvite

ColumnTypeDescription
idstring (CUID)Primary key
orgIdstringFK → Organization
emailstringInvitee email
roleOrgRole enumInvited role
tokenstringSecure invite token
expiresAtDateTimeToken expiry
createdAtDateTimeCreation timestamp

Teams & Workspaces

Team

ColumnTypeDescription
idstring (CUID)Primary key
orgIdstringFK → Organization
namestringDisplay name
slugstringURL-safe slug
isPersonalbooleanAuto-created personal team
userIdstringFK → User (owner)
createdAtDateTimeCreation timestamp
updatedAtDateTimeLast update

TeamMember

ColumnTypeDescription
idstring (CUID)Primary key
teamIdstringFK → Team
userIdstringFK → User
roleTeamRole enumOWNER / MEMBER
addedBystringFK → User who added this member
addedAtDateTimeJoin timestamp

Workspace

Workspaces are scoped under a Team. There is no direct orgId — org is accessed via team.orgId.

ColumnTypeDescription
idstring (CUID)Primary key
teamIdstringFK → Team
namestringDisplay name
slugstringURL-safe slug
descriptionstring?Optional description
archivedbooleanSoft-delete flag
createdBystringFK → User (creator)
createdAtDateTimeCreation timestamp
updatedAtDateTimeLast update

Storage

StorageObject

Metadata index for all cloud-stored files.

ColumnTypeDescription
idstring (CUID)Primary key
orgIdstringFK → Organization
workspaceIdstring?FK → Workspace (null = org-level)
folderIdstring?FK → ArtifactFolder
kindStorageKind enumFile type
scopeStorageScope enumVisibility
ownerUserIdstring?Set when scope=PERSONAL
storageKeystringR2/S3 object key (unique)
pathstringUser-facing display path
titlestringDisplay title
mimeTypestringMIME type
sizeBytesintFile size in bytes
checksumstringSHA-256 for sync/conflict detection
versionintIncremented on update
metadataJSON?Kind-specific metadata
createdBystringFK → User
updatedBystringFK → User
createdAtDateTimeCreation timestamp
updatedAtDateTimeLast update

StorageKind enum

ARTIFACT  HUB_MEMORY  TEAM_MEMORY  WORKSPACE_MEMORY  TEMPLATE  BRAND_ASSET

StorageScope enum

SHARED  PERSONAL

ArtifactFolder

ColumnTypeDescription
idstring (CUID)Primary key
workspaceIdstringFK → Workspace
parentIdstring?FK → ArtifactFolder (null = top-level)
namestringFolder name
sortOrderintDisplay order
aiGeneratedbooleanCreated by AI suggestion
createdAtDateTimeCreation timestamp
updatedAtDateTimeLast update

Billing & Metering

Subscription

Stripe/Razorpay customer IDs are not stored here. The payment customer ID lives on Organization.paymentCustomerId.

ColumnTypeDescription
idstring (CUID)Primary key
orgIdstringFK → Organization (unique)
providerBillingProvider enumSTRIPE / RAZORPAY / MANUAL
externalIdstring?Stripe/Razorpay subscription ID (null for MANUAL contracts)
planPlan enumSubscribed plan
statusSubscriptionStatus enumCurrent status
currentPeriodStartDateTimeBilling period start
currentPeriodEndDateTimeBilling period end
cancelAtPeriodEndbooleanScheduled cancellation
purchasedSeatsint?Null = metered; set for ENTERPRISE contracts
createdAtDateTimeCreation timestamp
updatedAtDateTimeLast update

SubscriptionStatus enum

ACTIVE  PAST_DUE  CANCELED  TRIALING  PAUSED

UsageRecord

ColumnTypeDescription
idstring (CUID)Primary key
orgIdstringFK → Organization
userIdstringFK → User
typeUsageType enumUsage category
inputTokensintInput tokens used
outputTokensintOutput tokens used
modelstring?LLM model ID
costUsdDecimalCalculated cost in USD
metadataJSON?Extra context
createdAtDateTimeUsage timestamp

UsageType enum

LLM_CHAT  LLM_AGENT  MCP_CALL  SYNC_OPERATION  STORAGE

EnterpriseSeatAudit

ColumnTypeDescription
idstring (CUID)Primary key
orgIdstringFK → Organization
changedBystringAdmin email or script name
oldSeatsintSeat count before change
newSeatsintSeat count after change
notesstring?Reason for change
createdAtDateTimeAudit timestamp

Connectors & Integrations

ConnectorProvider

Registry of available MCP integrations.

ColumnTypeDescription
idstring (CUID)Primary key
serverIdstringUnique provider slug (e.g. "notion")
displayNamestringHuman name
descriptionstring?Short description
iconUrlstring?Logo URL
categorystring?Category for UI grouping
authModeAuthMode enumAuth type
authUrlstring?OAuth authorization URL
tokenUrlstring?OAuth token exchange URL
clientIdstring?OAuth client ID
clientSecretstring?OAuth client secret (encrypted)
scopesstring[]OAuth scopes to request
authStylestringheader / body
authParamsJSON?Extra OAuth parameters
credentialMapJSON?Maps OAuth response fields to credential keys
mcpCommandstring?STDIO command
mcpArgsstring[]?STDIO args
mcpUrlstring?HTTP/SSE URL
mcpUrlsJSON?Multi-tenant URL map
mcpTransportMCPTransport enumSTDIO / SSE / HTTP
perUserAuthbooleanAuth is per-user, not per-org
requiresAdminConsentbooleanRequires org admin to consent first
enabledbooleanShow in catalog
createdAtDateTimeCreation timestamp
updatedAtDateTimeLast update

AuthMode enum

SERVER_MEDIATED  REMOTE_OAUTH  API_KEY  NONE

MCPConfig

Per-org connector instances.

ColumnTypeDescription
idstring (CUID)Primary key
orgIdstringFK → Organization
userIdstring?FK → User (null = org-shared)
serverIdstringFK → ConnectorProvider
instanceIdstringUnique instance ID
labelstringHuman-readable name
hostingMCPHosting enumCLOUD / LOCAL
transportMCPTransport enumSTDIO / SSE / HTTP
configJSONServer-specific config (command, args, url, etc.)
credentialsJSON?Encrypted OAuth tokens / API keys
statusMCPStatus enumCONNECTED / DISCONNECTED / CONNECTING / ERROR
lastErrorstring?Last error message
lastUsedAtDateTime?Last usage timestamp
createdBystringuserId who connected this instance
createdAtDateTimeCreation timestamp
updatedAtDateTimeLast update

Tasks

Task

ColumnTypeDescription
idstring (CUID)Primary key
orgIdstringFK → Organization
workspaceIdstring?FK → Workspace (null = org-level)
titlestringTask title
descriptionstring?Detailed description
statusTaskStatus enumCurrent status
priorityTaskPriority enumPriority level
assigneeIdstring?FK → User (null = unassigned)
createdBystringFK → User (creator)
dueDateDateTime?Optional due date
completedAtDateTime?Set when status = DONE
tagsstring[]Label tags
metadataJSON?Extra AI-managed data
sortOrderintFor manual reordering
createdAtDateTimeCreation timestamp
updatedAtDateTimeLast update

TaskStatus enum

TODO  IN_PROGRESS  DONE  CANCELLED

TaskPriority enum

LOW  MEDIUM  HIGH  URGENT

App Releases

AppRelease

ColumnTypeDescription
idstring (CUID)Primary key
versionstringSemantic version (e.g. "2026.4.30")
platformAppPlatform enumDARWIN / WIN32 / LINUX
archAppArch enumX64 / ARM64 / UNIVERSAL
channelReleaseChannel enumSTABLE / BETA / CANARY
downloadUrlstringFile download URL
sha512stringSHA-512 hash
fileSizeBytesint?File size
releaseNotesstring?Markdown release notes
minOsVersionstring?Minimum OS version required
signaturestring?Code signature
mandatorybooleanForce update flag
rolloutPercentageintPercentage of clients to target
activebooleanAvailable for serving
metadataJSON?Extra metadata
publishedAtDateTimePublish timestamp
createdAtDateTimeCreation timestamp
updatedAtDateTimeLast update

Marketplace

MarketplaceListing

Skills, agents, and integrations shared publicly.

ColumnTypeDescription
idstring (CUID)Primary key
typeListingType enumMCP_SERVER / SKILL / AGENT / INTEGRATION
namestringListing name (unique)
displayNamestringHuman-readable name
descriptionstringDescription
versionstringSemver
authorIdstringFK → User (publisher)
orgIdstring?FK → Organization (publisher org)
priceUsdDecimal?Null = free
downloadsintInstall count
ratingDecimal?Average rating
ratingCountintNumber of ratings
tagsstring[]Searchable tags
definitionJSONMCP config / Skill def / Agent def
readmestring?Markdown readme
iconUrlstring?Icon URL
verifiedbooleanVerified by Cosmo team
publishedbooleanVisible in marketplace
createdAtDateTimePublish timestamp
updatedAtDateTimeLast update

ListingType enum

MCP_SERVER  SKILL  AGENT  INTEGRATION

MarketplaceReview

ColumnTypeDescription
idstring (CUID)Primary key
listingIdstringFK → MarketplaceListing
userIdstringFK → User
ratingint1–5
commentstring?Review text
createdAtDateTimeCreation timestamp