From 7c989ce26cb5e6db972dc3a8be92b2c784ab7e79 Mon Sep 17 00:00:00 2001 From: Gabrielsv01 Date: Mon, 4 May 2026 23:28:04 -0300 Subject: [PATCH] Validate remote MCP URLs in config UI --- .../src/components/config/config-page.tsx | 14 ++++++ .../src/components/config/config-sections.tsx | 49 +++++++++++++++++++ web/frontend/src/i18n/locales/en.json | 5 ++ web/frontend/src/i18n/locales/zh.json | 5 ++ 4 files changed, 73 insertions(+) diff --git a/web/frontend/src/components/config/config-page.tsx b/web/frontend/src/components/config/config-page.tsx index e5c1f736c..469ec34d8 100644 --- a/web/frontend/src/components/config/config-page.tsx +++ b/web/frontend/src/components/config/config-page.tsx @@ -338,6 +338,20 @@ export function ConfigPage() { throw new Error(`MCP server ${server.name} requires a URL.`) } + try { + const parsedURL = new URL(server.url) + if ( + parsedURL.protocol !== "http:" && + parsedURL.protocol !== "https:" + ) { + throw new Error("invalid protocol") + } + } catch { + throw new Error( + `MCP server ${server.name} requires a valid HTTP(S) URL.`, + ) + } + return [ server.name, { diff --git a/web/frontend/src/components/config/config-sections.tsx b/web/frontend/src/components/config/config-sections.tsx index 2d3237105..022eb8fdc 100644 --- a/web/frontend/src/components/config/config-sections.tsx +++ b/web/frontend/src/components/config/config-sections.tsx @@ -399,6 +399,42 @@ export function MCPSection({ onServerFieldChange(server.id, "enabled", checked) } /> + + {server.type !== "stdio" ? ( @@ -442,6 +478,19 @@ export function MCPSection({ ) } /> + + onServerFieldChange( + server.id, + "envFile", + e.target.value, + ) + } + />