From c5cd9eb359d4e51bf82a08d5d57384997baddfc3 Mon Sep 17 00:00:00 2001 From: Dustin Healy <54083382+dustinhealy@users.noreply.github.com> Date: Wed, 25 Jun 2025 23:54:53 -0700 Subject: [PATCH] auth revamp --- .../SidePanel/Agents/AgentConfig.tsx | 3 +- .../components/SidePanel/Builder/MCPAuth.tsx | 266 +++++++++++++++--- client/src/locales/en/translation.json | 15 + 3 files changed, 237 insertions(+), 47 deletions(-) diff --git a/client/src/components/SidePanel/Agents/AgentConfig.tsx b/client/src/components/SidePanel/Agents/AgentConfig.tsx index 2afa56601c..cc653d7d7c 100644 --- a/client/src/components/SidePanel/Agents/AgentConfig.tsx +++ b/client/src/components/SidePanel/Agents/AgentConfig.tsx @@ -12,6 +12,7 @@ import Instructions from './Instructions'; import AgentAvatar from './AgentAvatar'; import FileContext from './FileContext'; import SearchForm from './Search/Form'; +import MCPSection from './MCPSection'; import { useLocalize } from '~/hooks'; import FileSearch from './FileSearch'; import Artifacts from './Artifacts'; @@ -355,7 +356,7 @@ export default function AgentConfig({ {/* MCP Section */} - {/* */} + { - if (type === 'none') { - // Reset auth fields when type is none - setValue('api_key', ''); - setValue('authorization_type', AuthorizationTypeEnum.Basic); - setValue('custom_auth_header', ''); - setValue('oauth_client_id', ''); - setValue('oauth_client_secret', ''); - setValue('authorization_url', ''); - setValue('client_url', ''); - setValue('scope', ''); - setValue('token_exchange_method', TokenExchangeMethodEnum.DefaultPost); - } - }, [type, setValue]); + const addCustomHeader = () => { + const newHeader = { + id: Date.now().toString(), + name: '', + value: '', + }; + setValue('customHeaders', [...customHeaders, newHeader]); + }; + + const removeCustomHeader = (id: string) => { + setValue( + 'customHeaders', + customHeaders.filter((header: any) => header.id !== id), + ); + }; + + const updateCustomHeader = (id: string, field: 'name' | 'value', value: string) => { + setValue( + 'customHeaders', + customHeaders.map((header: any) => + header.id === id ? { ...header, [field]: value } : header, + ), + ); + }; + + const handleAddPlaceholder = (placeholder: UserInfoPlaceholder) => { + const newHeader = { + id: Date.now().toString(), + name: placeholder.label, + value: placeholder.value, + }; + setValue('customHeaders', [...customHeaders, newHeader]); + setIsHeadersMenuOpen(false); + }; + + const headerMenuItems = [ + ...userInfoPlaceholders.map((placeholder) => ({ + label: `${placeholder.label} - ${placeholder.description}`, + onClick: () => handleAddPlaceholder(placeholder), + })), + ]; return ( - - - +
+ {/* Authentication Accordion */} + + + + {localize('com_ui_authentication')} + + +
+ {/* Custom Headers Section - Individual Inputs Version */} +
+
+ + setIsHeadersMenuOpen(!isHeadersMenuOpen)} + className="flex h-7 items-center gap-1 rounded-md border border-border-medium bg-surface-secondary px-2 py-0 text-xs text-text-primary transition-colors duration-200 hover:bg-surface-tertiary" + > + + {localize('com_ui_mcp_headers')} + + } + /> +
+ +
+ {customHeaders.length === 0 ? ( +
+

+ {localize('com_ui_mcp_no_custom_headers')} +

+ +
+ ) : ( + <> + {customHeaders.map((header: any) => ( +
+ updateCustomHeader(header.id, 'name', e.target.value)} + className="min-w-0 flex-1 rounded-md border border-border-medium bg-surface-primary px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring" + /> + updateCustomHeader(header.id, 'value', e.target.value)} + className="min-w-0 flex-1 rounded-md border border-border-medium bg-surface-primary px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring" + /> + +
+ ))} + {/* Add New Header Button */} +
+ +
+ + )} +
+
+
+
+
+
+ + {/* Configuration Accordion */} + + + + {localize('com_ui_mcp_configuration')} + + +
+ {/* Request Timeout */} +
+ + +

+ {localize('com_ui_mcp_request_timeout_description')} +

+
+ + {/* Connection Timeout */} +
+ + +

+ {localize('com_ui_mcp_connection_timeout_description')} +

+
+
+
+
+
+
); } diff --git a/client/src/locales/en/translation.json b/client/src/locales/en/translation.json index 4c6ab1df47..c816d4921f 100644 --- a/client/src/locales/en/translation.json +++ b/client/src/locales/en/translation.json @@ -827,6 +827,21 @@ "com_ui_mcp_server_not_found": "Server not found.", "com_ui_mcp_servers": "MCP Servers", "com_ui_mcp_url": "MCP Server URL", + "com_ui_mcp_custom_headers": "Custom Headers", + "com_ui_mcp_headers": "Headers", + "com_ui_mcp_no_custom_headers": "No custom headers configured", + "com_ui_mcp_add_header": "Add Header", + "com_ui_mcp_header_name": "Header Name", + "com_ui_mcp_header_value": "Header Value", + "com_ui_mcp_configuration": "Configuration", + "com_ui_mcp_request_timeout": "Request Timeout (ms)", + "com_ui_mcp_request_timeout_description": "Maximum time in milliseconds to wait for a response from the MCP server", + "com_ui_mcp_connection_timeout": "Connection Timeout (ms)", + "com_ui_mcp_connection_timeout_description": "Maximum time in milliseconds to establish connection to the MCP server", + "com_ui_mcp_reset_timeout_on_progress": "Reset Timeout on Progress", + "com_ui_mcp_reset_timeout_on_progress_description": "Reset the request timeout when progress is received", + "com_ui_mcp_max_total_timeout": "Maximum Total Timeout (ms)", + "com_ui_mcp_max_total_timeout_description": "Maximum total time in milliseconds allowed for the entire request including retries", "com_ui_memories": "Memories", "com_ui_memories_allow_create": "Allow creating Memories", "com_ui_memories_allow_opt_out": "Allow users to opt out of Memories",