@@ -979,6 +979,63 @@ describe("useMcpToolTool", () => {
979979 )
980980 } )
981981
982+ it ( "should not double-prefix image resource blobs already formatted as data URLs" , async ( ) => {
983+ const block : ToolUse < "use_mcp_tool" > = {
984+ type : "tool_use" ,
985+ name : "use_mcp_tool" ,
986+ params : {
987+ server_name : "godot-server" ,
988+ tool_name : "game_screenshot" ,
989+ arguments : "{}" ,
990+ } ,
991+ nativeArgs : {
992+ server_name : "godot-server" ,
993+ tool_name : "game_screenshot" ,
994+ arguments : { } ,
995+ } ,
996+ partial : false ,
997+ }
998+
999+ mockAskApproval . mockResolvedValue ( true )
1000+
1001+ const mockToolResult = {
1002+ content : [
1003+ {
1004+ type : "resource" ,
1005+ resource : {
1006+ uri : "godot://screenshot/latest" ,
1007+ mimeType : "image/png" ,
1008+ blob : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJ" ,
1009+ } ,
1010+ } ,
1011+ ] ,
1012+ isError : false ,
1013+ }
1014+
1015+ mockProviderRef . deref . mockReturnValue ( {
1016+ getMcpHub : ( ) => ( {
1017+ callTool : vi . fn ( ) . mockResolvedValue ( mockToolResult ) ,
1018+ getAllServers : vi . fn ( ) . mockReturnValue ( [
1019+ {
1020+ name : "godot-server" ,
1021+ tools : [ { name : "game_screenshot" , description : "Capture screenshot" } ] ,
1022+ } ,
1023+ ] ) ,
1024+ } ) ,
1025+ postMessageToWebview : vi . fn ( ) ,
1026+ } )
1027+
1028+ await useMcpToolTool . handle ( mockTask as Task , block , {
1029+ askApproval : mockAskApproval ,
1030+ handleError : mockHandleError ,
1031+ pushToolResult : mockPushToolResult ,
1032+ } )
1033+
1034+ expect ( mockTask . say ) . toHaveBeenCalledWith ( "mcp_server_response" , expect . any ( String ) , [
1035+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJ" ,
1036+ ] )
1037+ } )
1038+
9821039 it ( "should handle multiple images in response" , async ( ) => {
9831040 const block : ToolUse = {
9841041 type : "tool_use" ,
0 commit comments