import { useState, useMemo } from 'react'; import { cn, getBackendUrl } from '@/lib/utils/utils'; import { Alert, AlertDescription, CodeBlock, JsonHighlight, Tabs, TabsList, TabsTrigger, TabsContent, } from '@/components'; import { CursorDeeplinkGenerator } from './CursorDeeplinkGenerator'; import { MCP_AGENTS, createMCPConfig, GenerateInstallCommand, type MCPAgent, type PlatformType, } from './helpers'; import { useApiKey } from '@/lib/hooks/useMetadata'; interface McpInstallerProps { className?: string; defaultAgent?: string; TabListClassName?: string; } export function McpInstallation({ className, defaultAgent = 'cursor', TabListClassName, }: McpInstallerProps) { const [selectedAgent, setSelectedAgent] = useState(() => { return MCP_AGENTS.find((agent) => agent.id === defaultAgent) || MCP_AGENTS[0]; }); const [activeTab, setActiveTab] = useState('macos-linux'); const { apiKey } = useApiKey(); const handleTabChange = (value: string) => { setActiveTab(value as PlatformType); }; const mcpConfig = useMemo(() => { return createMCPConfig(apiKey || '', activeTab, getBackendUrl()); }, [apiKey, activeTab]); return (
{/* Agent Tabs */} { const agent = MCP_AGENTS.find((a) => a.id === value); if (agent) { setSelectedAgent(agent); } }} > {MCP_AGENTS.map((agent) => ( {agent.logo && (
{agent.logo}
)} {agent.displayName}
))}
{/* Content for each agent */} {MCP_AGENTS.map((agent) => ( {agent.id !== 'mcp' ? (
{agent.id === 'cursor' && ( )} {/* Alternative Installation */}

{agent.id === 'cursor' ? 'or copy' : 'Copy'} the command below and paste it to terminal

{/* Command Block */}
) : (

Copy the configuration below and add it to your AI assistant.

{/* OS Tabs */}
MacOS/Linux Windows
{/* Configuration content */}
{!apiKey && ( No API key found. Please ensure the backend is running and you're logged in as an admin. )}
)}
))}
); }