11import { TabsContent } from "@/components/ui/tabs" ;
22import { Button } from "@/components/ui/button" ;
3- import { Textarea } from "@/components/ui/textarea " ;
3+ import { Input } from "@/components/ui/input " ;
44import { Send , AlertCircle } from "lucide-react" ;
55import { Alert , AlertDescription , AlertTitle } from "@/components/ui/alert" ;
66import { useState } from "react" ;
7+ import { Label } from "@/components/ui/label" ;
78
89export type Tool = {
910 name : string ;
11+ description : string ;
12+ inputSchema : {
13+ type : string ;
14+ properties : Record < string , { type : string ; description : string } > ;
15+ } ;
1016} ;
1117
1218const ToolsTab = ( {
@@ -26,7 +32,7 @@ const ToolsTab = ({
2632 toolResult : string ;
2733 error : string | null ;
2834} ) => {
29- const [ params , setParams ] = useState ( "" ) ;
35+ const [ params , setParams ] = useState < Record < string , unknown > > ( { } ) ;
3036
3137 return (
3238 < TabsContent value = "tools" className = "grid grid-cols-2 gap-4" >
@@ -46,6 +52,9 @@ const ToolsTab = ({
4652 onClick = { ( ) => setSelectedTool ( tool ) }
4753 >
4854 < span className = "flex-1" > { tool . name } </ span >
55+ < span className = "text-sm text-gray-500" >
56+ { tool . description }
57+ </ span >
4958 </ div >
5059 ) ) }
5160 </ div >
@@ -67,22 +76,47 @@ const ToolsTab = ({
6776 </ Alert >
6877 ) : selectedTool ? (
6978 < div className = "space-y-4" >
70- < Textarea
71- placeholder = "Tool parameters (JSON)"
72- className = "h-32 font-mono"
73- value = { params }
74- onChange = { ( e ) => setParams ( e . target . value ) }
75- />
76- < Button
77- onClick = { ( ) => callTool ( selectedTool . name , JSON . parse ( params ) ) }
78- >
79+ < p className = "text-sm text-gray-600" >
80+ { selectedTool . description }
81+ </ p >
82+ { Object . entries ( selectedTool . inputSchema . properties ) . map (
83+ ( [ key , value ] ) => (
84+ < div key = { key } >
85+ < Label
86+ htmlFor = { key }
87+ className = "block text-sm font-medium text-gray-700"
88+ >
89+ { key }
90+ </ Label >
91+ < Input
92+ type = { value . type === "number" ? "number" : "text" }
93+ id = { key }
94+ name = { key }
95+ placeholder = { value . description }
96+ onChange = { ( e ) =>
97+ setParams ( {
98+ ...params ,
99+ [ key ] :
100+ value . type === "number"
101+ ? Number ( e . target . value )
102+ : e . target . value ,
103+ } )
104+ }
105+ />
106+ </ div >
107+ ) ,
108+ ) }
109+ < Button onClick = { ( ) => callTool ( selectedTool . name , params ) } >
79110 < Send className = "w-4 h-4 mr-2" />
80111 Run Tool
81112 </ Button >
82113 { toolResult && (
83- < pre className = "bg-gray-50 p-4 rounded text-sm overflow-auto max-h-64" >
84- { JSON . stringify ( toolResult , null , 2 ) }
85- </ pre >
114+ < >
115+ < h4 className = "font-semibold mb-2" > Tool Result:</ h4 >
116+ < pre className = "bg-gray-50 p-4 rounded text-sm overflow-auto max-h-64" >
117+ { toolResult }
118+ </ pre >
119+ </ >
86120 ) }
87121 </ div >
88122 ) : (
0 commit comments