From 8cf317af6831c4baabc26f950181622804a68d23 Mon Sep 17 00:00:00 2001 From: adam jones Date: Mon, 10 Nov 2025 12:37:36 +0000 Subject: [PATCH] Add simple web UI for browsing the registry (#757) ## Summary Adds a clean, minimal web interface at `/` for browsing MCP servers in the registry. Built as a single self-contained HTML file embedded in the Go binary. ## Features - Responsive grid layout (1/2/3 columns based on screen size) - Search servers by name - Filter to show only latest versions (default on) - "Recently Updated" section for servers updated in the last hour - Expandable cards with full server metadata and JSON viewer - Debug modal to switch between production/staging/local/custom API endpoints - Full URL parameter support and browser history navigation ## Implementation - Single HTML file (~400 lines) with Tailwind CSS via CDN - Zero build dependencies - Embedded using `//go:embed` - Served directly from router at root path - Uses stable v0.1 API endpoints Fixes #99 --- AI disclosure: this is 99% vibed with Claude. It's intended as a v0 to get something up and working, and then maybe at a later date we can replace it with something more real. --- internal/api/handlers/v0/ui.go | 13 + internal/api/handlers/v0/ui_index.html | 519 +++++++++++++++++++++++++ internal/api/router/router.go | 11 +- 3 files changed, 540 insertions(+), 3 deletions(-) create mode 100644 internal/api/handlers/v0/ui.go create mode 100644 internal/api/handlers/v0/ui_index.html diff --git a/internal/api/handlers/v0/ui.go b/internal/api/handlers/v0/ui.go new file mode 100644 index 0000000..32aadd4 --- /dev/null +++ b/internal/api/handlers/v0/ui.go @@ -0,0 +1,13 @@ +package v0 + +import ( + _ "embed" +) + +//go:embed ui_index.html +var embedUI string + +// GetUIHTML returns the embedded HTML for the UI +func GetUIHTML() string { + return embedUI +} diff --git a/internal/api/handlers/v0/ui_index.html b/internal/api/handlers/v0/ui_index.html new file mode 100644 index 0000000..ba04a4b --- /dev/null +++ b/internal/api/handlers/v0/ui_index.html @@ -0,0 +1,519 @@ + + + + + + Official MCP Registry + + + + +
+ +
+

Official MCP Registry

+

Discover Model Context Protocol servers

+ +
+ + + + + +
+
+ + +
+ +
+ + +
+ Loading servers... +
+ + + + + + +
+ + + + + + + + + + diff --git a/internal/api/router/router.go b/internal/api/router/router.go index 73283a0..d951e60 100644 --- a/internal/api/router/router.go +++ b/internal/api/router/router.go @@ -184,14 +184,19 @@ func NewHumaAPI(cfg *config.Config, registry service.RegistryService, mux *http. // Add /metrics for Prometheus metrics using promhttp mux.Handle("/metrics", metrics.PrometheusHandler()) - // Add redirect from / to docs and 404 handler for all other routes + // Add UI and 404 handler for all other routes mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { if r.URL.Path == "/" { - http.Redirect(w, r, "https://github.com/modelcontextprotocol/registry/tree/main/docs", http.StatusTemporaryRedirect) + // Serve UI at root + w.Header().Set("Content-Type", "text/html; charset=utf-8") + _, err := w.Write([]byte(v0.GetUIHTML())) + if err != nil { + http.Error(w, "Failed to write response", http.StatusInternalServerError) + } return } - // Handle 404 for all other routes + // Handle 404 for all non-matched routes handle404(w, r) })