()
| 25 | } |
| 26 | |
| 27 | export function initMcpRuntime(): DatabaseManager { |
| 28 | const config = loadConfig() |
| 29 | const userDataDir = config.data.user_data_dir || undefined |
| 30 | const pathProvider = new NodePathProvider(userDataDir) |
| 31 | pathProvider.ensureAllDirs() |
| 32 | const runtime = assertCliDataDirCompatible(pathProvider, 'mcp') |
| 33 | |
| 34 | if (hasPendingElectronDataWarning() || !verifyCliDataPath(pathProvider.getDatabaseDir())) { |
| 35 | console.error('[MCP] Electron desktop data detected but databases not found.') |
| 36 | console.error('[MCP] Set CHATLAB_DATA_DIR or edit ~/.chatlab/config.toml to point to your data directory.') |
| 37 | process.exit(1) |
| 38 | } |
| 39 | |
| 40 | const nativeBinding = resolveNativeBinding() |
| 41 | return new DatabaseManager(pathProvider, { nativeBinding, runtime }) |
| 42 | } |
| 43 | |
| 44 | export async function startCliMcpServer(): Promise<void> { |
| 45 | const dbManager = initMcpRuntime() |
no test coverage detected