Address PR #1221 code review feedback
- Fix getCapabilityEntries to iterate fixed key sets so unsupported capabilities render red X (was only showing present/supported ones) - Merge duplicate @mantine/core import in ViewHeader - Move ConnectionState from ServerCard to core/mcp/types.ts - Narrow onConnectionModeChange to "proxy" | "direct" instead of string Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
771a67ee20
commit
cc9be5e930
6 changed files with 44 additions and 17 deletions
|
|
@ -1,7 +1,9 @@
|
||||||
import type { MCPServerConfig } from "@inspector/core/mcp/types.js";
|
import type {
|
||||||
|
ConnectionState,
|
||||||
|
MCPServerConfig,
|
||||||
|
} 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 type { ConnectionState } from "./ServerCard";
|
|
||||||
import { ServerCard } from "./ServerCard";
|
import { ServerCard } from "./ServerCard";
|
||||||
|
|
||||||
const stdioConfig: MCPServerConfig = {
|
const stdioConfig: MCPServerConfig = {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { Badge, Button, Card, Group, Menu, Stack, Text } from "@mantine/core";
|
import { Badge, Button, Card, Group, Menu, Stack, Text } from "@mantine/core";
|
||||||
import type { Implementation } from "@modelcontextprotocol/sdk/types.js";
|
import type { Implementation } from "@modelcontextprotocol/sdk/types.js";
|
||||||
import type {
|
import type {
|
||||||
ConnectionStatus,
|
ConnectionState,
|
||||||
MCPServerConfig,
|
MCPServerConfig,
|
||||||
ServerType,
|
ServerType,
|
||||||
} from "@inspector/core/mcp/types.js";
|
} from "@inspector/core/mcp/types.js";
|
||||||
|
|
@ -11,12 +11,6 @@ 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 ConnectionState {
|
|
||||||
status: ConnectionStatus;
|
|
||||||
retryCount?: number;
|
|
||||||
error?: { message: string; details?: string };
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ServerCardProps {
|
export interface ServerCardProps {
|
||||||
name: string;
|
name: string;
|
||||||
config: MCPServerConfig;
|
config: MCPServerConfig;
|
||||||
|
|
|
||||||
|
|
@ -39,12 +39,30 @@ function formatScopes(scopes: string[]): string {
|
||||||
return scopes.join(", ");
|
return scopes.join(", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SERVER_CAPABILITY_KEYS: CapabilityKey[] = [
|
||||||
|
"tools",
|
||||||
|
"resources",
|
||||||
|
"prompts",
|
||||||
|
"logging",
|
||||||
|
"completions",
|
||||||
|
"tasks",
|
||||||
|
"experimental",
|
||||||
|
];
|
||||||
|
|
||||||
|
const CLIENT_CAPABILITY_KEYS: CapabilityKey[] = [
|
||||||
|
"roots",
|
||||||
|
"sampling",
|
||||||
|
"elicitation",
|
||||||
|
"experimental",
|
||||||
|
];
|
||||||
|
|
||||||
function getCapabilityEntries(
|
function getCapabilityEntries(
|
||||||
capabilities: Record<string, unknown>,
|
capabilities: Record<string, unknown>,
|
||||||
|
knownKeys: CapabilityKey[],
|
||||||
): { capability: CapabilityKey; supported: boolean }[] {
|
): { capability: CapabilityKey; supported: boolean }[] {
|
||||||
return Object.entries(capabilities).map(([key, value]) => ({
|
return knownKeys.map((key) => ({
|
||||||
capability: key as CapabilityKey,
|
capability: key,
|
||||||
supported: value != null,
|
supported: key in capabilities && capabilities[key] != null,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -57,8 +75,11 @@ export function ServerInfoContent({
|
||||||
const { serverInfo, protocolVersion, capabilities, instructions } =
|
const { serverInfo, protocolVersion, capabilities, instructions } =
|
||||||
initializeResult;
|
initializeResult;
|
||||||
|
|
||||||
const serverCaps = getCapabilityEntries(capabilities);
|
const serverCaps = getCapabilityEntries(capabilities, SERVER_CAPABILITY_KEYS);
|
||||||
const clientCaps = getCapabilityEntries(clientCapabilities);
|
const clientCaps = getCapabilityEntries(
|
||||||
|
clientCapabilities,
|
||||||
|
CLIENT_CAPABILITY_KEYS,
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack gap="md">
|
<Stack gap="md">
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ export interface ServerSettingsFormProps {
|
||||||
settings: InspectorServerSettings;
|
settings: InspectorServerSettings;
|
||||||
expandedSections: ServerSettingsSection[];
|
expandedSections: ServerSettingsSection[];
|
||||||
onExpandedSectionsChange: (sections: ServerSettingsSection[]) => void;
|
onExpandedSectionsChange: (sections: ServerSettingsSection[]) => void;
|
||||||
onConnectionModeChange: (mode: string) => void;
|
onConnectionModeChange: (mode: "proxy" | "direct") => void;
|
||||||
onAddHeader: () => void;
|
onAddHeader: () => void;
|
||||||
onRemoveHeader: (index: number) => void;
|
onRemoveHeader: (index: number) => void;
|
||||||
onHeaderChange: (index: number, key: string, value: string) => void;
|
onHeaderChange: (index: number, key: string, value: string) => void;
|
||||||
|
|
@ -129,7 +129,7 @@ export function ServerSettingsForm({
|
||||||
data={CONNECTION_MODE_OPTIONS}
|
data={CONNECTION_MODE_OPTIONS}
|
||||||
value={settings.connectionMode}
|
value={settings.connectionMode}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
if (value) onConnectionModeChange(value);
|
if (value) onConnectionModeChange(value as "proxy" | "direct");
|
||||||
}}
|
}}
|
||||||
description={
|
description={
|
||||||
settings.connectionMode === "proxy"
|
settings.connectionMode === "proxy"
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ import {
|
||||||
SegmentedControl,
|
SegmentedControl,
|
||||||
Text,
|
Text,
|
||||||
Title,
|
Title,
|
||||||
|
useComputedColorScheme,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useComputedColorScheme } from "@mantine/core";
|
|
||||||
import type { Implementation } from "@modelcontextprotocol/sdk/types.js";
|
import type { Implementation } from "@modelcontextprotocol/sdk/types.js";
|
||||||
import { MdLightMode, MdDarkMode } from "react-icons/md";
|
import { MdLightMode, MdDarkMode } from "react-icons/md";
|
||||||
import type { ConnectionStatus } from "@inspector/core/mcp/types.js";
|
import type { ConnectionStatus } from "@inspector/core/mcp/types.js";
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,16 @@ export type ConnectionStatus =
|
||||||
| "connected"
|
| "connected"
|
||||||
| "error";
|
| "error";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Snapshot of a server's connection state, used by dumb components
|
||||||
|
* that display status, retry count, and error details.
|
||||||
|
*/
|
||||||
|
export interface ConnectionState {
|
||||||
|
status: ConnectionStatus;
|
||||||
|
retryCount?: number;
|
||||||
|
error?: { message: string; details?: string };
|
||||||
|
}
|
||||||
|
|
||||||
export interface StderrLogEntry {
|
export interface StderrLogEntry {
|
||||||
timestamp: Date;
|
timestamp: Date;
|
||||||
message: string;
|
message: string;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue