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.
| Column | Type | Description |
|---|
id | string (CUID) | Primary key |
clerkId | string? | Clerk user ID (null for dev-mode users) |
email | string | Email address |
name | string? | Display name |
avatarUrl | string? | Profile picture URL |
passwordHash | string? | Null for OAuth-only users |
createdAt | DateTime | Creation timestamp |
updatedAt | DateTime | Last update |
CLI session tokens.
| Column | Type | Description |
|---|
id | string (CUID) | Primary key |
userId | string | FK → User |
token | string | JWT value |
expiresAt | DateTime | Token expiry |
createdAt | DateTime | Creation timestamp |
| Column | Type | Description |
|---|
id | string (CUID) | Primary key |
orgId | string | FK → Organization |
userId | string | FK → User (creator) |
name | string | Human label |
prefix | string | First 8 chars, shown to user |
hash | string | bcrypt hash of full key |
scopes | string[] | Allowed scopes |
expiresAt | DateTime? | Optional expiry |
lastUsed | DateTime? | Last usage |
createdAt | DateTime | Creation timestamp |
| Column | Type | Description |
|---|
id | string (CUID) | Primary key |
clerkId | string? | Clerk org ID (null for dev-mode orgs) |
name | string | Display name |
slug | string | URL-safe slug |
plan | Plan enum | Current billing plan |
paymentCustomerId | string? | Stripe/Razorpay customer ID |
paymentProvider | BillingProvider? | Payment provider for this org |
logoUrl | string? | Org logo URL |
onboardingSeeded | boolean | Whether sample data was seeded |
microsoftTenantId | string? | Microsoft 365 tenant ID |
microsoftAdminConsentedAt | DateTime? | When M365 admin consent was granted |
microsoftAdminConsentedBy | string? | User ID of the admin who granted M365 consent |
createdAt | DateTime | Creation timestamp |
updatedAt | DateTime | Last update |
NO_PLAN FREE STANDARD PREMIUM ENTERPRISE
| Column | Type | Description |
|---|
id | string (CUID) | Primary key |
orgId | string | FK → Organization |
userId | string | FK → User |
role | OrgRole enum | Member role |
onboardingCompleted | boolean | Onboarding done flag |
workspaceOrder | JSON? | Custom sort order of workspace IDs |
joinedAt | DateTime | Join timestamp |
OWNER ADMIN MEMBER VIEWER
| Column | Type | Description |
|---|
id | string (CUID) | Primary key |
orgId | string | FK → Organization |
email | string | Invitee email |
role | OrgRole enum | Invited role |
token | string | Secure invite token |
expiresAt | DateTime | Token expiry |
createdAt | DateTime | Creation timestamp |
| Column | Type | Description |
|---|
id | string (CUID) | Primary key |
orgId | string | FK → Organization |
name | string | Display name |
slug | string | URL-safe slug |
isPersonal | boolean | Auto-created personal team |
userId | string | FK → User (owner) |
createdAt | DateTime | Creation timestamp |
updatedAt | DateTime | Last update |
| Column | Type | Description |
|---|
id | string (CUID) | Primary key |
teamId | string | FK → Team |
userId | string | FK → User |
role | TeamRole enum | OWNER / MEMBER |
addedBy | string | FK → User who added this member |
addedAt | DateTime | Join timestamp |
Workspaces are scoped under a Team. There is no direct orgId — org is accessed via team.orgId.
| Column | Type | Description |
|---|
id | string (CUID) | Primary key |
teamId | string | FK → Team |
name | string | Display name |
slug | string | URL-safe slug |
description | string? | Optional description |
archived | boolean | Soft-delete flag |
createdBy | string | FK → User (creator) |
createdAt | DateTime | Creation timestamp |
updatedAt | DateTime | Last update |
Metadata index for all cloud-stored files.
| Column | Type | Description |
|---|
id | string (CUID) | Primary key |
orgId | string | FK → Organization |
workspaceId | string? | FK → Workspace (null = org-level) |
folderId | string? | FK → ArtifactFolder |
kind | StorageKind enum | File type |
scope | StorageScope enum | Visibility |
ownerUserId | string? | Set when scope=PERSONAL |
storageKey | string | R2/S3 object key (unique) |
path | string | User-facing display path |
title | string | Display title |
mimeType | string | MIME type |
sizeBytes | int | File size in bytes |
checksum | string | SHA-256 for sync/conflict detection |
version | int | Incremented on update |
metadata | JSON? | Kind-specific metadata |
createdBy | string | FK → User |
updatedBy | string | FK → User |
createdAt | DateTime | Creation timestamp |
updatedAt | DateTime | Last update |
ARTIFACT HUB_MEMORY TEAM_MEMORY WORKSPACE_MEMORY TEMPLATE BRAND_ASSET
| Column | Type | Description |
|---|
id | string (CUID) | Primary key |
workspaceId | string | FK → Workspace |
parentId | string? | FK → ArtifactFolder (null = top-level) |
name | string | Folder name |
sortOrder | int | Display order |
aiGenerated | boolean | Created by AI suggestion |
createdAt | DateTime | Creation timestamp |
updatedAt | DateTime | Last update |
Stripe/Razorpay customer IDs are not stored here. The payment customer ID lives on Organization.paymentCustomerId.
| Column | Type | Description |
|---|
id | string (CUID) | Primary key |
orgId | string | FK → Organization (unique) |
provider | BillingProvider enum | STRIPE / RAZORPAY / MANUAL |
externalId | string? | Stripe/Razorpay subscription ID (null for MANUAL contracts) |
plan | Plan enum | Subscribed plan |
status | SubscriptionStatus enum | Current status |
currentPeriodStart | DateTime | Billing period start |
currentPeriodEnd | DateTime | Billing period end |
cancelAtPeriodEnd | boolean | Scheduled cancellation |
purchasedSeats | int? | Null = metered; set for ENTERPRISE contracts |
createdAt | DateTime | Creation timestamp |
updatedAt | DateTime | Last update |
ACTIVE PAST_DUE CANCELED TRIALING PAUSED
| Column | Type | Description |
|---|
id | string (CUID) | Primary key |
orgId | string | FK → Organization |
userId | string | FK → User |
type | UsageType enum | Usage category |
inputTokens | int | Input tokens used |
outputTokens | int | Output tokens used |
model | string? | LLM model ID |
costUsd | Decimal | Calculated cost in USD |
metadata | JSON? | Extra context |
createdAt | DateTime | Usage timestamp |
LLM_CHAT LLM_AGENT MCP_CALL SYNC_OPERATION STORAGE
| Column | Type | Description |
|---|
id | string (CUID) | Primary key |
orgId | string | FK → Organization |
changedBy | string | Admin email or script name |
oldSeats | int | Seat count before change |
newSeats | int | Seat count after change |
notes | string? | Reason for change |
createdAt | DateTime | Audit timestamp |
Registry of available MCP integrations.
| Column | Type | Description |
|---|
id | string (CUID) | Primary key |
serverId | string | Unique provider slug (e.g. "notion") |
displayName | string | Human name |
description | string? | Short description |
iconUrl | string? | Logo URL |
category | string? | Category for UI grouping |
authMode | AuthMode enum | Auth type |
authUrl | string? | OAuth authorization URL |
tokenUrl | string? | OAuth token exchange URL |
clientId | string? | OAuth client ID |
clientSecret | string? | OAuth client secret (encrypted) |
scopes | string[] | OAuth scopes to request |
authStyle | string | header / body |
authParams | JSON? | Extra OAuth parameters |
credentialMap | JSON? | Maps OAuth response fields to credential keys |
mcpCommand | string? | STDIO command |
mcpArgs | string[]? | STDIO args |
mcpUrl | string? | HTTP/SSE URL |
mcpUrls | JSON? | Multi-tenant URL map |
mcpTransport | MCPTransport enum | STDIO / SSE / HTTP |
perUserAuth | boolean | Auth is per-user, not per-org |
requiresAdminConsent | boolean | Requires org admin to consent first |
enabled | boolean | Show in catalog |
createdAt | DateTime | Creation timestamp |
updatedAt | DateTime | Last update |
SERVER_MEDIATED REMOTE_OAUTH API_KEY NONE
Per-org connector instances.
| Column | Type | Description |
|---|
id | string (CUID) | Primary key |
orgId | string | FK → Organization |
userId | string? | FK → User (null = org-shared) |
serverId | string | FK → ConnectorProvider |
instanceId | string | Unique instance ID |
label | string | Human-readable name |
hosting | MCPHosting enum | CLOUD / LOCAL |
transport | MCPTransport enum | STDIO / SSE / HTTP |
config | JSON | Server-specific config (command, args, url, etc.) |
credentials | JSON? | Encrypted OAuth tokens / API keys |
status | MCPStatus enum | CONNECTED / DISCONNECTED / CONNECTING / ERROR |
lastError | string? | Last error message |
lastUsedAt | DateTime? | Last usage timestamp |
createdBy | string | userId who connected this instance |
createdAt | DateTime | Creation timestamp |
updatedAt | DateTime | Last update |
| Column | Type | Description |
|---|
id | string (CUID) | Primary key |
orgId | string | FK → Organization |
workspaceId | string? | FK → Workspace (null = org-level) |
title | string | Task title |
description | string? | Detailed description |
status | TaskStatus enum | Current status |
priority | TaskPriority enum | Priority level |
assigneeId | string? | FK → User (null = unassigned) |
createdBy | string | FK → User (creator) |
dueDate | DateTime? | Optional due date |
completedAt | DateTime? | Set when status = DONE |
tags | string[] | Label tags |
metadata | JSON? | Extra AI-managed data |
sortOrder | int | For manual reordering |
createdAt | DateTime | Creation timestamp |
updatedAt | DateTime | Last update |
TODO IN_PROGRESS DONE CANCELLED
| Column | Type | Description |
|---|
id | string (CUID) | Primary key |
version | string | Semantic version (e.g. "2026.4.30") |
platform | AppPlatform enum | DARWIN / WIN32 / LINUX |
arch | AppArch enum | X64 / ARM64 / UNIVERSAL |
channel | ReleaseChannel enum | STABLE / BETA / CANARY |
downloadUrl | string | File download URL |
sha512 | string | SHA-512 hash |
fileSizeBytes | int? | File size |
releaseNotes | string? | Markdown release notes |
minOsVersion | string? | Minimum OS version required |
signature | string? | Code signature |
mandatory | boolean | Force update flag |
rolloutPercentage | int | Percentage of clients to target |
active | boolean | Available for serving |
metadata | JSON? | Extra metadata |
publishedAt | DateTime | Publish timestamp |
createdAt | DateTime | Creation timestamp |
updatedAt | DateTime | Last update |
Skills, agents, and integrations shared publicly.
| Column | Type | Description |
|---|
id | string (CUID) | Primary key |
type | ListingType enum | MCP_SERVER / SKILL / AGENT / INTEGRATION |
name | string | Listing name (unique) |
displayName | string | Human-readable name |
description | string | Description |
version | string | Semver |
authorId | string | FK → User (publisher) |
orgId | string? | FK → Organization (publisher org) |
priceUsd | Decimal? | Null = free |
downloads | int | Install count |
rating | Decimal? | Average rating |
ratingCount | int | Number of ratings |
tags | string[] | Searchable tags |
definition | JSON | MCP config / Skill def / Agent def |
readme | string? | Markdown readme |
iconUrl | string? | Icon URL |
verified | boolean | Verified by Cosmo team |
published | boolean | Visible in marketplace |
createdAt | DateTime | Publish timestamp |
updatedAt | DateTime | Last update |
MCP_SERVER SKILL AGENT INTEGRATION
| Column | Type | Description |
|---|
id | string (CUID) | Primary key |
listingId | string | FK → MarketplaceListing |
userId | string | FK → User |
rating | int | 1–5 |
comment | string? | Review text |
createdAt | DateTime | Creation timestamp |