Back to Cherry Studio

McpServerMigrator

src/main/data/migration/v2/migrators/README-McpServerMigrator.md

2.0.03.0 KB
Original Source

McpServerMigrator

Migrates MCP server configurations from Redux to SQLite.

Data Sources

SourcePathDescription
Reduxstate.mcp.serversArray of McpServer objects

Target Table

mcp_server (defined in src/main/data/db/schemas/mcpServer.ts)

Skipped Fields (Runtime/Cache)

FieldReasonV2 Target
isUvInstalled, isBunInstalledDerived from live binary availabilityNot persisted

Not Migrated (Regenerable Cache)

SourceReasonV2 Target
Dexie mcp:provider:*:serversRe-fetched from provider APIHandled in separate PR

Field Mappings

All McpServer fields are mapped 1:1 at the Drizzle ORM level (camelCase property names). The underlying SQLite columns use snake_case (e.g., baseUrlbase_url), handled automatically by Drizzle:

Source FieldTarget ColumnTransform
ididDirect (PK)
namenameUses source name; falls back to the generated id when missing/empty/whitespace-only
typetypeNullable passthrough
descriptiondescriptionNullable passthrough
baseUrl / urlbaseUrlFalls back from url if baseUrl is absent (legacy SSE servers)
commandcommandNullable passthrough
registryUrlregistryUrlNullable passthrough
argsargsJSON array
envenvJSON object
headersheadersJSON object
providerproviderNullable passthrough
providerUrlproviderUrlNullable passthrough
logoUrllogoUrlNullable passthrough
tagstagsJSON array
longRunninglongRunningNullable boolean
timeouttimeoutNullable integer
dxtVersiondxtVersionNullable passthrough
dxtPathdxtPathNullable passthrough
referencereferenceNullable passthrough
searchKeysearchKeyNullable passthrough
configSampleconfigSampleJSON object
disabledToolsdisabledToolsJSON array
disabledAutoApproveToolsdisabledAutoApproveToolsJSON array
shouldConfigshouldConfigNullable boolean
isActiveisActiveBoolean (NOT NULL, default false)
installSourceinstallSourceNullable passthrough
isTrustedisTrustedNullable boolean
trustedAttrustedAtNullable integer (timestamp)
installedAtinstalledAtNullable integer (timestamp)

Edge Cases

  • Missing id: Server is skipped with warning
  • Empty id: Server is skipped with warning
  • Missing/empty/whitespace-only name: Uses the generated id as the migrated name
  • Duplicate id: Second occurrence is skipped, first is kept
  • Missing isActive: Defaults to false
  • undefined/null optional fields: Stored as null in SQLite

Execution Order

order = 1.5 (after PreferencesMigrator=1, before AssistantMigrator=2)