diff --git a/clients/web/src/components/groups/HistoryControls/HistoryControls.stories.tsx b/clients/web/src/components/groups/HistoryControls/HistoryControls.stories.tsx index ed24eabc..938e31d5 100644 --- a/clients/web/src/components/groups/HistoryControls/HistoryControls.stories.tsx +++ b/clients/web/src/components/groups/HistoryControls/HistoryControls.stories.tsx @@ -1,8 +1,9 @@ import type { Meta, StoryObj } from "@storybook/react-vite"; import { fn } from "storybook/test"; +import type { MessageMethod } from "@inspector/core/mcp/types.js"; import { HistoryControls } from "./HistoryControls"; -const SAMPLE_METHODS = [ +const SAMPLE_METHODS: MessageMethod[] = [ "tools/call", "tools/list", "resources/read", @@ -11,14 +12,14 @@ const SAMPLE_METHODS = [ "prompts/list", "sampling/createMessage", "elicitation/create", -] as const; +]; const meta: Meta = { title: "Groups/HistoryControls", component: HistoryControls, args: { searchText: "", - availableMethods: [...SAMPLE_METHODS], + availableMethods: SAMPLE_METHODS, onSearchChange: fn(), onMethodFilterChange: fn(), }, diff --git a/clients/web/src/components/groups/HistoryControls/HistoryControls.tsx b/clients/web/src/components/groups/HistoryControls/HistoryControls.tsx index 1fc6add8..32ba944d 100644 --- a/clients/web/src/components/groups/HistoryControls/HistoryControls.tsx +++ b/clients/web/src/components/groups/HistoryControls/HistoryControls.tsx @@ -1,12 +1,12 @@ import { Select, Stack, TextInput, Title } from "@mantine/core"; -import type { RequestMethod } from "@inspector/core/mcp/types.js"; +import type { MessageMethod } from "@inspector/core/mcp/types.js"; export interface HistoryControlsProps { searchText: string; - methodFilter?: RequestMethod; - availableMethods: RequestMethod[]; + methodFilter?: MessageMethod; + availableMethods: MessageMethod[]; onSearchChange: (text: string) => void; - onMethodFilterChange: (method: RequestMethod | undefined) => void; + onMethodFilterChange: (method: MessageMethod | undefined) => void; } export function HistoryControls({ @@ -31,7 +31,7 @@ export function HistoryControls({ data={availableMethods} value={methodFilter ?? null} onChange={(value) => - onMethodFilterChange((value as RequestMethod | null) ?? undefined) + onMethodFilterChange((value as MessageMethod | null) ?? undefined) } clearable /> diff --git a/clients/web/src/components/groups/HistoryListPanel/HistoryListPanel.tsx b/clients/web/src/components/groups/HistoryListPanel/HistoryListPanel.tsx index 6e15d725..0bd6a6f7 100644 --- a/clients/web/src/components/groups/HistoryListPanel/HistoryListPanel.tsx +++ b/clients/web/src/components/groups/HistoryListPanel/HistoryListPanel.tsx @@ -8,10 +8,7 @@ import { Text, Title, } from "@mantine/core"; -import type { - MessageEntry, - RequestMethod, -} from "../../../../../../core/mcp/types.js"; +import type { MessageEntry, MessageMethod } from "@inspector/core/mcp/types.js"; import { HistoryEntry } from "../HistoryEntry/HistoryEntry"; import { ListToggle } from "../../elements/ListToggle/ListToggle"; import { extractMethod } from "../historyUtils.js"; @@ -20,7 +17,7 @@ export interface HistoryListPanelProps { entries: MessageEntry[]; pinnedIds: Set; searchText: string; - methodFilter?: RequestMethod; + methodFilter?: MessageMethod; onClearAll: () => void; onExport: () => void; onReplay: (id: string) => void; @@ -56,7 +53,7 @@ function formatHistoryTitle(count: number): string { function matchesFilters( entry: MessageEntry, searchText: string, - methodFilter?: RequestMethod, + methodFilter?: MessageMethod, ): boolean { const method = extractMethod(entry); if (methodFilter && method !== methodFilter) return false; diff --git a/clients/web/src/components/groups/historyUtils.ts b/clients/web/src/components/groups/historyUtils.ts index 820d05fa..f6258b10 100644 --- a/clients/web/src/components/groups/historyUtils.ts +++ b/clients/web/src/components/groups/historyUtils.ts @@ -1,11 +1,10 @@ -import type { - MessageEntry, - RequestMethod, -} from "../../../../../core/mcp/types.js"; +import type { MessageEntry, MessageMethod } from "@inspector/core/mcp/types.js"; -export function extractMethod(entry: MessageEntry): RequestMethod { +export function extractMethod(entry: MessageEntry): MessageMethod { if ("method" in entry.message) { - return entry.message.method as RequestMethod; + // Cast: SDK types message.method as `string`, but every entry in this + // app's MessageEntry log originates from MCP SDK schemas. + return entry.message.method as MessageMethod; } return "response"; } diff --git a/clients/web/src/components/screens/HistoryScreen/HistoryScreen.tsx b/clients/web/src/components/screens/HistoryScreen/HistoryScreen.tsx index 052673f2..1e1a499e 100644 --- a/clients/web/src/components/screens/HistoryScreen/HistoryScreen.tsx +++ b/clients/web/src/components/screens/HistoryScreen/HistoryScreen.tsx @@ -1,9 +1,6 @@ import { useMemo, useState } from "react"; import { Card, Flex, Stack } from "@mantine/core"; -import type { - MessageEntry, - RequestMethod, -} from "../../../../../../core/mcp/types.js"; +import type { MessageEntry, MessageMethod } from "@inspector/core/mcp/types.js"; import { HistoryControls } from "../../groups/HistoryControls/HistoryControls"; import { HistoryListPanel } from "../../groups/HistoryListPanel/HistoryListPanel.js"; import { extractMethod } from "../../groups/historyUtils.js"; @@ -43,7 +40,7 @@ export function HistoryScreen({ onTogglePin, }: HistoryScreenProps) { const [searchText, setSearchText] = useState(""); - const [methodFilter, setMethodFilter] = useState(); + const [methodFilter, setMethodFilter] = useState(); const availableMethods = useMemo( () => Array.from(new Set(entries.map(extractMethod))).sort(), diff --git a/core/mcp/types.ts b/core/mcp/types.ts index ed6e005b..8f0f1c6c 100644 --- a/core/mcp/types.ts +++ b/core/mcp/types.ts @@ -103,7 +103,7 @@ export interface MessageEntry { } /** Method name for any MessageEntry traffic, plus synthetic "response" for result/error entries. */ -export type RequestMethod = +export type MessageMethod = | ClientRequest["method"] | ClientNotification["method"] | ServerRequest["method"] diff --git a/specification/v2_ux_interfaces.md b/specification/v2_ux_interfaces.md index 354b08db..0c906d28 100644 --- a/specification/v2_ux_interfaces.md +++ b/specification/v2_ux_interfaces.md @@ -356,7 +356,7 @@ will close out as part of that work. - **Purpose**: Search + method filter sidebar for the history screen. - **Current props**: `searchText`, `methodFilter`, `onSearchChange`, `onMethodFilterChange`. - **MCP schema touch points**: Method filter values are MCP `Request.method` literals. -- **Target props**: `searchText`, `methodFilter?: RequestMethod`, `availableMethods: RequestMethod[]`, `onSearchChange`, `onMethodFilterChange`. +- **Target props**: `searchText`, `methodFilter?: MessageMethod`, `availableMethods: MessageMethod[]`, `onSearchChange`, `onMethodFilterChange`. - **Callbacks → core hook**: `useMessageLog`. - **Internal refactors**: Type the method filter as a union of MCP method strings.