mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-07 02:58:15 +00:00
feat: add auto-approve support for MCP access_resource tool (#7606)
This commit is contained in:
parent
d1baa6e849
commit
7e24600877
2 changed files with 34 additions and 4 deletions
|
|
@ -1,5 +1,15 @@
|
|||
import { z } from "zod"
|
||||
|
||||
/**
|
||||
* MCP Server Use Types
|
||||
*/
|
||||
export interface McpServerUse {
|
||||
type: string
|
||||
serverName: string
|
||||
toolName?: string
|
||||
uri?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* McpExecutionStatus
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
@ -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
|
||||
|
|
@ -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") {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue