Refactor ServerCard stack to use id-based callbacks

Distinguishes server `id` (the unique map key in MCPConfig.mcpServers)
from `name` (display label) so containers can dispatch by id without
relying on display strings. ServerCard, ConnectionToggle, ServerListScreen,
and supporting stories all updated.

- ServerCard: add `id` prop; all action callbacks now `(id: string) => void`
- ConnectionToggle: collapse `onConnect`/`onDisconnect` into single `onToggle`
- ServerListScreen: lift `activeServer` to a prop; combine `onSetActive` +
  `onToggleConnection` into a single `onToggleConnection(id)` callback
- Stories: use UUIDs for server ids so callbacks visibly carry ids, not names

Removes the "Direct"/"Via Proxy" connection mode concept, which is no
longer planned. ServerSettingsForm drops the section, ServerCard drops
the badge, InspectorServerSettings drops the field.

Removes the "Test Client Features" dropdown from ServerCard along with
its four handlers; that surface will live elsewhere.

TransportBadge now collapses `sse` and `streamable-http` into a single
"HTTP" label; ServerCard adds a grey transport descriptor next to the
badge ("Standard I/O", "SSE (Server Sent Events) [deprecated]",
"Streamable HTTP"). The version badge moves from the header row to sit
beside the transport badge.

ServerCard header no longer wraps; long server names truncate with
ellipsis.

Specification docs (`v2_scope.md`, `v2_screenshots.md`,
`v2_ux_interfaces.md`, `v2_ux_storybook.md`) updated to match.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
cliffhall 2026-04-25 18:33:38 -04:00
commit 1149288ea6
2 changed files with 196 additions and 326 deletions

View file

