From 68430a19ec21b036af63ee9ba9530cb9ffa7fa38 Mon Sep 17 00:00:00 2001 From: karthicksndr Date: Tue, 10 Feb 2026 10:13:05 +1300 Subject: [PATCH 1/3] provision a new parameter for custom mcp registry url - MCP_REGISTRY_CUSTOM_MCP_REGISTRY_URL When this parameter is specified, the default registry.modelcontextprotocol.io is ignored and the custom registry url is set for custom mcp registries --- internal/api/handlers/v0/ui.go | 33 ++++++++++++++++++++-- internal/api/handlers/v0/ui_index.html | 39 ++++++++++++++++++++++---- internal/api/router/router.go | 2 +- internal/config/config.go | 1 + 4 files changed, 65 insertions(+), 10 deletions(-) diff --git a/internal/api/handlers/v0/ui.go b/internal/api/handlers/v0/ui.go index 32aadd4e2..37878c218 100644 --- a/internal/api/handlers/v0/ui.go +++ b/internal/api/handlers/v0/ui.go @@ -2,12 +2,39 @@ package v0 import ( _ "embed" + "encoding/json" + "strings" ) //go:embed ui_index.html var embedUI string -// GetUIHTML returns the embedded HTML for the UI -func GetUIHTML() string { - return embedUI +const ( + defaultAPIBasePlaceholder = "PLACEHOLDER" + defaultAPIBaseValueKey = "__DEFAULT_API_BASE_VALUE__" + defaultAPIBasePlaceholderKey = "__DEFAULT_API_BASE_PLACEHOLDER__" +) + +// GetUIHTML returns the embedded HTML for the UI with injected API base URL configuration. +// The defaultBaseURL is injected into the JavaScript context to allow the frontend to +// access a custom registry URL set via environment variable. If no custom URL is provided, +// the frontend will fall back to the default production registry. +func GetUIHTML(defaultBaseURL string) string { + // Marshal the URL to get a JSON-encoded string for safe JavaScript injection + jsonEncoded, err := json.Marshal(defaultBaseURL) + if err != nil { + // Fallback to empty string if marshaling fails (should be very rare for strings) + jsonEncoded = []byte(`""`) + } + + // Trim the surrounding quotes from JSON encoding to get the raw URL value + value := strings.Trim(string(jsonEncoded), `"`) + + // Inject the actual URL value into the UI + html := strings.ReplaceAll(embedUI, defaultAPIBaseValueKey, value) + + // Inject the placeholder sentinel value for frontend comparison logic + html = strings.ReplaceAll(html, defaultAPIBasePlaceholderKey, defaultAPIBasePlaceholder) + + return html } diff --git a/internal/api/handlers/v0/ui_index.html b/internal/api/handlers/v0/ui_index.html index 38bac7f7b..b3e77c68d 100644 --- a/internal/api/handlers/v0/ui_index.html +++ b/internal/api/handlers/v0/ui_index.html @@ -138,6 +138,9 @@

API Base URL