File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ import { Label } from "@/components/ui/label";
5
5
import { TabsContent } from "@/components/ui/tabs" ;
6
6
import { Textarea } from "@/components/ui/textarea" ;
7
7
import {
8
- CallToolResult ,
9
8
ListToolsResult ,
10
9
Tool ,
11
10
CallToolResultSchema ,
@@ -41,7 +40,24 @@ const ToolsTab = ({
41
40
if ( ! toolResult ) return null ;
42
41
43
42
if ( "content" in toolResult ) {
44
- const structuredResult = CallToolResultSchema . parse ( toolResult ) ;
43
+ const parsedResult = CallToolResultSchema . safeParse ( toolResult ) ;
44
+ if ( ! parsedResult . success ) {
45
+ return (
46
+ < >
47
+ < h4 className = "font-semibold mb-2" > Invalid Tool Result:</ h4 >
48
+ < pre className = "bg-gray-50 dark:bg-gray-800 dark:text-gray-100 p-4 rounded text-sm overflow-auto max-h-64" >
49
+ { JSON . stringify ( toolResult , null , 2 ) }
50
+ </ pre >
51
+ < h4 className = "font-semibold mb-2" > Errors:</ h4 >
52
+ { parsedResult . error . errors . map ( ( error ) => (
53
+ < pre className = "bg-gray-50 dark:bg-gray-800 dark:text-gray-100 p-4 rounded text-sm overflow-auto max-h-64" >
54
+ { JSON . stringify ( error , null , 2 ) }
55
+ </ pre >
56
+ ) ) }
57
+ </ >
58
+ ) ;
59
+ }
60
+ const structuredResult = parsedResult . data ;
45
61
const isError = structuredResult . isError ?? false ;
46
62
47
63
return (
You can’t perform that action at this time.
0 commit comments