mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-05 08:10:14 +00:00
fix: prevent MCP connection errors when toggling auto-approve on running tools
- Modified updateServerToolList to update local tool state without making MCP requests - Added fallback error handling for cases where MCP requests fail - Fixes issue where clicking auto-approve checkbox on running tools caused connection errors Fixes #7189
This commit is contained in:
parent
e7e827a3f8
commit
25ecf5d9e6
1 changed files with 25 additions and 2 deletions
|
|
@ -1690,8 +1690,31 @@ export class McpHub {
|
|||
|
||||
await fs.writeFile(normalizedPath, JSON.stringify(config, null, 2))
|
||||
|
||||
if (connection) {
|
||||
connection.server.tools = await this.fetchToolsList(serverName, source)
|
||||
// Update the local tools list without making an MCP request
|
||||
// This avoids connection issues when toggling auto-approve on running tools
|
||||
if (connection && connection.server.tools) {
|
||||
// Update the local tool's alwaysAllow or enabledForPrompt property
|
||||
const tool = connection.server.tools.find((t) => t.name === toolName)
|
||||
if (tool) {
|
||||
if (listName === "alwaysAllow") {
|
||||
tool.alwaysAllow = addTool
|
||||
} else if (listName === "disabledTools") {
|
||||
tool.enabledForPrompt = !addTool
|
||||
}
|
||||
}
|
||||
await this.notifyWebviewOfServerChanges()
|
||||
} else if (connection && connection.type === "connected") {
|
||||
// Only fetch tools list if we don't have it cached and the connection is active
|
||||
try {
|
||||
connection.server.tools = await this.fetchToolsList(serverName, source)
|
||||
await this.notifyWebviewOfServerChanges()
|
||||
} catch (error) {
|
||||
// If fetching fails, just notify with current state
|
||||
console.warn(`Failed to refresh tools list for ${serverName}, using cached state:`, error)
|
||||
await this.notifyWebviewOfServerChanges()
|
||||
}
|
||||
} else {
|
||||
// For disconnected servers, just notify with current state
|
||||
await this.notifyWebviewOfServerChanges()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue