"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import useSWR from "swr"; import AppShell from "@/components/AppShell"; import { EmptyState, LoadError, Modal, PageHeader, SkeletonRows, StatusBadge } from "@/components/ui"; import { useToast } from "@/components/toast"; import { api, fetcher } from "@/lib/api"; import { useAuth, roleAtLeast } from "@/lib/auth"; type Mcp = { name: string; status: string; error: string | null; source?: string; tools: { name: string; description: string | null }[]; }; export default function McpPage() { const router = useRouter(); const { user } = useAuth(); const isAdmin = roleAtLeast(user?.role, "admin"); const toast = useToast(); const { data: mcps, error: mcpError, isLoading, mutate, } = useSWR("/api/mcp/servers", fetcher, { refreshInterval: 15000 }); const [expanded, setExpanded] = useState(null); const [busy, setBusy] = useState(null); const [developOpen, setDevelopOpen] = useState(null); const [developIssue, setDevelopIssue] = useState(""); const run = async (key: string, label: string, fn: () => Promise) => { setBusy(key); try { await fn(); toast.success(`${label} — status will refresh shortly.`); mutate(); } catch (err: unknown) { toast.error(err instanceof Error ? err.message : "Action failed"); } finally { setBusy(null); } }; return ( run("all", "Reload all queued", async () => { await api("/api/mcp/reload-all", { method: "POST" }); }) } > {busy === "all" ? "Reloading…" : "Reload all"} ) } /> {isLoading && !mcps ? ( ) : mcpError ? ( mutate()} /> ) : (mcps || []).length === 0 ? ( ) : (
{(mcps || []).map((m) => (
{isAdmin && ( <> )}
{m.error &&
{m.error}
} {expanded === m.name && m.tools?.length > 0 && (
{m.tools.map((t) => (
{t.name}
{t.description && (
{t.description}
)}
))}
)}
))}
)} setDevelopOpen(null)} title={`Develop ${developOpen || ""}`} >

Describe the missing tool or bug. A monitor task opens automatically so you can watch analyze → patch → reload → git push in the task timeline. Push to Gitea needs approval unless auto-push is enabled.