Matt Rubens 1 year ago
parent
commit
d32c5f805e
2 changed files with 6 additions and 5 deletions
  1. 4 1
      src/core/Cline.ts
  2. 2 4
      src/core/webview/ClineProvider.ts

+ 4 - 1
src/core/Cline.ts

@@ -780,7 +780,10 @@ export class Cline {
 
 	async *attemptApiRequest(previousApiReqIndex: number): ApiStream {
 		let mcpHub: McpHub | undefined
-		if (this.providerRef.deref()?.mcpEnabled ?? true) {
+
+		const { mcpEnabled } = await this.providerRef.deref()?.getState() ?? {}
+
+		if (mcpEnabled ?? true) {
 			mcpHub = this.providerRef.deref()?.mcpHub
 			if (!mcpHub) {
 				throw new Error("MCP hub not available")

+ 2 - 4
src/core/webview/ClineProvider.ts

@@ -96,7 +96,6 @@ export class ClineProvider implements vscode.WebviewViewProvider {
 	private workspaceTracker?: WorkspaceTracker
 	mcpHub?: McpHub
 	private latestAnnouncementId = "dec-10-2024" // update to some unique identifier when we add a new announcement
-  mcpEnabled: boolean = true
 
 	constructor(
 		readonly context: vscode.ExtensionContext,
@@ -131,7 +130,6 @@ export class ClineProvider implements vscode.WebviewViewProvider {
 		this.workspaceTracker = undefined
 		this.mcpHub?.dispose()
 		this.mcpHub = undefined
-    this.mcpEnabled = true
 		this.outputChannel.appendLine("Disposed all disposables")
 		ClineProvider.activeInstances.delete(this)
 	}
@@ -609,8 +607,8 @@ export class ClineProvider implements vscode.WebviewViewProvider {
 						break
 					}
 					case "mcpEnabled":
-						this.mcpEnabled = message.bool ?? true
-						await this.updateGlobalState("mcpEnabled", this.mcpEnabled)
+						const mcpEnabled = message.bool ?? true
+						await this.updateGlobalState("mcpEnabled", mcpEnabled)
 						await this.postStateToWebview()
 						break
 					case "playSound":