Some checks failed
Run install, format, lint, build, and test on every push / build (push) Has been cancelled
Run install, format, lint, build, and test on every push / publish (push) Has been cancelled
Run install, format, lint, build, and test on every push / publish-github-container-registry (push) Has been cancelled
* MRTR: drive input_required manually to keep pending-request UX (#1704) Follow-up to #1627/#1705. Instead of letting the SDK auto-fulfil the modern (2026-07-28) MRTR retry loop, InspectorClient now drives it itself so the Inspector keeps its pending-request UX, owns the loop, and shows era-accurate semantics. Core (core/mcp/inspectorClient.ts): - Construct the SDK Client with `inputRequired: { autoFulfill: false }` (unconditional; a no-op on legacy, which never returns input_required). - New `requestWithInputRequired()` driver: issues the request with `allowInputRequired` + `withInputRequired(schema)`, and while the result is `input_required`, fulfils each embedded request through the SAME pending sampling/elicitation plumbing, then retries the original call with `inputResponses` + the echoed `requestState` on a fresh id, bounded by MRTR_MAX_ROUNDS. - Route tools/call, prompts/get, and resources/read through the driver. - Embedded roots/list is auto-answered from configured roots (no pending UX); decline/cancel is echoed to the server (not treated as an abort); a tool-call abort mid-round settles the pending request and surfaces ToolCallCancelledError. - Extract shared `enqueuePendingSample`/`enqueuePendingElicitation` helpers used by both the legacy inbound handlers and the driver; add a per-request `origin` ("server-request" | "input-required") to the pending wrappers. Web UI: - New `MrtrOriginNote` element shows an "input_required — your answer returns as a retry" note on a modern MRTR round; legacy panels are unchanged. - Thread `origin` App -> PendingClientRequestModal -> the sampling/elicitation panels (and the inline panels). Test servers: new MRTR presets (multi-round, roots, sampling, loop, edge-case param shaping). Integration tests cover the manual round-trip (asserting the pending UI pauses and the retry carries inputResponses + requestState on a new id), multi-round, roots auto-answer, sampling, decline-echoed, maxRounds bound, abort mid-round, and requestState-only/inputRequests-only param shaping. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5 * Review: clarify sampling-reject and between-rounds abort comments (#1704) Address review nits on PR #1719 (comment-only, no behavior change): - enqueuePendingSample docstring: sampling has no decline/cancel action; the panel either sends a result (resolve) or Rejects (reject → fails the call). The shared "declined/cancelled resolves" wording was accurate only for the elicitation case. - callToolWithRetries abort comment: note the between-rounds case — when the abort lands while an MRTR round awaits an embedded pending request there is no in-flight SDK request, so nothing is sent on the wire; the outcome (ToolCallCancelledError, no failed-call record) is identical. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5 * test-servers: add mrtr-showcase config exercising every MRTR preset (#1704) A single modern-era streamable-HTTP server (port 3111) bundling all six MRTR presets — mrtr_confirm, mrtr_two_step, mrtr_sample, mrtr_roots, mrtr_edge, mrtr_loop — for manual testing of the manual-driving pending-request UX across single-round, multi-round, sampling, roots, param-shaping, and maxRounds paths. Document it in the README alongside modern-mrtr-http.json. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5 --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
141 lines
3.7 KiB
TypeScript
141 lines
3.7 KiB
TypeScript
import { Badge, Button, Group, Paper, Stack, Text } from "@mantine/core";
|
|
import type {
|
|
CreateMessageRequestParams,
|
|
CreateMessageResult,
|
|
} from "@modelcontextprotocol/client";
|
|
import type { PendingRequestOrigin } from "@inspector/core/mcp/types.js";
|
|
import { MrtrOriginNote } from "../../elements/MrtrOriginNote/MrtrOriginNote";
|
|
|
|
export interface InlineSamplingRequestProps {
|
|
request: CreateMessageRequestParams;
|
|
queuePosition: string;
|
|
draftResult?: CreateMessageResult;
|
|
/**
|
|
* How the request reached the Inspector — a legacy server→client request or a
|
|
* modern MRTR `input_required` round. Drives the era-accurate note; defaults
|
|
* to `"server-request"` (legacy, note hidden). (#1704)
|
|
*/
|
|
origin?: PendingRequestOrigin;
|
|
onAutoRespond: () => void;
|
|
onEditAndSend: () => void;
|
|
onReject: () => void;
|
|
onViewDetails: () => void;
|
|
}
|
|
|
|
const RequestContainer = Paper.withProps({
|
|
p: "md",
|
|
withBorder: true,
|
|
});
|
|
|
|
const QueueLabel = Text.withProps({
|
|
size: "xs",
|
|
c: "dimmed",
|
|
});
|
|
|
|
const PreviewText = Text.withProps({
|
|
size: "sm",
|
|
c: "dimmed",
|
|
lineClamp: 2,
|
|
});
|
|
|
|
const DraftPreview = Text.withProps({
|
|
size: "sm",
|
|
lineClamp: 2,
|
|
});
|
|
|
|
const DetailButton = Button.withProps({
|
|
variant: "subtle",
|
|
size: "xs",
|
|
});
|
|
|
|
const ActionsRow = Group.withProps({
|
|
justify: "flex-end",
|
|
gap: "xs",
|
|
});
|
|
|
|
const CompactButton = Button.withProps({
|
|
size: "xs",
|
|
variant: "light",
|
|
});
|
|
|
|
const RejectButton = Button.withProps({
|
|
size: "xs",
|
|
variant: "light",
|
|
color: "red",
|
|
});
|
|
|
|
function extractPreview(request: CreateMessageRequestParams): string {
|
|
const lastMessage = request.messages[request.messages.length - 1];
|
|
if (!lastMessage) return "";
|
|
const content = lastMessage.content;
|
|
if (Array.isArray(content)) {
|
|
const textBlock = content.find((b) => b.type === "text");
|
|
return textBlock && "text" in textBlock ? textBlock.text : "";
|
|
}
|
|
return content.type === "text" ? content.text : `[${content.type}]`;
|
|
}
|
|
|
|
function extractDraftPreview(draft: CreateMessageResult): string {
|
|
switch (draft.content.type) {
|
|
case "text":
|
|
return draft.content.text;
|
|
case "image":
|
|
return "[Image content]";
|
|
case "audio":
|
|
return "[Audio content]";
|
|
}
|
|
}
|
|
|
|
function extractModelHints(
|
|
request: CreateMessageRequestParams,
|
|
): string[] | undefined {
|
|
const hints = request.modelPreferences?.hints;
|
|
if (!hints || hints.length === 0) return undefined;
|
|
return hints.map((h) => h.name).filter(Boolean) as string[];
|
|
}
|
|
|
|
function formatModelHints(hints: string[]): string {
|
|
return `Model hints: ${hints.join(", ")}`;
|
|
}
|
|
|
|
export function InlineSamplingRequest({
|
|
request,
|
|
queuePosition,
|
|
draftResult,
|
|
origin = "server-request",
|
|
onAutoRespond,
|
|
onEditAndSend,
|
|
onReject,
|
|
onViewDetails,
|
|
}: InlineSamplingRequestProps) {
|
|
const modelHints = extractModelHints(request);
|
|
const messagePreview = extractPreview(request);
|
|
const draftPreview = draftResult ? extractDraftPreview(draftResult) : null;
|
|
|
|
return (
|
|
<RequestContainer>
|
|
<Stack gap="sm">
|
|
<Group justify="space-between">
|
|
<Badge color="blue">sampling/createMessage</Badge>
|
|
<QueueLabel>{queuePosition}</QueueLabel>
|
|
</Group>
|
|
|
|
<MrtrOriginNote origin={origin} />
|
|
|
|
{modelHints && <Text size="sm">{formatModelHints(modelHints)}</Text>}
|
|
|
|
<PreviewText>{messagePreview}</PreviewText>
|
|
|
|
<DetailButton onClick={onViewDetails}>View Details</DetailButton>
|
|
|
|
{draftPreview !== null && <DraftPreview>{draftPreview}</DraftPreview>}
|
|
|
|
<ActionsRow>
|
|
<CompactButton onClick={onAutoRespond}>Auto-respond</CompactButton>
|
|
<CompactButton onClick={onEditAndSend}>Edit & Send</CompactButton>
|
|
<RejectButton onClick={onReject}>Reject</RejectButton>
|
|
</ActionsRow>
|
|
</Stack>
|
|
</RequestContainer>
|
|
);
|
|
}
|