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:
parent
f9a1aa4e3c
commit
2d4fca4fa6
5 changed files with 905 additions and 648 deletions
|
|
@ -1,7 +1,8 @@
|
|||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
||||
import type { LoggingLevel } from "@modelcontextprotocol/sdk/types.js";
|
||||
import { fn } from "storybook/test";
|
||||
import { LoggingScreen } from "./LoggingScreen";
|
||||
import type { LogEntryProps, LogLevel } from "../../elements/LogEntry/LogEntry";
|
||||
import type { LogEntryData } from "../../elements/LogEntry/LogEntry";
|
||||
|
||||
const meta: Meta<typeof LoggingScreen> = {
|
||||
title: "Screens/LoggingScreen",
|
||||
|
|
@ -27,121 +28,125 @@ export const Empty: Story = {
|
|||
},
|
||||
};
|
||||
|
||||
const logMessages: { level: LogLevel; message: string; logger?: string }[] = [
|
||||
{ level: "info", message: "Server started on port 3000" },
|
||||
const logMessages: {
|
||||
level: LoggingLevel;
|
||||
data: string;
|
||||
logger?: string;
|
||||
}[] = [
|
||||
{ level: "info", data: "Server started on port 3000" },
|
||||
{
|
||||
level: "debug",
|
||||
message: "Loading configuration from /etc/mcp/config.json",
|
||||
data: "Loading configuration from /etc/mcp/config.json",
|
||||
logger: "config",
|
||||
},
|
||||
{
|
||||
level: "warning",
|
||||
message: "Deprecated API endpoint called: /v1/tools",
|
||||
data: "Deprecated API endpoint called: /v1/tools",
|
||||
logger: "http",
|
||||
},
|
||||
{ level: "info", message: "Client connected: inspector-web-ui" },
|
||||
{ level: "info", data: "Client connected: inspector-web-ui" },
|
||||
{
|
||||
level: "error",
|
||||
message: "Failed to read resource: file not found at /data/missing.txt",
|
||||
data: "Failed to read resource: file not found at /data/missing.txt",
|
||||
logger: "resources",
|
||||
},
|
||||
{
|
||||
level: "info",
|
||||
message: "Tool execution completed: search_files (245ms)",
|
||||
data: "Tool execution completed: search_files (245ms)",
|
||||
logger: "tools",
|
||||
},
|
||||
{
|
||||
level: "debug",
|
||||
message: "Parsing JSON-RPC request body",
|
||||
data: "Parsing JSON-RPC request body",
|
||||
logger: "transport",
|
||||
},
|
||||
{
|
||||
level: "info",
|
||||
message: "Listing available tools for client session",
|
||||
data: "Listing available tools for client session",
|
||||
logger: "tools",
|
||||
},
|
||||
{
|
||||
level: "warning",
|
||||
message: "Slow query detected: 1200ms for resource lookup",
|
||||
data: "Slow query detected: 1200ms for resource lookup",
|
||||
logger: "db",
|
||||
},
|
||||
{
|
||||
level: "info",
|
||||
message: "Resource subscription added: file:///config.json",
|
||||
data: "Resource subscription added: file:///config.json",
|
||||
logger: "resources",
|
||||
},
|
||||
{
|
||||
level: "debug",
|
||||
message: "Heartbeat ping received from client",
|
||||
data: "Heartbeat ping received from client",
|
||||
logger: "session",
|
||||
},
|
||||
{
|
||||
level: "error",
|
||||
message: "Permission denied reading /etc/secrets.env",
|
||||
data: "Permission denied reading /etc/secrets.env",
|
||||
logger: "resources",
|
||||
},
|
||||
{
|
||||
level: "info",
|
||||
message: "Prompt 'summarize' resolved with 2 messages",
|
||||
data: "Prompt 'summarize' resolved with 2 messages",
|
||||
logger: "prompts",
|
||||
},
|
||||
{
|
||||
level: "debug",
|
||||
message: "Cache hit for resource: db://users/42",
|
||||
data: "Cache hit for resource: db://users/42",
|
||||
logger: "cache",
|
||||
},
|
||||
{
|
||||
level: "info",
|
||||
message: "Tool 'create_record' executed successfully in 89ms",
|
||||
data: "Tool 'create_record' executed successfully in 89ms",
|
||||
logger: "tools",
|
||||
},
|
||||
{
|
||||
level: "warning",
|
||||
message: "Client reconnection attempt #3",
|
||||
data: "Client reconnection attempt #3",
|
||||
logger: "session",
|
||||
},
|
||||
{
|
||||
level: "info",
|
||||
message: "New resource detected: file:///data/output.csv",
|
||||
data: "New resource detected: file:///data/output.csv",
|
||||
logger: "resources",
|
||||
},
|
||||
{
|
||||
level: "debug",
|
||||
message: "Serializing response payload (2.4KB)",
|
||||
data: "Serializing response payload (2.4KB)",
|
||||
logger: "transport",
|
||||
},
|
||||
{
|
||||
level: "error",
|
||||
message: "Timeout waiting for tool response after 30s",
|
||||
data: "Timeout waiting for tool response after 30s",
|
||||
logger: "tools",
|
||||
},
|
||||
{
|
||||
level: "info",
|
||||
message: "Session initialized with capabilities: tools, resources, prompts",
|
||||
data: "Session initialized with capabilities: tools, resources, prompts",
|
||||
},
|
||||
{
|
||||
level: "debug",
|
||||
message: "Validating input schema for tool 'batch_process'",
|
||||
data: "Validating input schema for tool 'batch_process'",
|
||||
logger: "tools",
|
||||
},
|
||||
{
|
||||
level: "info",
|
||||
message: "Resource template resolved: db://tables/users/rows/15",
|
||||
data: "Resource template resolved: db://tables/users/rows/15",
|
||||
logger: "resources",
|
||||
},
|
||||
{
|
||||
level: "warning",
|
||||
message: "Memory usage at 78% — consider increasing limits",
|
||||
data: "Memory usage at 78% — consider increasing limits",
|
||||
logger: "system",
|
||||
},
|
||||
{
|
||||
level: "info",
|
||||
message: "Client disconnected gracefully",
|
||||
data: "Client disconnected gracefully",
|
||||
logger: "session",
|
||||
},
|
||||
{
|
||||
level: "debug",
|
||||
message: "Flushing log buffer to disk (128 entries)",
|
||||
data: "Flushing log buffer to disk (128 entries)",
|
||||
logger: "logging",
|
||||
},
|
||||
];
|
||||
|
|
@ -150,14 +155,11 @@ function pad(n: number): string {
|
|||
return n.toString().padStart(2, "0");
|
||||
}
|
||||
|
||||
const mixedEntries: LogEntryProps[] = Array.from({ length: 50 }, (_, i) => {
|
||||
const mixedEntries: LogEntryData[] = Array.from({ length: 50 }, (_, i) => {
|
||||
const src = logMessages[i % logMessages.length];
|
||||
const seconds = pad(i + 1);
|
||||
return {
|
||||
timestamp: `2026-03-17T10:00:${seconds}Z`,
|
||||
level: src.level,
|
||||
message: src.message,
|
||||
logger: src.logger,
|
||||
receivedAt: new Date(`2026-03-17T10:00:${pad(i + 1)}Z`),
|
||||
params: { level: src.level, data: src.data, logger: src.logger },
|
||||
};
|
||||
});
|
||||
|
||||
|
|
@ -167,53 +169,66 @@ export const WithEntries: Story = {
|
|||
},
|
||||
};
|
||||
|
||||
const allLevelEntries: LogEntryProps[] = [
|
||||
const allLevelEntries: LogEntryData[] = [
|
||||
{
|
||||
timestamp: "2026-03-17T10:00:01Z",
|
||||
level: "debug",
|
||||
message: "Resolving transport handler for stdio connection",
|
||||
logger: "transport",
|
||||
receivedAt: new Date("2026-03-17T10:00:01Z"),
|
||||
params: {
|
||||
level: "debug",
|
||||
data: "Resolving transport handler for stdio connection",
|
||||
logger: "transport",
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamp: "2026-03-17T10:00:02Z",
|
||||
level: "info",
|
||||
message: "MCP session initialized successfully",
|
||||
receivedAt: new Date("2026-03-17T10:00:02Z"),
|
||||
params: { level: "info", data: "MCP session initialized successfully" },
|
||||
},
|
||||
{
|
||||
timestamp: "2026-03-17T10:00:03Z",
|
||||
level: "notice",
|
||||
message: "Server capabilities negotiated: tools, resources, prompts",
|
||||
logger: "session",
|
||||
receivedAt: new Date("2026-03-17T10:00:03Z"),
|
||||
params: {
|
||||
level: "notice",
|
||||
data: "Server capabilities negotiated: tools, resources, prompts",
|
||||
logger: "session",
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamp: "2026-03-17T10:00:04Z",
|
||||
level: "warning",
|
||||
message: "Rate limit approaching: 85% of quota used",
|
||||
logger: "ratelimit",
|
||||
receivedAt: new Date("2026-03-17T10:00:04Z"),
|
||||
params: {
|
||||
level: "warning",
|
||||
data: "Rate limit approaching: 85% of quota used",
|
||||
logger: "ratelimit",
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamp: "2026-03-17T10:00:05Z",
|
||||
level: "error",
|
||||
message: "Tool execution failed: timeout after 30s",
|
||||
logger: "tools",
|
||||
receivedAt: new Date("2026-03-17T10:00:05Z"),
|
||||
params: {
|
||||
level: "error",
|
||||
data: "Tool execution failed: timeout after 30s",
|
||||
logger: "tools",
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamp: "2026-03-17T10:00:06Z",
|
||||
level: "critical",
|
||||
message: "Database connection pool exhausted",
|
||||
logger: "db",
|
||||
receivedAt: new Date("2026-03-17T10:00:06Z"),
|
||||
params: {
|
||||
level: "critical",
|
||||
data: "Database connection pool exhausted",
|
||||
logger: "db",
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamp: "2026-03-17T10:00:07Z",
|
||||
level: "alert",
|
||||
message: "Memory usage exceeds 95% threshold",
|
||||
logger: "system",
|
||||
receivedAt: new Date("2026-03-17T10:00:07Z"),
|
||||
params: {
|
||||
level: "alert",
|
||||
data: "Memory usage exceeds 95% threshold",
|
||||
logger: "system",
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamp: "2026-03-17T10:00:08Z",
|
||||
level: "emergency",
|
||||
message: "System unresponsive - initiating graceful shutdown",
|
||||
logger: "system",
|
||||
receivedAt: new Date("2026-03-17T10:00:08Z"),
|
||||
params: {
|
||||
level: "emergency",
|
||||
data: "System unresponsive - initiating graceful shutdown",
|
||||
logger: "system",
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ import { useState } from "react";
|
|||
import { Card, Flex, Stack } from "@mantine/core";
|
||||
import { LogControls } from "../../groups/LogControls/LogControls";
|
||||
import { LogStreamPanel } from "../../groups/LogStreamPanel/LogStreamPanel";
|
||||
import type { LogEntryProps } from "../../elements/LogEntry/LogEntry";
|
||||
import type { LogEntryData } from "../../elements/LogEntry/LogEntry";
|
||||
|
||||
export interface LoggingScreenProps {
|
||||
entries: LogEntryProps[];
|
||||
entries: LogEntryData[];
|
||||
currentLevel: string;
|
||||
onSetLevel: (level: string) => void;
|
||||
onClear: () => void;
|
||||
|
|
|
|||
|
|
@ -89,12 +89,17 @@ export const WithResult: Story = {
|
|||
messages: [
|
||||
{
|
||||
role: "user",
|
||||
content:
|
||||
'Translate the following text to Spanish: "Hello, how are you?"',
|
||||
content: {
|
||||
type: "text",
|
||||
text: 'Translate the following text to Spanish: "Hello, how are you?"',
|
||||
},
|
||||
},
|
||||
{
|
||||
role: "assistant",
|
||||
content: "Hola, como estas?",
|
||||
content: {
|
||||
type: "text",
|
||||
text: "Hola, como estas?",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -69,10 +69,10 @@ const disconnectedStdioServer: ServerCardProps = {
|
|||
const failedHttpServer: ServerCardProps = {
|
||||
name: "Remote API Server",
|
||||
version: "2.0.0",
|
||||
transport: "http",
|
||||
transport: "streamable-http",
|
||||
connectionMode: "Streamable HTTP",
|
||||
command: "https://api.example.com/mcp",
|
||||
status: "failed",
|
||||
status: "error",
|
||||
retryCount: 3,
|
||||
error: {
|
||||
message: "Connection refused",
|
||||
|
|
@ -84,7 +84,7 @@ const failedHttpServer: ServerCardProps = {
|
|||
|
||||
const connectingHttpServer: ServerCardProps = {
|
||||
name: "Staging Server",
|
||||
transport: "http",
|
||||
transport: "streamable-http",
|
||||
connectionMode: "Streamable HTTP",
|
||||
command: "https://staging.example.com/mcp",
|
||||
status: "connecting",
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ type Story = StoryObj<typeof TasksScreen>;
|
|||
const sampleTasks: TaskCardProps[] = [
|
||||
{
|
||||
taskId: "d0b22eba71fa36229ce5c4dfadeaa7de",
|
||||
status: "running",
|
||||
status: "working",
|
||||
method: "tools/call",
|
||||
target: "batch_process",
|
||||
progress: 65,
|
||||
|
|
@ -32,7 +32,7 @@ const sampleTasks: TaskCardProps[] = [
|
|||
},
|
||||
{
|
||||
taskId: "4100b5e0b0ed9cd0023330342d1bf647",
|
||||
status: "waiting",
|
||||
status: "input_required",
|
||||
method: "resources/read",
|
||||
target: "file:///data/large-dataset.csv",
|
||||
startedAt: "3/29/2026, 8:17:55 PM",
|
||||
|
|
@ -77,7 +77,7 @@ export const Mixed: Story = {
|
|||
export const ActiveOnly: Story = {
|
||||
args: {
|
||||
tasks: sampleTasks.filter(
|
||||
(t) => t.status === "running" || t.status === "waiting",
|
||||
(t) => t.status === "working" || t.status === "input_required",
|
||||
),
|
||||
},
|
||||
};
|
||||
|
|
@ -85,7 +85,7 @@ export const ActiveOnly: Story = {
|
|||
export const CompletedOnly: Story = {
|
||||
args: {
|
||||
tasks: sampleTasks.filter(
|
||||
(t) => t.status !== "running" && t.status !== "waiting",
|
||||
(t) => t.status !== "working" && t.status !== "input_required",
|
||||
),
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue