'use client' import type { ToolWithProvider } from '../../workflow/types' import { cn } from '@langgenius/dify-ui/cn' import { StatusDot } from '@langgenius/dify-ui/status-dot' import { useCallback, useState } from 'react' import { useTranslation } from 'react-i18next' import Icon from '@/app/components/plugins/card/base/card-icon' import { useCanManageMCP } from '@/app/components/tools/hooks/use-tool-permissions' import { useFormatTimeFromNow } from '@/hooks/use-format-time-from-now' import OperationDropdown from './detail/operation-dropdown' type Props = Readonly<{ currentProvider?: ToolWithProvider data: ToolWithProvider handleSelect: (providerID: string) => void onEdit: (providerID: string) => void onDelete: (providerID: string) => void }> const MCPCard = ({ currentProvider, data, onEdit, onDelete, handleSelect }: Props) => { const { t } = useTranslation() const { formatTimeFromNow } = useFormatTimeFromNow() const canManageMCP = useCanManageMCP() const isConfigured = data.is_team_authorization && data.tools.length > 0 const updatedAtText = data.updated_at ? `${t(($) => $['mcp.updateTime'], { ns: 'tools' })} ${formatTimeFromNow(data.updated_at * 1000)}` : undefined const [isOperationShow, setIsOperationShow] = useState(false) const handleSelectProvider = useCallback(() => { handleSelect(data.id) }, [data.id, handleSelect]) return (