import React, { useState } from 'react' import { X, Plus, RefreshCw } from 'lucide-react' type Props = { backendUrl: string apiKey?: string onClose: () => void onRegistered: () => void } const TRANSPORTS = ['SSE', 'STREAMABLEHTTP', 'HTTP', 'STDIO'] as const export function AddServerDrawer({ backendUrl, apiKey, onClose, onRegistered }: Props) { const [name, setName] = useState('') const [url, setUrl] = useState('') const [transport, setTransport] = useState('SSE') const [description, setDescription] = useState('') const [autoRefresh, setAutoRefresh] = useState(true) const [busy, setBusy] = useState(false) const [error, setError] = useState(null) const [success, setSuccess] = useState(false) const canSubmit = name.trim() && url.trim() && !busy const handleSubmit = async () => { if (!canSubmit) return setBusy(true) setError(null) try { const headers: Record = { 'Content-Type': 'application/json' } if (apiKey) headers['x-api-key'] = apiKey const res = await fetch(`${backendUrl}/v1/agentic/register/gateway`, { method: 'POST', headers, body: JSON.stringify({ name: name.trim(), url: url.trim(), transport, description: description.trim(), auto_refresh: autoRefresh, }), }) const data = await res.json() if (!res.ok || !data.ok) { throw new Error(data.detail || `HTTP ${res.status}`) } setSuccess(true) setTimeout(() => { onRegistered() onClose() }, 1000) } catch (e: any) { setError(e?.message || 'Registration failed') } finally { setBusy(false) } } return (
e.stopPropagation()} > {/* Header */}

Add MCP Server

{/* Form */}
{/* Name */}
setName(e.target.value)} placeholder="e.g. my-mcp-server" className="w-full bg-white/5 border border-white/10 rounded-xl px-4 py-2.5 text-sm text-white placeholder-white/30 focus:outline-none focus:border-purple-500/50 transition-colors" />
{/* URL */}
setUrl(e.target.value)} placeholder="e.g. http://localhost:9101/rpc" className="w-full bg-white/5 border border-white/10 rounded-xl px-4 py-2.5 text-sm text-white placeholder-white/30 focus:outline-none focus:border-purple-500/50 transition-colors" />
{/* Transport */}
{TRANSPORTS.map((t) => ( ))}
{/* Description */}