Skip to content

Commit f7312ab

Browse files
committed
Add checkbox for Boolean input params
1 parent beee383 commit f7312ab

File tree

4 files changed

+59
-1
lines changed

4 files changed

+59
-1
lines changed

client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
},
2323
"dependencies": {
2424
"@modelcontextprotocol/sdk": "^1.4.1",
25+
"@radix-ui/react-checkbox": "^1.1.4",
2526
"@radix-ui/react-icons": "^1.3.0",
2627
"@radix-ui/react-label": "^2.1.0",
2728
"@radix-ui/react-select": "^2.1.2",

client/src/components/ToolsTab.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
22
import { Button } from "@/components/ui/button";
3+
import { Checkbox } from "@/components/ui/checkbox";
34
import { Input } from "@/components/ui/input";
45
import { Label } from "@/components/ui/label";
56
import { TabsContent } from "@/components/ui/tabs";
@@ -169,6 +170,28 @@ const ToolsTab = ({
169170
</Label>
170171
{
171172
/* @ts-expect-error value type is currently unknown */
173+
value.type === "boolean" ? (
174+
<div className="flex items-center space-x-2 mt-2">
175+
<Checkbox
176+
id={key}
177+
name={key}
178+
checked={!!params[key]}
179+
onCheckedChange={(checked: boolean) =>
180+
setParams({
181+
...params,
182+
[key]: checked
183+
})
184+
}
185+
/>
186+
<label
187+
htmlFor={key}
188+
className="text-sm font-medium text-gray-700 dark:text-gray-300"
189+
>
190+
{/* @ts-expect-error value type is currently unknown */}
191+
{value.description || "Toggle this option"}
192+
</label>
193+
</div>
194+
) : /* @ts-expect-error value type is currently unknown */
172195
value.type === "string" ? (
173196
<Textarea
174197
id={key}
@@ -197,7 +220,7 @@ const ToolsTab = ({
197220
...params,
198221
[key]: parsed,
199222
});
200-
} catch (err) {
223+
} catch {
201224
// If invalid JSON, store as string - will be validated on submit
202225
setParams({
203226
...params,

client/src/components/ui/checkbox.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"use client"
2+
3+
import * as React from "react"
4+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
5+
import { Check } from "lucide-react"
6+
7+
import { cn } from "@/lib/utils"
8+
9+
const Checkbox = React.forwardRef<
10+
React.ElementRef<typeof CheckboxPrimitive.Root>,
11+
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
12+
>(({ className, ...props }, ref) => (
13+
<CheckboxPrimitive.Root
14+
ref={ref}
15+
className={cn(
16+
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
17+
className
18+
)}
19+
{...props}
20+
>
21+
<CheckboxPrimitive.Indicator
22+
className={cn("flex items-center justify-center text-current")}
23+
>
24+
<Check className="h-4 w-4" />
25+
</CheckboxPrimitive.Indicator>
26+
</CheckboxPrimitive.Root>
27+
))
28+
Checkbox.displayName = CheckboxPrimitive.Root.displayName
29+
30+
export { Checkbox }

client/src/index.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ button:focus-visible {
5757
outline: 4px auto -webkit-focus-ring-color;
5858
}
5959

60+
button[role="checkbox"] {
61+
padding: 0;
62+
}
63+
6064
@media (prefers-color-scheme: light) {
6165
:root {
6266
color: #213547;

0 commit comments

Comments
 (0)