Skip to content

Commit fafd33f

Browse files
committed
feat: add auto-approve support for MCP access_resource tool
- Extended auto-approval logic to handle both use_mcp_tool and access_mcp_resource types - MCP resource access requests are now auto-approved when alwaysAllowMcp is enabled - Maintains existing behavior for MCP tools with individual alwaysAllow settings - Ensures notification sounds are properly suppressed for auto-approved resource requests Fixes auto-approve workflow for access_resource MCP operations
1 parent 59d6e74 commit fafd33f

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,31 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
11451145
}
11461146

11471147
if (message.ask === "use_mcp_server") {
1148-
return alwaysAllowMcp && isMcpToolAlwaysAllowed(message)
1148+
// Check if it's a tool or resource access
1149+
if (!message.text) {
1150+
return false
1151+
}
1152+
1153+
try {
1154+
const mcpServerUse = JSON.parse(message.text) as {
1155+
type: string
1156+
serverName: string
1157+
toolName?: string
1158+
uri?: string
1159+
}
1160+
1161+
if (mcpServerUse.type === "use_mcp_tool") {
1162+
// For tools, check if the specific tool is always allowed
1163+
return alwaysAllowMcp && isMcpToolAlwaysAllowed(message)
1164+
} else if (mcpServerUse.type === "access_mcp_resource") {
1165+
// For resources, auto-approve if MCP is always allowed
1166+
// Resources don't have individual alwaysAllow settings like tools do
1167+
return alwaysAllowMcp
1168+
}
1169+
} catch (error) {
1170+
console.error("Failed to parse MCP server use message:", error)
1171+
return false
1172+
}
11491173
}
11501174

11511175
if (message.ask === "command") {

0 commit comments

Comments
 (0)