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
fix(mcp): handle missing server name in McpServerRows
Steven Enamakelfefef18e49f8
diff --git a/app/src/components/channels/mcp/McpServerRows.tsx b/app/src/components/channels/mcp/McpServerRows.tsxindex 4224ae9107..f9a04fe32d 100644--- a/app/src/components/channels/mcp/McpServerRows.tsx+++ b/app/src/components/channels/mcp/McpServerRows.tsx@@ -14,10 +14,7 @@* state says so.*/import {- AlertTriangle,- Check,ChevronRight,- Info,Pencil,Plug,Plus,@@ -28,14 +25,16 @@ import {Unplug,Wrench,} from 'lucide-react';-import { useCallback, useEffect, useState } from 'react';+import { Fragment, type ReactNode, useCallback, useEffect, useMemo, useState } from 'react';import { useT } from '../../../lib/i18n/I18nContext';import { mcpClientsApi } from '../../../services/api/mcpClientsApi';-import Badge from '../../ui/Badge';+import { Alert, AlertDescription } from '../../ui';+import Badge, { type BadgeVariant } from '../../ui/Badge';import Button from '../../ui/Button';-import Card from '../../ui/Card';import { ConfirmDialog } from '../../ui/ConfirmDialog';+import DataTable, { type DataTableColumn } from '../../ui/DataTable';+import { TableCell, TableRow } from '../../ui/Table';import ConnectAuthModal from './ConnectAuthModal';import McpIconButton from './McpIconButton';import McpServerForm from './McpServerForm';@@ -59,28 +58,22 @@ const dialOf = (server: InstalledServer): string => {return [server.command, ...server.args].filter(Boolean).join(' ');};-/** The status line's tone and icon. `null` for a plain disconnected row. */-const statusTone = (- status: ServerStatus-): { className: string; Icon: typeof Check; key: string } | null => {- switch (status) {- case 'connected':- return { className: 'text-sage-700 dark:text-sage-300', Icon: Check, key: 'connected' };- case 'connecting':- return { className: 'text-content-muted', Icon: Info, key: 'connecting' };- case 'unauthorized':- return {- className: 'text-amber-700 dark:text-amber-300',- Icon: AlertTriangle,- key: 'unauthorized',- };- case 'error':- return { className: 'text-coral-600 dark:text-coral-300', Icon: AlertTriangle, key: 'error' };- default:- return null;- }+/** Status chip per connection state; `null` for a plain disconnected row. */+const STATUS_TONE: Record<ServerStatus, { variant: BadgeVariant; labelKey: string } | null> = {+ connected: { variant: 'success', labelKey: 'channels.status.connected' },+ connecting: { variant: 'primary', labelKey: 'channels.status.connecting' },+ unauthorized: { variant: 'warning', labelKey: 'mcp.status.unauthorized' },+ error: { variant: 'danger', labelKey: 'channels.status.error' },+ disconnected: null,};+/** The square identity tile every row in the MCP / Skills tables leads with. */+export const RowIcon = ({ children }: { children: ReactNode }) => (+ <span className="flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-md border border-line bg-surface-muted">+ {children}+ </span>+);+type ToolsState =| { kind: 'loading' }| { kind: 'error'; message: string }@@ -223,204 +216,263 @@ const McpServerRows = ({);const statusMap = new Map(statuses.map(s => [s.server_id, s]));+ const [query, setQuery] = useState('');+ const [transports, setTransports] = useState<ReadonlySet<string>>(new Set());- return (- <section className="space-y-3" data-testid="mcp-servers-section">- <div className="flex items-center justify-between gap-3">- <h2 className="text-xs font-medium uppercase tracking-wide text-content-muted">- {t('mcp.rows.title')}- </h2>- <Button- variant="primary"- size="sm"- leadingIcon={<Plus className="size-4" aria-hidden="true" />}- onClick={() => setForm(undefined)}- data-testid="mcp-add-server">- {t('mcp.rows.add')}- </Button>- </div>- <p className="text-sm text-content-muted">{t('mcp.rows.intro')}</p>+ const visible = useMemo(() => {+ const needle = query.trim().toLowerCase();+ return servers.filter(server => {+ const kind = server.transport?.kind === 'http_remote' ? 'hosted' : 'local';+ if (transports.size > 0 && !transports.has(kind)) return false;+ if (!needle) return true;+ return (+ server.display_name.toLowerCase().includes(needle) ||+ server.qualified_name.toLowerCase().includes(needle) ||+ dialOf(server).toLowerCase().includes(needle)+ );+ });+ }, [servers, query, transports]);- {error && (- <p- role="alert"- className="rounded-md border border-coral-500/30 bg-coral-500/10 px-3 py-2 text-xs text-coral-700 dark:text-coral-300">- {error}- </p>- )}+ const columns: DataTableColumn<InstalledServer>[] = [+ { id: 'name', header: t('common.name'), className: 'w-full max-w-0' },+ { id: 'type', header: t('mcp.tab.transportFilter.label'), className: 'w-px whitespace-nowrap' },+ { id: 'status', header: t('dataTable.column.status'), className: 'w-px whitespace-nowrap' },+ {+ id: 'tools',+ header: t('dataTable.column.tools'),+ align: 'right',+ className: 'w-px whitespace-nowrap tabular-nums',+ },+ {+ id: 'actions',+ header: <span className="sr-only">{t('dataTable.column.actions')}</span>,+ align: 'right',+ className: 'w-px whitespace-nowrap',+ },+ ];- <Card padded divided={false}>- {servers.length === 0 ? (- <div className="space-y-2" data-testid="mcp-installed-empty">- <p className="text-sm text-content-muted">{t('mcp.installed.empty')}</p>- <p className="flex items-center gap-3">- <Button- variant="tertiary"- size="xs"- onClick={() => setForm(undefined)}- className="h-auto p-0">- {t('mcp.rows.add')}- </Button>- <Button variant="tertiary" size="xs" onClick={onAddInJson} className="h-auto p-0">- {t('mcp.installed.emptyAddInJson')}- </Button>- </p>- </div>- ) : (- <ul className="divide-y divide-line-subtle">- {servers.map(server => {- const conn = statusMap.get(server.server_id);- const status: ServerStatus = conn?.status ?? 'disconnected';- const tone = statusTone(status);- const hosted = server.transport?.kind === 'http_remote';- const connected = status === 'connected';- const rowBusy = busy === server.server_id;- return (- <li- key={server.server_id}- data-testid="mcp-installed-row"- className="space-y-2 py-3 first:pt-0 last:pb-0">- <div className="flex items-start gap-3">- <span className="mt-0.5 flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-md border border-line bg-surface-muted">- {server.icon_url ? (- <img src={server.icon_url} alt="" className="size-full object-cover" />- ) : (- <Server className="size-4 text-content-muted" aria-hidden="true" />- )}- </span>- <div className="min-w-0 flex-1 space-y-1">- <div className="flex flex-wrap items-center gap-2">- {/* The row's handle on its own detail view. A button on- the name rather than a trailing "Open": the row's- right edge is already several controls deep, and the- name is what a user points at when they want to know- what a server is. The chevron is not decoration —- hover styling alone makes a name that opens something- indistinguishable from one that does not. */}- <button- type="button"- data-testid="mcp-server-open"- aria-label={t('mcp.rows.open').replace('{name}', server.display_name)}- onClick={() => onOpen(server.server_id)}- className="inline-flex cursor-pointer items-center gap-0.5 rounded-sm text-sm font-medium text-content transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500">- {server.display_name}- <ChevronRight- className="size-3.5 text-content-muted"- aria-hidden="true"- />- </button>- <Badge variant="neutral">- {t(hosted ? 'mcp.tab.transport.hosted' : 'mcp.tab.transport.local')}- </Badge>- {tone && (- <span- className={`inline-flex items-center gap-1 text-xs ${tone.className}`}- data-testid="mcp-row-status">- <tone.Icon className="size-3" aria-hidden="true" />- {t(- tone.key === 'unauthorized'- ? 'mcp.status.unauthorized'- : `channels.status.${tone.key}`- )}- {connected && conn && conn.tool_count > 0- ? ` · ${t(- conn.tool_count === 1- ? 'mcp.installed.toolSingular'- : 'mcp.installed.toolPlural'- ).replace('{count}', String(conn.tool_count))}`- : null}- </span>- )}- {!server.enabled && (- <Badge variant="neutral" data-testid="mcp-disabled-badge">- {t('mcp.status.disabled')}- </Badge>- )}- </div>- <p className="truncate font-mono text-xs text-content-muted">- {dialOf(server)}- </p>- </div>- <span className="flex shrink-0 items-center gap-0.5">- {server.enabled && (- <McpIconButton- label={t(connected ? 'mcp.rows.disconnect' : 'mcp.rows.connect').replace(- '{name}',- server.display_name- )}- icon={connected ? Unplug : Plug}- tone={connected ? 'default' : 'primary'}- testId="mcp-lifecycle"- busy={rowBusy}- disabled={busy !== null}- onClick={() => {- if (connected) {- void run(server.server_id, async () => {- await mcpClientsApi.disconnect(server.server_id);- });- } else {- setConnectFor(server);- }- }}- />- )}- {connected && (- <McpIconButton- label={t(- toolsOpen.has(server.server_id)- ? 'mcp.rows.hideTools'- : 'mcp.rows.showTools'- ).replace('{name}', server.display_name)}- icon={Wrench}- testId="mcp-tools"- disabled={busy !== null}- onClick={() => toggleTools(server.server_id)}- />- )}- <McpIconButton- label={t(server.enabled ? 'mcp.rows.disable' : 'mcp.rows.enable').replace(- '{name}',- server.display_name- )}- icon={server.enabled ? Power : PowerOff}- testId="mcp-toggle"- busy={rowBusy}- disabled={busy !== null}- onClick={() =>- void run(server.server_id, async () => {- await mcpClientsApi.setEnabled(server.server_id, !server.enabled);- })- }- />- <McpIconButton- label={t('mcp.rows.edit').replace('{name}', server.display_name)}- icon={Pencil}- testId="mcp-edit"- disabled={busy !== null}- onClick={() => setForm(server)}- />- <McpIconButton- label={t('mcp.rows.remove').replace('{name}', server.display_name)}- icon={Trash2}- tone="destructive"- testId="mcp-remove"- disabled={busy !== null}- onClick={() => setRemoveFor(server)}- />- </span>- </div>- {conn?.last_error && status !== 'connected' && (- <p className="text-xs text-content-muted">{conn.last_error}</p>+ const renderServerRow = (server: InstalledServer) => {+ const conn = statusMap.get(server.server_id);+ const status: ServerStatus = conn?.status ?? 'disconnected';+ const tone = STATUS_TONE[status];+ const hosted = server.transport?.kind === 'http_remote';+ const connected = status === 'connected';+ const rowBusy = busy === server.server_id;+ const toolsShown = connected && toolsOpen.has(server.server_id);+ const lastError = conn?.last_error && status !== 'connected' ? conn.last_error : null;+ return (+ <Fragment key={server.server_id}>+ <TableRow data-testid="mcp-installed-row">+ <TableCell className="w-full max-w-0">+ <div className="flex min-w-0 items-center gap-3">+ <RowIcon>+ {server.icon_url ? (+ <img src={server.icon_url} alt="" className="size-full object-cover" />+ ) : (+ <Server className="size-4 text-content-muted" aria-hidden="true" />+ )}+ </RowIcon>+ <div className="min-w-0">+ {/* The name opens the server's detail view; the chevron says+ so — hover styling alone would not. */}+ <button+ type="button"+ data-testid="mcp-server-open"+ aria-label={t('mcp.rows.open').replace('{name}', server.display_name)}+ onClick={() => onOpen(server.server_id)}+ className="inline-flex max-w-full cursor-pointer items-center gap-0.5 rounded-sm text-sm font-medium text-content transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500">+ <span className="truncate">{server.display_name}</span>+ <ChevronRight className="size-3.5 shrink-0 text-content-muted" aria-hidden="true" />+ </button>+ <p className="truncate font-mono text-xs text-content-muted" title={dialOf(server)}>+ {dialOf(server)}+ </p>+ </div>+ </div>+ </TableCell>+ <TableCell className="w-px whitespace-nowrap">+ <Badge variant="neutral">+ {t(hosted ? 'mcp.tab.transport.hosted' : 'mcp.tab.transport.local')}+ </Badge>+ </TableCell>+ <TableCell className="w-px whitespace-nowrap">+ <span className="flex items-center gap-1.5">+ {tone ? (+ <Badge variant={tone.variant} data-testid="mcp-row-status">+ {t(tone.labelKey)}+ </Badge>+ ) : (+ <Badge variant="neutral">{t('channels.status.disconnected')}</Badge>+ )}+ {!server.enabled && (+ <Badge variant="neutral" dot={false} data-testid="mcp-disabled-badge">+ {t('mcp.status.disabled')}+ </Badge>+ )}+ </span>+ </TableCell>+ <TableCell className="w-px whitespace-nowrap text-right tabular-nums text-content-muted">+ {connected && conn ? conn.tool_count : '—'}+ </TableCell>+ <TableCell className="w-px whitespace-nowrap text-right">+ <span className="inline-flex items-center gap-0.5">+ {server.enabled && (+ <McpIconButton+ label={t(connected ? 'mcp.rows.disconnect' : 'mcp.rows.connect').replace(+ '{name}',+ server.display_name)}- {connected && toolsOpen.has(server.server_id) && (- <McpRowTools server={server} onTry={tool => setPlayground({ server, tool })} />+ icon={connected ? Unplug : Plug}+ tone={connected ? 'default' : 'primary'}+ testId="mcp-lifecycle"+ busy={rowBusy}+ disabled={busy !== null}+ onClick={() => {+ if (connected) {+ void run(server.server_id, async () => {+ await mcpClientsApi.disconnect(server.server_id);+ });+ } else {+ setConnectFor(server);+ }+ }}+ />+ )}+ {connected && (+ <McpIconButton+ label={t(toolsShown ? 'mcp.rows.hideTools' : 'mcp.rows.showTools').replace(+ '{name}',+ server.display_name)}- </li>- );- })}- </ul>+ icon={Wrench}+ testId="mcp-tools"+ disabled={busy !== null}+ onClick={() => toggleTools(server.server_id)}+ />+ )}+ <McpIconButton+ label={t(server.enabled ? 'mcp.rows.disable' : 'mcp.rows.enable').replace(+ '{name}',+ server.display_name+ )}+ icon={server.enabled ? Power : PowerOff}+ testId="mcp-toggle"+ busy={rowBusy}+ disabled={busy !== null}+ onClick={() =>+ void run(server.server_id, async () => {+ await mcpClientsApi.setEnabled(server.server_id, !server.enabled);+ })+ }+ />+ <McpIconButton+ label={t('mcp.rows.edit').replace('{name}', server.display_name)}+ icon={Pencil}+ testId="mcp-edit"+ disabled={busy !== null}+ onClick={() => setForm(server)}+ />+ <McpIconButton+ label={t('mcp.rows.remove').replace('{name}', server.display_name)}+ icon={Trash2}+ tone="destructive"+ testId="mcp-remove"+ disabled={busy !== null}+ onClick={() => setRemoveFor(server)}+ />+ </span>+ </TableCell>+ </TableRow>+ {/* Detail row: the last connection error and/or the expanded tool+ list, spanning the whole table under its server. */}+ {(lastError || toolsShown) && (+ <TableRow className="hover:bg-transparent">+ <TableCell colSpan={columns.length} className="space-y-2 pt-0">+ {lastError && <p className="pl-11 text-xs text-content-muted">{lastError}</p>}+ {toolsShown && (+ <div className="pl-11">+ <McpRowTools server={server} onTry={tool => setPlayground({ server, tool })} />+ </div>+ )}+ </TableCell>+ </TableRow>)}- </Card>+ </Fragment>+ );+ };++ return (+ <section className="flex h-full min-h-0 flex-col" data-testid="mcp-servers-section">+ <DataTable<InstalledServer>+ title={t('mcp.rows.title')}+ description={t('mcp.rows.intro')}+ actions={+ <Button+ variant="primary"+ size="sm"+ leadingIcon={<Plus className="size-4" aria-hidden="true" />}+ onClick={() => setForm(undefined)}+ data-testid="mcp-add-server">+ {t('mcp.rows.add')}+ </Button>+ }+ columns={columns}+ rows={visible}+ rowKey={server => server.server_id}+ renderRow={server => renderServerRow(server)}+ search={+ servers.length > 0+ ? {+ value: query,+ onChange: setQuery,+ placeholder: t('mcp.rows.searchPlaceholder'),+ testId: 'mcp-servers-search',+ }+ : undefined+ }+ filters={+ servers.length > 0+ ? [+ {+ id: 'transport',+ label: t('mcp.tab.transportFilter.label'),+ ariaLabel: t('mcp.tab.transportFilter.aria'),+ options: [+ { value: 'hosted', label: t('mcp.tab.transport.hosted') },+ { value: 'local', label: t('mcp.tab.transport.local') },+ ],+ selected: transports,+ onChange: setTransports,+ testId: 'mcp-transport-filter',+ },+ ]+ : undefined+ }+ pagination={{ pageSize: 25 }}+ error={+ error ? (+ <Alert variant="destructive" density="compact">+ <AlertDescription>{error}</AlertDescription>+ </Alert>+ ) : undefined+ }+ empty={+ servers.length === 0 ? (+ <div className="space-y-2 text-center" data-testid="mcp-installed-empty">+ <p className="text-sm text-content-muted">{t('mcp.installed.empty')}</p>+ <p className="flex items-center justify-center gap-3">+ <Button variant="secondary" size="sm" onClick={() => setForm(undefined)}>+ {t('mcp.rows.add')}+ </Button>+ <Button variant="tertiary" size="sm" onClick={onAddInJson}>+ {t('mcp.installed.emptyAddInJson')}+ </Button>+ </p>+ </div>+ ) : undefined+ }+ ariaLabel={t('mcp.rows.title')}+ />{playground && (<McpToolPlayground