@ -33,16 +33,11 @@ const meta: Meta<typeof ServerCard> = {
component: ServerCard,
args: {
onToggleConnection: fn(),
onSetActiveServer: fn(),
onServerInfo: fn(),
onSettings: fn(),
onEdit: fn(),
onClone: fn(),
onRemove: fn(),
onTestSampling: fn(),
onTestElicitationForm: fn(),
onTestElicitationUrl: fn(),
onConfigureRoots: fn(),
},
};
@ -51,61 +46,47 @@ type Story = StoryObj<typeof ServerCard>;
export const Connected: Story = {
args: {
id: "7f3b2a8e-1c4d-4e5f-9a0b-3c2d1e4f5a6b",
name: "My MCP Server",
config: stdioConfig,
info: { name: "My MCP Server", version: "1.2.0" },
connection: connected,
connectionMode: "Subprocess",
canTestClientFeatures: false,
},
};
export const Disconnected: Story = {
args: {
id: "7f3b2a8e-1c4d-4e5f-9a0b-3c2d1e4f5a6b",
name: "My MCP Server",
config: stdioConfig,
info: { name: "My MCP Server", version: "1.2.0" },
connection: disconnected,
connectionMode: "Subprocess",
canTestClientFeatures: false,
},
};
export const Connecting: Story = {
args: {
id: "7f3b2a8e-1c4d-4e5f-9a0b-3c2d1e4f5a6b",
name: "My MCP Server",
config: stdioConfig,
info: { name: "My MCP Server", version: "1.2.0" },
connection: connecting,
connectionMode: "Subprocess",
canTestClientFeatures: false,
},
};
export const Failed: Story = {
args: {
id: "7f3b2a8e-1c4d-4e5f-9a0b-3c2d1e4f5a6b",
name: "My MCP Server",
config: stdioConfig,
info: { name: "My MCP Server", version: "1.2.0" },
connection: failed,
connectionMode: "Subprocess",
canTestClientFeatures: false,
},
};
export const WithClientFeatures: Story = {
args: {
name: "My MCP Server",
config: stdioConfig,
info: { name: "My MCP Server", version: "1.2.0" },
connection: connected,
connectionMode: "Subprocess",
canTestClientFeatures: true,
},
};
export const LongServerName: Story = {
args: {
id: "a1b2c3d4-e5f6-4789-9abc-def012345678",
name: "my-organization-super-long-experimental-mcp-server-with-many-features-v2",
config: {
command:
@ -116,42 +97,37 @@ export const LongServerName: Story = {
version: "1.0.0-beta.42",
},
connection: connected,
connectionMode: "Subprocess",
canTestClientFeatures: true,
},
};
export const HttpDirect: Story = {
args: {
id: "9e8d7c6b-5a4f-4321-bdc6-fedcba098765",
name: "Remote API Server",
config: httpConfig,
info: { name: "Remote API Server", version: "2.0.0" },
connection: connected,
connectionMode: "Direct",
canTestClientFeatures: false,
},
};
export const CompactConnected: Story = {
args: {
id: "7f3b2a8e-1c4d-4e5f-9a0b-3c2d1e4f5a6b",
name: "My MCP Server",
config: stdioConfig,
info: { name: "My MCP Server", version: "1.2.0" },
connection: connected,
connectionMode: "Subprocess",
canTestClientFeatures: false,
compact: true,
},
};
export const CompactDisconnected: Story = {
args: {
id: "7f3b2a8e-1c4d-4e5f-9a0b-3c2d1e4f5a6b",
name: "My MCP Server",
config: stdioConfig,
info: { name: "My MCP Server", version: "1.2.0" },
connection: disconnected,
connectionMode: "Subprocess",
canTestClientFeatures: false,
compact: true,
},
};

View file

@ -1,4 +1,4 @@
import { Badge, Button, Card, Group, Menu, Stack, Text } from "@mantine/core";
import { Badge, Button, Card, Group, Stack, Text } from "@mantine/core";
import type { Implementation } from "@modelcontextprotocol/sdk/types.js";
import type {
ConnectionState,
@ -12,33 +12,33 @@ import { ContentViewer } from "../../elements/ContentViewer/ContentViewer";
import { InlineError } from "../../elements/InlineError/InlineError";
export interface ServerCardProps {
/** Stable unique identifier — the MCPConfig.mcpServers map key. */
id: string;
/** Display label shown in the card header. May or may not equal id. */
name: string;
config: MCPServerConfig;
info?: Implementation;
connection: ConnectionState;
connectionMode: string;
canTestClientFeatures: boolean;
activeServer?: string;
onSetActiveServer?: (name: string | undefined) => void;
onToggleConnection: (connect: boolean) => void;
onServerInfo: () => void;
onSettings: () => void;
onEdit: () => void;
onClone: () => void;
onRemove: () => void;
onTestSampling?: () => void;
onTestElicitationForm?: () => void;
onTestElicitationUrl?: () => void;
onConfigureRoots?: () => void;
onToggleConnection: (id: string) => void;
onServerInfo: (id: string) => void;
onSettings: (id: string) => void;
onEdit: (id: string) => void;
onClone: (id: string) => void;
onRemove: (id: string) => void;
compact?: boolean;
}
const HeaderLeft = Group.withProps({
gap: "sm",
wrap: "nowrap",
miw: 0,
flex: 1,
});
const HeaderRight = Group.withProps({
gap: "sm",
wrap: "nowrap",
});
const ActionsRow = Group.withProps({
@ -48,6 +48,9 @@ const ActionsRow = Group.withProps({
const ServerName = Text.withProps({
fw: 600,
size: "lg",
truncate: "end",
miw: 0,
flex: 1,
});
const ModeText = Text.withProps({
@ -70,6 +73,12 @@ function getTransport(config: MCPServerConfig): ServerType {
return config.type ?? "stdio";
}
const TRANSPORT_DESCRIPTION: Record<ServerType, string> = {
stdio: "Standard I/O",
sse: "SSE (Server Sent Events) [deprecated]",
"streamable-http": "Streamable HTTP",
};
function getCommandOrUrl(config: MCPServerConfig): string {
if (config.type === "sse" || config.type === "streamable-http") {
return config.url;
@ -78,27 +87,21 @@ function getCommandOrUrl(config: MCPServerConfig): string {
}
export function ServerCard({
id,
name,
config,
info,
connection,
connectionMode,
canTestClientFeatures,
activeServer,
onSetActiveServer,
onToggleConnection,
onServerInfo,
onSettings,
onEdit,
onClone,
onRemove,
onTestSampling,
onTestElicitationForm,
onTestElicitationUrl,
onConfigureRoots,
compact = false,
}: ServerCardProps) {
const isDimmed = activeServer !== undefined && activeServer !== name;
const isDimmed = activeServer !== undefined && activeServer !== id;
const transport = getTransport(config);
const commandOrUrl = getCommandOrUrl(config);
const version = info?.version;
@ -111,10 +114,9 @@ export function ServerCard({
{...(isDimmed ? { "aria-disabled": true, inert: true } : {})}
>
<Stack gap="sm">
<Group justify="space-between" wrap="wrap">
<Group justify="space-between" wrap="nowrap">
<HeaderLeft>
<ServerName>{name}</ServerName>
{version && <Badge variant="outline">{version}</Badge>}
</HeaderLeft>
<HeaderRight>
<ServerStatusIndicator
@ -124,46 +126,17 @@ export function ServerCard({
<ConnectionToggle
status={connection.status}
disabled={isDimmed}
onConnect={() => {
onSetActiveServer?.(name);
onToggleConnection(true);
}}
onDisconnect={() => {
onSetActiveServer?.(undefined);
onToggleConnection(false);
}}
onToggle={() => onToggleConnection(id)}
/>
</HeaderRight>
</Group>
{!compact && (
<>
<Group justify="space-between" mih={30}>
<Group gap="sm">
<TransportBadge transport={transport} />
<ModeText>{connectionMode}</ModeText>
</Group>
{canTestClientFeatures && (
<Menu>
<Menu.Target>
<SubtleButton>Test Client Features &#x25BE;</SubtleButton>
</Menu.Target>
<Menu.Dropdown>
<Menu.Item onClick={onTestSampling}>
Simulate Sampling Request
</Menu.Item>
<Menu.Item onClick={onTestElicitationForm}>
Simulate Elicitation (Form)
</Menu.Item>
<Menu.Item onClick={onTestElicitationUrl}>
Simulate Elicitation (URL)
</Menu.Item>
<Menu.Item onClick={onConfigureRoots}>
Configure Roots
</Menu.Item>
</Menu.Dropdown>
</Menu>
)}
<Group gap="sm" mih={30}>
{version && <Badge variant="outline">{version}</Badge>}
<TransportBadge transport={transport} />
<ModeText>{TRANSPORT_DESCRIPTION[transport]}</ModeText>
</Group>
<ContentViewer
@ -183,13 +156,17 @@ export function ServerCard({
<Group justify="space-between">
<ActionsRow>
<SubtleButton onClick={onClone}>Clone</SubtleButton>
<SubtleButton onClick={onEdit}>Edit</SubtleButton>
<RemoveButton onClick={onRemove}>Remove</RemoveButton>
<SubtleButton onClick={() => onClone(id)}>Clone</SubtleButton>
<SubtleButton onClick={() => onEdit(id)}>Edit</SubtleButton>
<RemoveButton onClick={() => onRemove(id)}>Remove</RemoveButton>
</ActionsRow>
<ActionsRow>
<SubtleButton onClick={onServerInfo}>Server Info</SubtleButton>
<SubtleButton onClick={onSettings}>Settings</SubtleButton>
<SubtleButton onClick={() => onServerInfo(id)}>
Server Info
</SubtleButton>
<SubtleButton onClick={() => onSettings(id)}>
Settings
</SubtleButton>
</ActionsRow>
</Group>
</>