Compare commits

...

16 Commits

Author SHA1 Message Date
Andrei Edell fe9265c63a Fix: Display original data:image URLs in rich display mode to maintain transparency 2025-04-17 13:41:23 -10:00
Andrei Edell 8d3981c618 Merge branch 'main' into pr-2146 2025-04-17 13:32:27 -10:00
Saoud Rizwan c69adcaf57 Remove mcpToolResult 2025-04-10 18:24:53 -07:00
rikaaa0928 697887b7af Merge branch 'remote' into feat-mcp-image 2025-04-05 11:22:57 +08:00
rikaaa0928 138206eae9 Merge branch 'remote' into feat-mcp-image 2025-04-04 13:46:01 +08:00
rikaaa0928 c5b714b59c Merge branch 'remote' into feat-mcp-image 2025-03-31 14:02:53 +08:00
rikaaa0928 7f60c08756 Merge branch 'main' into feat-mcp-image 2025-03-23 11:07:06 +08:00
rikaaa0928 ccaa999463 Merge branch 'remote' into feat-mcp-image 2025-03-22 16:48:32 +08:00
rikaaa0928 380b8c3aae Merge branch 'remote' into feat-mcp-image 2025-03-21 10:46:40 +08:00
rikaaa0928 9e94fd8e97 feat: MCP ImageContent support run format:fix 2025-03-08 15:28:51 +08:00
rikaaa0928 ff31ac1e1a Update src/core/Cline.ts
Co-authored-by: Dennis Bartlett <bartlett.dc.1@gmail.com>
2025-03-08 15:25:25 +08:00
rikaaa0928 59210b8d5d Update src/core/prompts/responses.ts
Co-authored-by: Dennis Bartlett <bartlett.dc.1@gmail.com>
2025-03-08 15:24:47 +08:00
rikaaa0928 30510dc73f feat: MCP ImageContent support changeset 2025-03-08 09:53:10 +08:00
rikaaa0928 eee5b9b77a feat: MCP ImageContent support 2025-03-08 09:39:59 +08:00
rikaaa0928 fd46b9c54e Merge branch 'remote' into feat-mcp-image 2025-03-08 09:05:30 +08:00
rikaaa0928 ee12bf5e30 feat: MCP ImageContent support 2025-03-08 09:02:13 +08:00
4 changed files with 29 additions and 5 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"claude-dev": patch
---
MCP ImageContent as tool result
+1
View File
@@ -2,6 +2,7 @@ import { Anthropic } from "@anthropic-ai/sdk"
import * as diff from "diff"
import * as path from "path"
import { ClineIgnoreController, LOCK_TEXT_SYMBOL } from "../ignore/ClineIgnoreController"
import { McpToolCallResponse } from "../../shared/mcp"
export const formatResponse = {
duplicateFileReadNotice: () =>
+22 -4
View File
@@ -2690,8 +2690,13 @@ export class Task {
await this.say("mcp_server_request_started") // same as browser_action_result
const toolResult = await this.mcpHub.callTool(server_name, tool_name, parsedArguments)
// TODO: add progress indicator and ability to parse images and non-text responses
const toolResultPretty =
// TODO: add progress indicator
const toolResultImages =
toolResult?.content
.filter((item) => item.type === "image")
.map((item) => `data:${item.mimeType};base64,${item.data}`) || []
let toolResultText =
(toolResult?.isError ? "Error:\n" : "") +
toolResult?.content
.map((item) => {
@@ -2706,8 +2711,21 @@ export class Task {
})
.filter(Boolean)
.join("\n\n") || "(No response)"
await this.say("mcp_server_response", toolResultPretty)
pushToolResult(formatResponse.toolResult(toolResultPretty))
// webview extracts images from the text response to display in the UI
const toolResultToDisplay =
toolResultText + toolResultImages?.map((image) => `\n\n${image}`).join("")
await this.say("mcp_server_response", toolResultToDisplay)
// MCP's might return images to display to the user, but the model may not support them
const supportsImages = this.api.getModel().info.supportsImages ?? false
if (toolResultImages.length > 0 && !supportsImages) {
toolResultText += `\n\n[${toolResultImages.length} images were provided in the response, and while they are displayed to the user, you do not have the ability to view them.]`
}
// only passes in images if model supports them
pushToolResult(
formatResponse.toolResult(toolResultText, supportsImages ? toolResultImages : undefined),
)
await this.saveCheckpoint()
@@ -162,7 +162,7 @@ const McpResponseDisplay: React.FC<McpResponseDisplayProps> = ({ responseText })
try {
const text = responseText || ""
const matches: UrlMatch[] = []
const urlRegex = /https?:\/\/[^\s<>"']+/g
const urlRegex = /(?:https?:\/\/|data:image)[^\s<>"']+/g
let urlMatch: RegExpExecArray | null
let urlCount = 0