Address PR #1220 code review feedback
- Remove unused clientExperimental prop from ExperimentalFeaturesPanel - Restore readable display of server capabilities by extracting description and methods fields when present instead of raw JSON - Extract RootDraft type alias to avoid repeated inline type Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e6de97dc20
commit
31b8db98ab
3 changed files with 46 additions and 18 deletions
|
|
@ -23,7 +23,6 @@ const meta: Meta<typeof ExperimentalFeaturesPanel> = {
|
||||||
onHeaderChange: fn(),
|
onHeaderChange: fn(),
|
||||||
onCopyResponse: fn(),
|
onCopyResponse: fn(),
|
||||||
onTestCapability: fn(),
|
onTestCapability: fn(),
|
||||||
clientExperimental: {},
|
|
||||||
clientToggles: defaultClientToggles,
|
clientToggles: defaultClientToggles,
|
||||||
customHeaders: [],
|
customHeaders: [],
|
||||||
requestHistory: [],
|
requestHistory: [],
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ import {
|
||||||
Title,
|
Title,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import type {
|
import type {
|
||||||
ClientCapabilities,
|
|
||||||
JSONRPCErrorResponse,
|
JSONRPCErrorResponse,
|
||||||
JSONRPCResponse,
|
JSONRPCResponse,
|
||||||
ServerCapabilities,
|
ServerCapabilities,
|
||||||
|
|
@ -40,7 +39,6 @@ export interface RequestHistoryItem {
|
||||||
|
|
||||||
export interface ExperimentalFeaturesPanelProps {
|
export interface ExperimentalFeaturesPanelProps {
|
||||||
serverExperimental: ServerCapabilities["experimental"];
|
serverExperimental: ServerCapabilities["experimental"];
|
||||||
clientExperimental: ClientCapabilities["experimental"];
|
|
||||||
clientToggles: ClientExperimentalToggle[];
|
clientToggles: ClientExperimentalToggle[];
|
||||||
requestDraft: string;
|
requestDraft: string;
|
||||||
response?: JSONRPCResponse | JSONRPCErrorResponse;
|
response?: JSONRPCResponse | JSONRPCErrorResponse;
|
||||||
|
|
@ -108,6 +106,28 @@ function getCapabilityEntries(
|
||||||
return Object.entries(experimental);
|
return Object.entries(experimental);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCapabilityDescription(value: object): string | undefined {
|
||||||
|
if ("description" in value && typeof value.description === "string") {
|
||||||
|
return value.description;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCapabilityMethods(value: object): string[] | undefined {
|
||||||
|
if (
|
||||||
|
"methods" in value &&
|
||||||
|
Array.isArray(value.methods) &&
|
||||||
|
value.methods.every((m: unknown) => typeof m === "string")
|
||||||
|
) {
|
||||||
|
return value.methods as string[];
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatMethods(methods: string[]): string {
|
||||||
|
return `Methods: ${methods.join(", ")}`;
|
||||||
|
}
|
||||||
|
|
||||||
export function ExperimentalFeaturesPanel({
|
export function ExperimentalFeaturesPanel({
|
||||||
serverExperimental,
|
serverExperimental,
|
||||||
clientToggles,
|
clientToggles,
|
||||||
|
|
@ -137,19 +157,26 @@ export function ExperimentalFeaturesPanel({
|
||||||
{serverEntries.length === 0 ? (
|
{serverEntries.length === 0 ? (
|
||||||
<Text c="dimmed">No experimental capabilities</Text>
|
<Text c="dimmed">No experimental capabilities</Text>
|
||||||
) : (
|
) : (
|
||||||
serverEntries.map(([name, value]) => (
|
serverEntries.map(([name, value]) => {
|
||||||
<CapCard key={name}>
|
const description = getCapabilityDescription(value);
|
||||||
<Stack gap="xs">
|
const methods = getCapabilityMethods(value);
|
||||||
<Text fw={600}>{name}</Text>
|
return (
|
||||||
<MetaText>{JSON.stringify(value)}</MetaText>
|
<CapCard key={name}>
|
||||||
<Group>
|
<Stack gap="xs">
|
||||||
<CompactButton onClick={() => onTestCapability(name)}>
|
<Text fw={600}>{name}</Text>
|
||||||
Test →
|
{description && <HintText>{description}</HintText>}
|
||||||
</CompactButton>
|
{methods && methods.length > 0 && (
|
||||||
</Group>
|
<MetaText>{formatMethods(methods)}</MetaText>
|
||||||
</Stack>
|
)}
|
||||||
</CapCard>
|
<Group>
|
||||||
))
|
<CompactButton onClick={() => onTestCapability(name)}>
|
||||||
|
Test →
|
||||||
|
</CompactButton>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
</CapCard>
|
||||||
|
);
|
||||||
|
})
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Divider />
|
<Divider />
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,13 @@ import {
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import type { Root } from "@modelcontextprotocol/sdk/types.js";
|
import type { Root } from "@modelcontextprotocol/sdk/types.js";
|
||||||
|
|
||||||
|
export type RootDraft = { name: string; uri: string };
|
||||||
|
|
||||||
export interface RootsTableProps {
|
export interface RootsTableProps {
|
||||||
roots: Root[];
|
roots: Root[];
|
||||||
newRootDraft: { name: string; uri: string };
|
newRootDraft: RootDraft;
|
||||||
onRemoveRoot: (uri: string) => void;
|
onRemoveRoot: (uri: string) => void;
|
||||||
onNewRootDraftChange: (draft: { name: string; uri: string }) => void;
|
onNewRootDraftChange: (draft: RootDraft) => void;
|
||||||
onAddRoot: () => void;
|
onAddRoot: () => void;
|
||||||
onBrowse: () => void;
|
onBrowse: () => void;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue