Skip to content

Commit 862f000

Browse files
author
deepinsect
committed
Merge branch 'dev' of github.os:ThinkInAIXYZ/deepchat into dev
2 parents 753587c + 3bb6a51 commit 862f000

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

src/main/presenter/configPresenter/mcpConfHelper.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ const DEFAULT_MCP_SERVERS = {
2121
env: {},
2222
descriptions: '',
2323
icons: '📁',
24-
autoApprove: ['all'],
24+
autoApprove: ['read'],
2525
type: 'stdio' as 'stdio' | 'sse',
26-
disable: true
26+
disable: false
2727
},
2828
memory: {
2929
command: 'npx',
@@ -32,7 +32,7 @@ const DEFAULT_MCP_SERVERS = {
3232
descriptions: '内存存储服务',
3333
icons: '🧠',
3434
autoApprove: ['all'],
35-
disable: false,
35+
disable: true,
3636
type: 'stdio' as 'stdio' | 'sse'
3737
},
3838
bitcoin: {
@@ -54,7 +54,7 @@ const DEFAULT_MCP_SERVERS = {
5454
env: {}
5555
}
5656
},
57-
defaultServer: 'memory',
57+
defaultServer: 'filesystem',
5858
mcpEnabled: false // 默认关闭MCP功能
5959
}
6060

src/main/presenter/syncPresenter/index.ts

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export class SyncPresenter implements ISyncPresenter {
2222
private backupTimer: NodeJS.Timeout | null = null
2323
private readonly BACKUP_DELAY = 60 * 1000 // 60秒无变更后触发备份
2424
private readonly APP_SETTINGS_PATH = path.join(app.getPath('userData'), 'app-settings.json')
25+
private readonly MCP_SETTINGS_PATH = path.join(app.getPath('userData'), 'mcp-settings.json')
2526
private readonly PROVIDER_MODELS_DIR_PATH = path.join(app.getPath('userData'), 'provider_models')
2627
private readonly DB_PATH = path.join(app.getPath('userData'), 'app_db', 'chat.db')
2728

@@ -142,7 +143,7 @@ export class SyncPresenter implements ISyncPresenter {
142143
const tempDbPath = path.join(app.getPath('temp'), `chat_${Date.now()}.db`)
143144
const tempAppSettingsPath = path.join(app.getPath('temp'), `app_settings_${Date.now()}.json`)
144145
const tempProviderModelsPath = path.join(app.getPath('temp'), `provider_models_${Date.now()}`)
145-
146+
const tempMcpSettingsPath = path.join(app.getPath('temp'), `mcp_settings_${Date.now()}.json`)
146147
// 创建临时备份
147148
if (fs.existsSync(this.DB_PATH)) {
148149
fs.copyFileSync(this.DB_PATH, tempDbPath)
@@ -152,6 +153,10 @@ export class SyncPresenter implements ISyncPresenter {
152153
fs.copyFileSync(this.APP_SETTINGS_PATH, tempAppSettingsPath)
153154
}
154155

156+
if (fs.existsSync(this.MCP_SETTINGS_PATH)) {
157+
fs.copyFileSync(this.MCP_SETTINGS_PATH, tempMcpSettingsPath)
158+
}
159+
155160
// 如果 provider_models 目录存在,备份整个目录
156161
if (fs.existsSync(this.PROVIDER_MODELS_DIR_PATH)) {
157162
this.copyDirectory(this.PROVIDER_MODELS_DIR_PATH, tempProviderModelsPath)
@@ -220,6 +225,10 @@ export class SyncPresenter implements ISyncPresenter {
220225
fs.copyFileSync(tempAppSettingsPath, this.APP_SETTINGS_PATH)
221226
}
222227

228+
if (fs.existsSync(tempMcpSettingsPath)) {
229+
fs.copyFileSync(tempMcpSettingsPath, this.MCP_SETTINGS_PATH)
230+
}
231+
223232
if (fs.existsSync(tempProviderModelsPath)) {
224233
if (fs.existsSync(this.PROVIDER_MODELS_DIR_PATH)) {
225234
this.removeDirectory(this.PROVIDER_MODELS_DIR_PATH)
@@ -239,6 +248,10 @@ export class SyncPresenter implements ISyncPresenter {
239248
fs.unlinkSync(tempAppSettingsPath)
240249
}
241250

251+
if (fs.existsSync(tempMcpSettingsPath)) {
252+
fs.unlinkSync(tempMcpSettingsPath)
253+
}
254+
242255
if (fs.existsSync(tempProviderModelsPath)) {
243256
this.removeDirectory(tempProviderModelsPath)
244257
}
@@ -276,10 +289,14 @@ export class SyncPresenter implements ISyncPresenter {
276289
syncFolderPath,
277290
`provider_models_${Date.now()}.tmp`
278291
)
292+
const tempMcpSettingsBackupPath = path.join(
293+
syncFolderPath,
294+
`mcp_settings_${Date.now()}.json.tmp`
295+
)
279296
const finalDbBackupPath = path.join(syncFolderPath, 'chat.db')
280297
const finalAppSettingsBackupPath = path.join(syncFolderPath, 'app-settings.json')
281298
const finalProviderModelsBackupPath = path.join(syncFolderPath, 'provider_models')
282-
299+
const finalMcpSettingsBackupPath = path.join(syncFolderPath, 'mcp-settings.json')
283300
// 确保数据库文件存在
284301
if (!fs.existsSync(this.DB_PATH)) {
285302
console.warn('数据库文件不存在:', this.DB_PATH)
@@ -313,7 +330,10 @@ export class SyncPresenter implements ISyncPresenter {
313330
'utf-8'
314331
)
315332
}
316-
333+
// 备份 MCP 设置
334+
if (fs.existsSync(this.MCP_SETTINGS_PATH)) {
335+
fs.copyFileSync(this.MCP_SETTINGS_PATH, tempMcpSettingsBackupPath)
336+
}
317337
// 备份 provider_models 目录
318338
if (fs.existsSync(this.PROVIDER_MODELS_DIR_PATH)) {
319339
// 确保临时目录存在
@@ -330,6 +350,9 @@ export class SyncPresenter implements ISyncPresenter {
330350
if (!fs.existsSync(tempAppSettingsBackupPath)) {
331351
throw new Error('sync.error.tempConfigFailed')
332352
}
353+
if (!fs.existsSync(tempMcpSettingsBackupPath)) {
354+
throw new Error('sync.error.tempMcpSettingsFailed')
355+
}
333356

334357
// 重命名临时文件为最终文件
335358
if (fs.existsSync(finalDbBackupPath)) {
@@ -345,10 +368,14 @@ export class SyncPresenter implements ISyncPresenter {
345368
this.removeDirectory(finalProviderModelsBackupPath)
346369
}
347370

371+
if (fs.existsSync(finalMcpSettingsBackupPath)) {
372+
fs.unlinkSync(finalMcpSettingsBackupPath)
373+
}
374+
348375
// 确保临时文件存在后再执行重命名
349376
fs.renameSync(tempDbBackupPath, finalDbBackupPath)
350377
fs.renameSync(tempAppSettingsBackupPath, finalAppSettingsBackupPath)
351-
378+
fs.renameSync(tempMcpSettingsBackupPath, finalMcpSettingsBackupPath)
352379
// 重命名 provider_models 临时目录
353380
if (fs.existsSync(tempProviderModelsBackupPath)) {
354381
fs.renameSync(tempProviderModelsBackupPath, finalProviderModelsBackupPath)

0 commit comments

Comments
 (0)