Skip to content

Commit 6451bc5

Browse files
committed
refactor: centralize supported image types in MCP tool processing
**Changes:** - Introduced a constant `SUPPORTED_IMAGE_TYPES` to define valid image MIME types, improving code readability and maintainability. - Updated `processToolContent` to utilize the new constant for image type validation. **Files Modified:** - `src/core/tools/useMcpToolTool.ts`
1 parent 17349d3 commit 6451bc5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/core/tools/useMcpToolTool.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { ClineAskUseMcpServer } from "../../shared/ExtensionMessage"
55
import { McpExecutionStatus } from "@roo-code/types"
66
import { t } from "../../i18n"
77

8+
const SUPPORTED_IMAGE_TYPES = ["image/png", "image/jpeg", "image/gif", "image/webp"]
9+
810
interface McpToolParams {
911
server_name?: string
1012
tool_name?: string
@@ -230,8 +232,7 @@ async function processToolContent(toolResult: any, cline: Task): Promise<{ text:
230232
}
231233

232234
if (item.mimeType && item.data !== undefined && item.data !== null) {
233-
const validImageTypes = ["image/png", "image/jpeg", "image/gif", "image/webp"]
234-
if (validImageTypes.includes(item.mimeType)) {
235+
if (SUPPORTED_IMAGE_TYPES.includes(item.mimeType)) {
235236
try {
236237
// Validate base64 data before constructing data URL
237238
if (typeof item.data !== "string" || item.data.trim() === "") {

0 commit comments

Comments
 (0)