Skip to content

Commit f8414c9

Browse files
author
saravmajestic
committed
fix(mcp-discover): add updatedAt timestamp and connect MCP immediately after config write
- Add updatedAt: new Date().toISOString() when writing MCP server to config so clients can detect config changes without restarting - Call MCP.connect(name) immediately after addMcpToConfig so the server becomes active in the current session — /mcps now shows connected without restart
1 parent 1290a63 commit f8414c9

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

packages/opencode/src/altimate/tools/mcp-discover.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { discoverExternalMcp } from "../../mcp/discover"
44
import { resolveConfigPath, addMcpToConfig, findAllConfigPaths, listMcpInConfig } from "../../mcp/config"
55
import { Instance } from "../../project/instance"
66
import { Global } from "../../global"
7+
import { MCP } from "../../mcp"
78

89
/**
910
* Check which MCP server names are permanently configured on disk
@@ -131,7 +132,10 @@ export const McpDiscoverTool = Tool.define("mcp_discover", {
131132
// as a security default (no auto-connect until user approves).
132133
// When the user explicitly adds a server via this tool, it should be enabled.
133134
const { enabled: _discardEnabled, ...cfgToWrite } = stripSessionEnv(discovered[name]) as any
134-
await addMcpToConfig(name, { ...cfgToWrite, enabled: true } as import('../../config/config').Config.Mcp, configPath)
135+
await addMcpToConfig(name, { ...cfgToWrite, enabled: true, updatedAt: new Date().toISOString() } as import('../../config/config').Config.Mcp, configPath)
136+
// Connect immediately so /mcps reflects the server status in the current session
137+
// without requiring a restart.
138+
await MCP.connect(name)
135139
// altimate_change end
136140
}
137141

0 commit comments

Comments
 (0)