2025-12-28 18:20:15 +01:00
|
|
|
import { MCPIcon } from '@librechat/client';
|
|
|
|
|
import { PermissionTypes, Permissions } from 'librechat-data-provider';
|
|
|
|
|
import type { MCPServerStatusIconProps } from '~/components/MCP/MCPServerStatusIcon';
|
|
|
|
|
import type { MCPServerDefinition } from '~/hooks';
|
|
|
|
|
import { useLocalize, useHasAccess } from '~/hooks';
|
|
|
|
|
import MCPServerCard from './MCPServerCard';
|
2025-12-04 21:37:23 +01:00
|
|
|
|
|
|
|
|
interface MCPServerListProps {
|
|
|
|
|
servers: MCPServerDefinition[];
|
2025-12-28 18:20:15 +01:00
|
|
|
getServerStatusIconProps: (serverName: string) => MCPServerStatusIconProps;
|
2025-12-10 16:36:41 +01:00
|
|
|
isFiltered?: boolean;
|
2025-12-04 21:37:23 +01:00
|
|
|
}
|
|
|
|
|
|
2025-12-28 18:20:15 +01:00
|
|
|
/**
|
|
|
|
|
* Renders a list of MCP server cards with empty state handling
|
|
|
|
|
*/
|
2025-12-10 16:36:41 +01:00
|
|
|
export default function MCPServerList({
|
|
|
|
|
servers,
|
|
|
|
|
getServerStatusIconProps,
|
|
|
|
|
isFiltered = false,
|
|
|
|
|
}: MCPServerListProps) {
|
2025-12-28 18:20:15 +01:00
|
|
|
const localize = useLocalize();
|
2025-12-04 21:37:23 +01:00
|
|
|
const canCreateEditMCPs = useHasAccess({
|
|
|
|
|
permissionType: PermissionTypes.MCP_SERVERS,
|
|
|
|
|
permission: Permissions.CREATE,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (servers.length === 0) {
|
|
|
|
|
return (
|
2025-12-28 18:20:15 +01:00
|
|
|
<div className="flex flex-col items-center justify-center rounded-lg border border-border-light bg-transparent p-6 text-center">
|
|
|
|
|
<div className="mb-2 flex size-10 items-center justify-center rounded-full bg-surface-tertiary">
|
|
|
|
|
<MCPIcon className="size-5 text-text-secondary" aria-hidden="true" />
|
|
|
|
|
</div>
|
2025-12-10 16:36:41 +01:00
|
|
|
{isFiltered ? (
|
|
|
|
|
<p className="text-sm text-text-secondary">{localize('com_ui_no_mcp_servers_match')}</p>
|
|
|
|
|
) : (
|
|
|
|
|
<>
|
2025-12-28 18:20:15 +01:00
|
|
|
<p className="text-sm font-medium text-text-primary">
|
|
|
|
|
{localize('com_ui_no_mcp_servers')}
|
|
|
|
|
</p>
|
|
|
|
|
<p className="mt-0.5 text-xs text-text-secondary">
|
2025-12-10 16:36:41 +01:00
|
|
|
{localize('com_ui_add_first_mcp_server')}
|
|
|
|
|
</p>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
2025-12-04 21:37:23 +01:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2025-12-28 18:20:15 +01:00
|
|
|
<div className="space-y-2" role="list" aria-label={localize('com_ui_mcp_servers')}>
|
|
|
|
|
{servers.map((server) => (
|
|
|
|
|
<div key={`card_${server.serverName}`} role="listitem">
|
|
|
|
|
<MCPServerCard
|
|
|
|
|
server={server}
|
|
|
|
|
getServerStatusIconProps={getServerStatusIconProps}
|
|
|
|
|
canCreateEditMCPs={canCreateEditMCPs}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
2025-12-04 21:37:23 +01:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|