import Link from "next/link"; import { listDocuments, listSections } from "@mcpedia/core"; import { getSectionMeta, type SectionConfig } from "@mcpedia/config"; import McpConfigSnippet from "@/components/McpConfigSnippet"; import InteractiveTopology from "@/components/InteractiveTopology"; import { Search, Plus, BookOpen, ArrowRight, Database, Layers, Folder, FileText, Clock, Terminal, } from "lucide-react"; export const dynamic = "force-dynamic"; interface TreeNode { name: string; slug: string; title: string; children: TreeNode[]; isLeaf: boolean; } function slugToTitle(segment: string): string { return segment .split(/[-_]/) .map((w) => (w ? w.charAt(0).toUpperCase() + w.slice(1) : "")) .join(" "); } function buildFolderTree(docs: { slug: string; title: string }[], section: string): TreeNode[] { const tree: TreeNode[] = []; for (const doc of docs) { const parts = doc.slug.split("/"); let current = tree; let currentPath = section; for (let i = 1; i < parts.length; i++) { const part = parts[i]; const isLeaf = i === parts.length - 1; currentPath = `${currentPath}/${part}`; let node = current.find((n) => n.name === part); if (!node) { node = { name: part, slug: currentPath, title: isLeaf ? doc.title : slugToTitle(part), children: [], isLeaf: false, }; current.push(node); } if (isLeaf) { node.isLeaf = true; node.title = doc.title; } else if (!node.title) { node.title = slugToTitle(part); } current = node.children; } } function sortNodes(nodes: TreeNode[]): TreeNode[] { return nodes.sort((a, b) => { const aFolder = a.children.length > 0 ? 0 : 1; const bFolder = b.children.length > 0 ? 0 : 1; if (aFolder !== bFolder) return aFolder - bFolder; return (a.title || a.name).localeCompare(b.title || b.name); }); } function sortAll(nodes: TreeNode[]): TreeNode[] { const sorted = sortNodes(nodes); for (const node of sorted) { if (node.children.length > 0) sortAll(node.children); } return sorted; } return sortAll(tree); } function renderTree(nodes: TreeNode[]) { return ( ); } function SectionTree({ section, docs }: { section: string; docs: { slug: string; title: string }[] }) { const tree = buildFolderTree( docs.filter((d) => d.slug.startsWith(`${section}/`)), section, ); return (
{tree.length > 0 ? ( renderTree(tree) ) : (

No documents

)}
); } export default async function HomePage() { const [all, sections] = await Promise.all([ listDocuments(), listSections(), ]); const recent = [...all] .sort( (a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime(), ) .slice(0, 6); return (
{/* Hero Section */}
{/* Status indicator stamp */}
PostgreSQL 16 Core · Model Context Protocol
{/* Primary Title with strong monolithic weight */}

Knowledge Base for
Humans and AI Agents.

{/* Subtitle */}

A high-performance technical knowledge repository. Humans read the web interface; AI assistants connect directly via native MCP tools. Both share one unified database source of truth.

{/* Quick Action Buttons */}
Browse Documentation Hybrid Search Create Document
{/* Live Telemetry Metric Strip */}
{all.length}
DB Documents
{sections.length}
Active Sections
RRF
FTS + Cosine Vectors
13 Tools
HTTP :4021 MCP
{/* Interactive System Architecture & Topology */}
{/* Browse Knowledge by Section */}

Knowledge Sections

{sections.map((s) => { const sectionDocs = all.filter((d) => (d.section || "docs").toLowerCase() === s.id); return (
{s.icon} {sectionDocs.length} docs →

{s.label}

{s.desc}

{/* Inline folder directory preview */}
({ slug: d.slug, title: d.title }))} />
); })}
{/* Recently Updated Knowledge */} {recent.length > 0 && (

Recently Updated

View all ({all.length})
{recent.map((d) => { const sInfo = getSectionMeta(d.section); return (
{sInfo?.icon} {d.section}

{d.title}

{d.tags.length > 0 && (
{d.tags.slice(0, 3).map((t) => ( #{t} ))}
)} ); })}
)} {/* Connect AI Assistant Showcase */}
[ MCP_INTEGRATION ]

Model Context Protocol Configuration

Equip Claude Desktop, Cursor, Antigravity, or custom agents with direct access to your knowledge base via semantic search, read resources, and document tools.

); }