Phase 5: Lift ServerEntry into core/mcp/types.ts
ServerEntry was previously defined as `Pick<ServerCardProps, ...>` in ServerListScreen, inverting the natural dependency direction (data shape derived from a UI prop type). Phase 5's cleanup pass calls this out specifically. Move the canonical ServerEntry into core/mcp/types.ts and have ServerCardProps extend it. ServerListScreen, InspectorView, and their stories now import ServerEntry from core directly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
56abced72b
commit
c5d02456e0
6 changed files with 23 additions and 22 deletions
|
|
@ -1,8 +1,7 @@
|
||||||
import { Badge, Button, Card, Group, 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 {
|
import type {
|
||||||
ConnectionState,
|
|
||||||
MCPServerConfig,
|
MCPServerConfig,
|
||||||
|
ServerEntry,
|
||||||
ServerType,
|
ServerType,
|
||||||
} from "@inspector/core/mcp/types.js";
|
} from "@inspector/core/mcp/types.js";
|
||||||
import { ServerStatusIndicator } from "../../elements/ServerStatusIndicator/ServerStatusIndicator";
|
import { ServerStatusIndicator } from "../../elements/ServerStatusIndicator/ServerStatusIndicator";
|
||||||
|
|
@ -11,14 +10,7 @@ import { ConnectionToggle } from "../../elements/ConnectionToggle/ConnectionTogg
|
||||||
import { ContentViewer } from "../../elements/ContentViewer/ContentViewer";
|
import { ContentViewer } from "../../elements/ContentViewer/ContentViewer";
|
||||||
import { InlineError } from "../../elements/InlineError/InlineError";
|
import { InlineError } from "../../elements/InlineError/InlineError";
|
||||||
|
|
||||||
export interface ServerCardProps {
|
export interface ServerCardProps extends ServerEntry {
|
||||||
/** 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;
|
|
||||||
activeServer?: string;
|
activeServer?: string;
|
||||||
onToggleConnection: (id: string) => void;
|
onToggleConnection: (id: string) => void;
|
||||||
onServerInfo: (id: string) => void;
|
onServerInfo: (id: string) => void;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
import type { Meta, StoryObj } from "@storybook/react-vite";
|
||||||
import { fn } from "storybook/test";
|
import { fn } from "storybook/test";
|
||||||
import { ServerListScreen, type ServerEntry } from "./ServerListScreen";
|
import type { ServerEntry } from "@inspector/core/mcp/types.js";
|
||||||
|
import { ServerListScreen } from "./ServerListScreen";
|
||||||
|
|
||||||
const meta: Meta<typeof ServerListScreen> = {
|
const meta: Meta<typeof ServerListScreen> = {
|
||||||
title: "Screens/ServerListScreen",
|
title: "Screens/ServerListScreen",
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,8 @@
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { ScrollArea, SimpleGrid, Stack, Text } from "@mantine/core";
|
import { ScrollArea, SimpleGrid, Stack, Text } from "@mantine/core";
|
||||||
|
import type { ServerEntry } from "@inspector/core/mcp/types.js";
|
||||||
import { ServerCard } from "../../groups/ServerCard/ServerCard";
|
import { ServerCard } from "../../groups/ServerCard/ServerCard";
|
||||||
import { ServerListControls } from "../../groups/ServerListControls/ServerListControls";
|
import { ServerListControls } from "../../groups/ServerListControls/ServerListControls";
|
||||||
import type { ServerCardProps } from "../../groups/ServerCard/ServerCard";
|
|
||||||
|
|
||||||
export type ServerEntry = Pick<
|
|
||||||
ServerCardProps,
|
|
||||||
"id" | "name" | "config" | "info" | "connection"
|
|
||||||
>;
|
|
||||||
|
|
||||||
export interface ServerListScreenProps {
|
export interface ServerListScreenProps {
|
||||||
servers: ServerEntry[];
|
servers: ServerEntry[];
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,11 @@ import type {
|
||||||
import type {
|
import type {
|
||||||
InspectorResourceSubscription,
|
InspectorResourceSubscription,
|
||||||
MessageEntry,
|
MessageEntry,
|
||||||
|
ServerEntry,
|
||||||
} from "@inspector/core/mcp/types.js";
|
} from "@inspector/core/mcp/types.js";
|
||||||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
import type { Meta, StoryObj } from "@storybook/react-vite";
|
||||||
import { fn } from "storybook/test";
|
import { fn } from "storybook/test";
|
||||||
import { InspectorView } from "./InspectorView";
|
import { InspectorView } from "./InspectorView";
|
||||||
import type { ServerEntry } from "../../screens/ServerListScreen/ServerListScreen";
|
|
||||||
import { mixedEntries as demoLogs } from "../../screens/LoggingScreen/LoggingScreen.fixtures";
|
import { mixedEntries as demoLogs } from "../../screens/LoggingScreen/LoggingScreen.fixtures";
|
||||||
import { longToolList as demoTools } from "../../screens/ToolsScreen/ToolsScreen.fixtures";
|
import { longToolList as demoTools } from "../../screens/ToolsScreen/ToolsScreen.fixtures";
|
||||||
import type { TaskProgress } from "../../groups/TaskCard/TaskCard";
|
import type { TaskProgress } from "../../groups/TaskCard/TaskCard";
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,10 @@ import type {
|
||||||
ConnectionStatus,
|
ConnectionStatus,
|
||||||
InspectorResourceSubscription,
|
InspectorResourceSubscription,
|
||||||
MessageEntry,
|
MessageEntry,
|
||||||
|
ServerEntry,
|
||||||
} from "@inspector/core/mcp/types.js";
|
} from "@inspector/core/mcp/types.js";
|
||||||
import { ViewHeader } from "../../groups/ViewHeader/ViewHeader";
|
import { ViewHeader } from "../../groups/ViewHeader/ViewHeader";
|
||||||
import {
|
import { ServerListScreen } from "../../screens/ServerListScreen/ServerListScreen";
|
||||||
ServerListScreen,
|
|
||||||
type ServerEntry,
|
|
||||||
} from "../../screens/ServerListScreen/ServerListScreen";
|
|
||||||
import { ToolsScreen } from "../../screens/ToolsScreen/ToolsScreen";
|
import { ToolsScreen } from "../../screens/ToolsScreen/ToolsScreen";
|
||||||
import { PromptsScreen } from "../../screens/PromptsScreen/PromptsScreen";
|
import { PromptsScreen } from "../../screens/PromptsScreen/PromptsScreen";
|
||||||
import { ResourcesScreen } from "../../screens/ResourcesScreen/ResourcesScreen";
|
import { ResourcesScreen } from "../../screens/ResourcesScreen/ResourcesScreen";
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,21 @@ export interface ConnectionState {
|
||||||
error?: { message: string; details?: string };
|
error?: { message: string; details?: string };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One server entry as seen by the UI: identity, transport config, optional
|
||||||
|
* `Implementation` info reported during `initialize`, and the current
|
||||||
|
* connection snapshot. Cards/screens spread this onto presentational props.
|
||||||
|
*/
|
||||||
|
export interface ServerEntry {
|
||||||
|
/** 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;
|
||||||
|
}
|
||||||
|
|
||||||
export interface StderrLogEntry {
|
export interface StderrLogEntry {
|
||||||
timestamp: Date;
|
timestamp: Date;
|
||||||
message: string;
|
message: string;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue