|
@@ -46,6 +46,7 @@ import { UrlContentFetcher } from "../services/browser/UrlContentFetcher"
|
|
|
import { listFiles } from "../services/glob/list-files"
|
|
import { listFiles } from "../services/glob/list-files"
|
|
|
import { BrowserSession } from "../services/browser/BrowserSession"
|
|
import { BrowserSession } from "../services/browser/BrowserSession"
|
|
|
import { McpHub } from "../services/mcp/McpHub"
|
|
import { McpHub } from "../services/mcp/McpHub"
|
|
|
|
|
+import { McpServerManager } from "../services/mcp/McpServerManager"
|
|
|
import { telemetryService } from "../services/telemetry/TelemetryService"
|
|
import { telemetryService } from "../services/telemetry/TelemetryService"
|
|
|
import { CheckpointServiceOptions, RepoPerTaskCheckpointService } from "../services/checkpoints"
|
|
import { CheckpointServiceOptions, RepoPerTaskCheckpointService } from "../services/checkpoints"
|
|
|
|
|
|
|
@@ -969,12 +970,19 @@ export class Cline extends EventEmitter<ClineEvents> {
|
|
|
this.lastApiRequestTime = Date.now()
|
|
this.lastApiRequestTime = Date.now()
|
|
|
|
|
|
|
|
if (mcpEnabled ?? true) {
|
|
if (mcpEnabled ?? true) {
|
|
|
- mcpHub = this.providerRef.deref()?.getMcpHub()
|
|
|
|
|
|
|
+ const provider = this.providerRef.deref()
|
|
|
|
|
+ if (!provider) {
|
|
|
|
|
+ throw new Error("Provider reference lost during view transition")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Wait for MCP hub initialization through McpServerManager
|
|
|
|
|
+ mcpHub = await McpServerManager.getInstance(provider.context, provider)
|
|
|
if (!mcpHub) {
|
|
if (!mcpHub) {
|
|
|
- throw new Error("MCP hub not available")
|
|
|
|
|
|
|
+ throw new Error("Failed to get MCP hub from server manager")
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
// Wait for MCP servers to be connected before generating system prompt
|
|
// Wait for MCP servers to be connected before generating system prompt
|
|
|
- await pWaitFor(() => mcpHub!.isConnecting !== true, { timeout: 10_000 }).catch(() => {
|
|
|
|
|
|
|
+ await pWaitFor(() => !mcpHub!.isConnecting, { timeout: 10_000 }).catch(() => {
|
|
|
console.error("MCP servers failed to connect in time")
|
|
console.error("MCP servers failed to connect in time")
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|