Phase 1: Refactor all 16 element component interfaces to use MCP SDK types

Replace ad-hoc local type definitions in element components with real
MCP SDK types and Inspector wrapper types from core/mcp/types.ts:

Schema-typed primitives:
- LogLevelBadge: LogLevel → LoggingLevel (SDK)
- TransportBadge: "stdio"|"http" → ServerType (core), add sse/streamable-http
- TaskStatusBadge: local TaskStatus → SDK TaskStatus (working/input_required/...)
- ServerStatusIndicator: inline union → ConnectionStatus (core), "failed"→"error"

MCP wrapper consumers:
- AnnotationBadge: label+variant → facet+value with SDK Role type
- CapabilityItem: name:string → capability:keyof ServerCapabilities|ClientCapabilities
- LogEntry: flat props → entry:{receivedAt:Date, params:LoggingMessageNotification["params"]}
- MessageBubble: flat props → message:SamplingMessage|PromptMessage
- ProgressDisplay: flat props → params:ProgressNotification["params"]

Composite-input elements:
- ContentViewer: type+content+mimeType → block:ContentBlock (SDK discriminated union)
- InlineError: message+details → error:{message,data?}
- ConnectionToggle: checked+loading+onChange → status:ConnectionStatus+onConnect/onDisconnect

Also updates all group/screen/view consumers to keep the build green,
and renames CSS variable --inspector-status-failed → --inspector-status-error.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
cliffhall 2026-04-16 22:25:23 -04:00
commit 2d4fca4fa6

View file

@ -1,4 +1,5 @@
import { Button, Group, Stack, Text, Title } from "@mantine/core";
import type { ContentBlock } from "@modelcontextprotocol/sdk/types.js";
import { ContentViewer } from "../../elements/ContentViewer/ContentViewer";
export interface ResultContentItem {
@ -18,12 +19,17 @@ const ClearButton = Button.withProps({
size: "sm",
});
function resolveTextType(type: string): "text" | "json" {
return type === "text" ? "text" : "json";
}
function resolveMediaType(mimeType?: string): "image" | "audio" {
return mimeType?.startsWith("image") ? "image" : "audio";
function toContentBlock(item: ResultContentItem): ContentBlock | null {
if (item.text !== undefined) {
return { type: "text", text: item.text };
}
if (item.data !== undefined && item.mimeType?.startsWith("image")) {
return { type: "image", data: item.data, mimeType: item.mimeType };
}
if (item.data !== undefined && item.mimeType) {
return { type: "audio", data: item.data, mimeType: item.mimeType };
}
return null;
}
export function ToolResultPanel({ content, onClear }: ToolResultPanelProps) {
@ -38,27 +44,15 @@ export function ToolResultPanel({ content, onClear }: ToolResultPanelProps) {
) : (
<>
{content.map((item, index) => {
if (item.text !== undefined) {
return (
<ContentViewer
key={index}
type={resolveTextType(item.type)}
content={item.text}
copyable
/>
);
}
if (item.data !== undefined) {
return (
<ContentViewer
key={index}
type={resolveMediaType(item.mimeType)}
content={item.data}
mimeType={item.mimeType}
/>
);
}
return null;
const block = toContentBlock(item);
if (!block) return null;
return (
<ContentViewer
key={index}
block={block}
copyable={block.type === "text"}
/>
);
})}
</>
)}