Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/types/src/mcp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { z } from "zod"

/**
* MCP Server Use Types
*/
export interface McpServerUse {
type: string
serverName: string
toolName?: string
uri?: string
}

/**
* McpExecutionStatus
*/
Expand Down
28 changes: 24 additions & 4 deletions webview-ui/src/components/chat/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useTranslation } from "react-i18next"
import { useDebounceEffect } from "@src/utils/useDebounceEffect"
import { appendImages } from "@src/utils/imageUtils"

import type { ClineAsk, ClineMessage } from "@roo-code/types"
import type { ClineAsk, ClineMessage, McpServerUse } from "@roo-code/types"

import { ClineSayBrowserAction, ClineSayTool, ExtensionMessage } from "@roo/ExtensionMessage"
import { McpServer, McpTool } from "@roo/mcp"
Expand Down Expand Up @@ -1062,9 +1062,9 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
return true
}

const mcpServerUse = JSON.parse(message.text) as { type: string; serverName: string; toolName: string }
const mcpServerUse = JSON.parse(message.text) as McpServerUse

if (mcpServerUse.type === "use_mcp_tool") {
if (mcpServerUse.type === "use_mcp_tool" && mcpServerUse.toolName) {
const server = mcpServers?.find((s: McpServer) => s.name === mcpServerUse.serverName)
const tool = server?.tools?.find((t: McpTool) => t.name === mcpServerUse.toolName)
return tool?.alwaysAllow || false
Expand Down Expand Up @@ -1145,7 +1145,27 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
}

if (message.ask === "use_mcp_server") {
return alwaysAllowMcp && isMcpToolAlwaysAllowed(message)
// Check if it's a tool or resource access
if (!message.text) {
return false
}

try {
const mcpServerUse = JSON.parse(message.text) as McpServerUse

if (mcpServerUse.type === "use_mcp_tool") {
// For tools, check if the specific tool is always allowed
return alwaysAllowMcp && isMcpToolAlwaysAllowed(message)
} else if (mcpServerUse.type === "access_mcp_resource") {
// For resources, auto-approve if MCP is always allowed
// Resources don't have individual alwaysAllow settings like tools do
return alwaysAllowMcp
}
} catch (error) {
console.error("Failed to parse MCP server use message:", error)
return false
}
return false
}

if (message.ask === "command") {
Expand Down
Loading