import { Button, Divider, Group, Stack, Text } from "@mantine/core"; import type { ProgressNotification, Tool, ToolAnnotations, } from "@modelcontextprotocol/sdk/types.js"; import { AnnotationBadge } from "../../elements/AnnotationBadge/AnnotationBadge"; import { ProgressDisplay } from "../../elements/ProgressDisplay/ProgressDisplay"; import { SchemaForm } from "../SchemaForm/SchemaForm"; export interface ToolDetailPanelProps { tool: Tool; formValues: Record; isExecuting: boolean; progress?: Pick< ProgressNotification["params"], "progress" | "total" | "message" >; onFormChange: (values: Record) => void; onExecute: () => void; onCancel: () => void; } const ToolTitle = Text.withProps({ fw: 700, size: "lg", truncate: "end", }); const DescriptionText = Text.withProps({ size: "sm", c: "dimmed", }); const CancelButton = Button.withProps({ variant: "subtle", color: "red", }); function resolveTitle(name: string, title?: string): string { return title ?? name; } function hasAnyAnnotation(annotations?: ToolAnnotations): boolean { return !!( annotations && (annotations.title || annotations.readOnlyHint || annotations.destructiveHint || annotations.idempotentHint || annotations.openWorldHint) ); } export function ToolDetailPanel({ tool, formValues, isExecuting, progress, onFormChange, onExecute, onCancel, }: ToolDetailPanelProps) { const { name, title, description, annotations, inputSchema } = tool; return ( {resolveTitle(name, title)} {hasAnyAnnotation(annotations) && annotations && ( {annotations.readOnlyHint && ( )} {annotations.destructiveHint && ( )} {annotations.idempotentHint && ( )} {annotations.openWorldHint && ( )} )} {description && {description}} {progress && } {isExecuting && Cancel} ); }