mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-25 17:54:34 +08:00
fix(mcp): pass nativeBinding to DatabaseManager for ABI compatibility
The MCP entry was loading better-sqlite3 from node_modules which may have been compiled for a different Node.js ABI. Now passes the pre-built native binding from apps/cli/native/ (maintained by ensure-native.mjs), matching how other CLI commands handle this. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
68652248fe
commit
584f581433
1 file changed
+11
-1
+11
-1
@@ -4,6 +4,8 @@
|
||||
* Thin wrapper: initializes Node.js runtime, then delegates to chatlab-mcp.
|
||||
*/
|
||||
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { loadConfig } from '@openchatlab/config'
|
||||
import {
|
||||
NodePathProvider,
|
||||
@@ -14,6 +16,13 @@ import {
|
||||
import { startMcpServer } from 'chatlab-mcp'
|
||||
import { getVersion } from './version'
|
||||
|
||||
function resolveNativeBinding(): string | undefined {
|
||||
if (process.versions.electron) return undefined
|
||||
const nativePath = path.resolve(__dirname, '../native/better_sqlite3.node')
|
||||
if (fs.existsSync(nativePath)) return nativePath
|
||||
return undefined
|
||||
}
|
||||
|
||||
function initMcpRuntime(): DatabaseManager {
|
||||
const config = loadConfig()
|
||||
const userDataDir = config.data.user_data_dir || undefined
|
||||
@@ -26,7 +35,8 @@ function initMcpRuntime(): DatabaseManager {
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
return new DatabaseManager(pathProvider)
|
||||
const nativeBinding = resolveNativeBinding()
|
||||
return new DatabaseManager(pathProvider, { nativeBinding })
|
||||
}
|
||||
|
||||
export async function startCliMcpServer(): Promise<void> {
|
||||
|
||||
Reference in new issue
Block a user