The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(mcp): clear env rows when HTTP origin changes in edit mode
Steven Enamakele2406e273ba9
diff --git a/app/src/components/channels/mcp/ConnectAuthModal.tsx b/app/src/components/channels/mcp/ConnectAuthModal.tsxindex 56e59560da..0e574883f6 100644--- a/app/src/components/channels/mcp/ConnectAuthModal.tsx+++ b/app/src/components/channels/mcp/ConnectAuthModal.tsx@@ -289,6 +289,7 @@ const ConnectAuthModal = ({ server, onClose, onConnected }: ConnectAuthModalPropvoid (async () => {try {const url = await mcpClientsApi.oauthBegin(server.server_id);+ if (oauthCancelled.current) return;await openUrl(url);const started = Date.now();const poll = async (): Promise<void> => {diff --git a/app/src/components/channels/mcp/CustomServerFormModal.tsx b/app/src/components/channels/mcp/CustomServerFormModal.tsxindex fe6d97a7a0..99fbc2af21 100644--- a/app/src/components/channels/mcp/CustomServerFormModal.tsx+++ b/app/src/components/channels/mcp/CustomServerFormModal.tsx@@ -81,6 +81,14 @@ const inputClass =const labelClass = 'block text-xs font-medium text-content-muted mb-1';+const originOf = (value: string): string | null => {+ try {+ return new URL(value).origin;+ } catch {+ return null;+ }+};+const CustomServerFormModal = ({ mode, server, onClose, onSubmit }: CustomServerFormModalProps) => {const { t } = useT();@@ -99,6 +107,10 @@ const CustomServerFormModal = ({ mode, server, onClose, onSubmit }: CustomServer// reverting to the stored set. Keyed by transport; the value is what to show// when that transport becomes active again.const stashedRows = useRef<Partial<Record<TransportKind, EnvRow[]>>>({});+ const initialHttpOrigin = useRef(+ mode === 'edit' && seedTransport(server) === 'http_remote' ? originOf(seedUrl(server)) : null+ );+ const httpOriginChanged = useRef(false);const isEdit = mode === 'edit';@@ -155,6 +167,26 @@ const CustomServerFormModal = ({ mode, server, onClose, onSubmit }: CustomServersetError(null);};+ const handleUrlChange = (next: string) => {+ setUrl(next);+ const initialOrigin = initialHttpOrigin.current;+ const nextOrigin = originOf(next);+ if (nextOrigin === initialOrigin) {+ httpOriginChanged.current = false;+ } else if (+ isEdit &&+ transport === 'http_remote' &&+ initialOrigin &&+ !httpOriginChanged.current+ ) {+ // The core drops credentials when the HTTP origin changes. Clear the+ // write-only rows too, so the form cannot imply that blank means keep.+ setEnvRows([newRow()]);+ setError(null);+ httpOriginChanged.current = true;+ }+ };+/*** Collapse the editor rows into the wire map.*@@ -342,7 +374,7 @@ const CustomServerFormModal = ({ mode, server, onClose, onSubmit }: CustomServerid="custom-server-url"className={inputClass}value={url}- onChange={e => setUrl(e.target.value)}+ onChange={e => handleUrlChange(e.target.value)}placeholder={t('mcp.custom.form.urlPlaceholder')}/></div>diff --git a/src/openhuman/mcp/registry/store_tests.rs b/src/openhuman/mcp/registry/store_tests.rsindex 3ab7695d6b..ce9a112943 100644--- a/src/openhuman/mcp/registry/store_tests.rs+++ b/src/openhuman/mcp/registry/store_tests.rs@@ -571,3 +571,4 @@err.to_string().contains("Failed to add bogus column to mcp_servers"),"unexpected error: {err}"+use super::*;diff --git a/src/openhuman/mcp/registry/types_tests.rs b/src/openhuman/mcp/registry/types_tests.rsindex cc0ca19397..1459923c4a 100644--- a/src/openhuman/mcp/registry/types_tests.rs+++ b/src/openhuman/mcp/registry/types_tests.rs@@ -359,3 +359,5 @@let v = serde_json::to_value(&s).unwrap();assert_eq!(v["status"], json!("connected"));// `auth_hint` is omitted from the wire when absent (skip_serializing_if).+use super::*;+use serde_json::json;