🔌 refactor: MCP UI with Improved Accessibility and Reusable Components (#11118)

* feat: enhance MCP server selection UI with new components and improved accessibility

* fix(i18n): add missing com_ui_mcp_servers translation key

The MCP server menu aria-label was referencing a non-existent translation
key. Added the missing key for accessibility.

* feat(MCP): enhance MCP components with improved accessibility and focus management

* fix(i18n): remove outdated MCP server translation keys

* fix(MCPServerList): improve color contrast by updating text color for no MCP servers message

* refactor(MCP): Server status components and improve user action handling
Updated MCPServerStatusIcon to use a unified icon system for better clarity
Introduced new MCPCardActions component for standardized action buttons on server cards
Created MCPServerCard component to encapsulate server display logic and actions
Enhanced MCPServerList to render MCPServerCard components, improving code organization
Added MCPStatusBadge for consistent status representation in dialogs
Updated utility functions for status color and text retrieval to align with new design
Improved localization keys for better clarity and consistency in user messages

* style(MCP): update button and card background styles for improved UI consistency

* feat(MCP): implement global server initialization state management using Jotai

* refactor(MCP): modularize MCPServerDialog into structured component architecture

- Split monolithic dialog into dedicated section components (Auth, BasicInfo, Connection, Transport, Trust)
- Extract form logic into useMCPServerForm custom hook
- Add utility modules for JSON import and URL handling
- Introduce reusable SecretInput component in @librechat/client
- Remove deprecated MCPAuth component

* style(MCP): update button styles for improved layout and adjust empty state background color

* refactor(Radio): enhance component mounting logic and background style updates

* refactor(translation): remove unused keys and streamline localization strings
This commit is contained in:
Marco Beretta 2025-12-28 18:20:15 +01:00 committed by GitHub
parent 0b8e0fcede
commit e4870ed0b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 2594 additions and 1646 deletions

View file

@ -1,12 +1,12 @@
import { useState, useRef, useMemo } from 'react';
import { Plus } from 'lucide-react';
import { PermissionTypes, Permissions } from 'librechat-data-provider';
import { Button, Spinner, FilterInput, OGDialogTrigger } from '@librechat/client';
import { Button, Spinner, FilterInput, OGDialogTrigger, TooltipAnchor } from '@librechat/client';
import { useLocalize, useMCPServerManager, useHasAccess } from '~/hooks';
import MCPServerList from './MCPServerList';
import MCPServerDialog from './MCPServerDialog';
import MCPConfigDialog from '~/components/MCP/MCPConfigDialog';
import MCPAdminSettings from './MCPAdminSettings';
import MCPServerDialog from './MCPServerDialog';
import MCPServerList from './MCPServerList';
export default function MCPBuilderPanel() {
const localize = useLocalize();
@ -37,40 +37,48 @@ export default function MCPBuilderPanel() {
return (
<div className="flex h-full w-full flex-col overflow-visible">
<div role="region" aria-label="MCP Builder" className="mt-2 space-y-2">
{/* Admin Settings Button */}
<MCPAdminSettings />
<div role="region" aria-label={localize('com_ui_mcp_servers')} className="mt-2 space-y-2">
{/* Toolbar: Search + Add Button */}
<div className="flex items-center gap-2">
<FilterInput
inputId="mcp-filter"
label={localize('com_ui_filter_mcp_servers')}
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
containerClassName="flex-1"
/>
{hasCreateAccess && (
<MCPServerDialog
open={showDialog}
onOpenChange={setShowDialog}
triggerRef={addButtonRef}
>
<OGDialogTrigger asChild>
<TooltipAnchor
description={localize('com_ui_add_mcp')}
side="bottom"
render={
<Button
ref={addButtonRef}
variant="outline"
size="icon"
className="shrink-0 bg-transparent"
onClick={() => setShowDialog(true)}
aria-label={localize('com_ui_add_mcp')}
>
<Plus className="size-4" aria-hidden="true" />
</Button>
}
/>
</OGDialogTrigger>
</MCPServerDialog>
)}
</div>
{/* Search Input */}
<FilterInput
inputId="mcp-filter"
label={localize('com_ui_filter_mcp_servers')}
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
/>
{hasCreateAccess && (
<MCPServerDialog open={showDialog} onOpenChange={setShowDialog} triggerRef={addButtonRef}>
<OGDialogTrigger asChild>
<div className="flex w-full justify-end">
<Button
ref={addButtonRef}
variant="outline"
className="w-full bg-transparent"
onClick={() => setShowDialog(true)}
>
<Plus className="size-4" aria-hidden />
{localize('com_ui_add_mcp')}
</Button>
</div>
</OGDialogTrigger>
</MCPServerDialog>
)}
{/* Server List */}
{/* Server Cards List */}
{isLoading ? (
<div className="flex items-center justify-center p-8">
<Spinner className="h-6 w-6" />
<Spinner className="size-6" aria-label={localize('com_ui_loading')} />
</div>
) : (
<MCPServerList
@ -79,7 +87,12 @@ export default function MCPBuilderPanel() {
isFiltered={searchQuery.trim().length > 0}
/>
)}
{/* Config Dialog for custom user vars */}
{configDialogProps && <MCPConfigDialog {...configDialogProps} />}
{/* Admin Settings Section */}
<MCPAdminSettings />
</div>
</div>
);