Skip to content

Commit 1cfb6e3

Browse files
author
LehaoLin
committed
fix: persist MCP toggle changes to opencode.json
- Save enabled state when connecting/disconnecting MCP servers - Fixes issue where /mcp toggle doesn't persist after restart - Config.update() called in both connect() and disconnect() Fixes anomalyco#17799
1 parent 51fcd04 commit 1cfb6e3

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎packages/opencode/src/mcp/index.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,10 @@ export namespace MCP {
569569
return
570570
}
571571

572+
// Update config to persist enabled state
573+
const mcpConfig: McpConfigured = { ...mcp, enabled: true }
574+
await Config.update({ mcp: { [name]: mcpConfig } })
575+
572576
const result = await create(name, { ...mcp, enabled: true })
573577

574578
if (!result) {
@@ -604,6 +608,15 @@ export namespace MCP {
604608
delete s.clients[name]
605609
}
606610
s.status[name] = { status: "disabled" }
611+
612+
// Update config to persist disabled state
613+
const cfg = await Config.get()
614+
const config = cfg.mcp ?? {}
615+
const mcp = config[name]
616+
if (mcp && isMcpConfigured(mcp)) {
617+
const mcpConfig: McpConfigured = { ...mcp, enabled: false }
618+
await Config.update({ mcp: { [name]: mcpConfig } })
619+
}
607620
}
608621

609622
export async function tools() {

0 commit comments

Comments
 (0)