MRTR: drive input_required manually to keep pending-request UX (#1704) (#1719)
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
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>
This commit is contained in:
parent
73d9b181fe
commit
9b2c188d11
13 changed files with 1131 additions and 96 deletions
|
|
@ -0,0 +1,18 @@
|
|||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
||||
import { MrtrOriginNote } from "./MrtrOriginNote";
|
||||
|
||||
const meta: Meta<typeof MrtrOriginNote> = {
|
||||
title: "Elements/MrtrOriginNote",
|
||||
component: MrtrOriginNote,
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof MrtrOriginNote>;
|
||||
|
||||
export const InputRequired: Story = {
|
||||
args: { origin: "input-required" },
|
||||
};
|
||||
|
||||
export const ServerRequest: Story = {
|
||||
args: { origin: "server-request" },
|
||||
};
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
import { describe, it, expect } from "vitest";
|
||||
import { renderWithMantine, screen } from "../../../test/renderWithMantine";
|
||||
import { MrtrOriginNote } from "./MrtrOriginNote";
|
||||
|
||||
describe("MrtrOriginNote", () => {
|
||||
it("renders the MRTR note for a modern input-required round", () => {
|
||||
renderWithMantine(<MrtrOriginNote origin="input-required" />);
|
||||
expect(screen.getByText("input_required")).toBeInTheDocument();
|
||||
expect(screen.getByText(/sent back as a retry/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders nothing for a legacy server request", () => {
|
||||
renderWithMantine(<MrtrOriginNote origin="server-request" />);
|
||||
expect(screen.queryByText("input_required")).not.toBeInTheDocument();
|
||||
expect(screen.queryByText(/sent back as a retry/i)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("defaults to rendering nothing when origin is omitted", () => {
|
||||
renderWithMantine(<MrtrOriginNote />);
|
||||
expect(screen.queryByText("input_required")).not.toBeInTheDocument();
|
||||
expect(screen.queryByText(/sent back as a retry/i)).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
import { Badge, Group, Text } from "@mantine/core";
|
||||
import type { PendingRequestOrigin } from "@inspector/core/mcp/types.js";
|
||||
|
||||
export interface MrtrOriginNoteProps {
|
||||
/**
|
||||
* How the pending request reached the Inspector. `"server-request"` (the
|
||||
* default) is a legacy server→client request and renders nothing, keeping the
|
||||
* panel visually identical to its pre-MRTR form. `"input-required"` is a
|
||||
* modern (2026-07-28) MRTR round and renders the era-accurate note.
|
||||
*/
|
||||
origin?: PendingRequestOrigin;
|
||||
}
|
||||
|
||||
const NoteRow = Group.withProps({
|
||||
gap: "xs",
|
||||
align: "center",
|
||||
wrap: "nowrap",
|
||||
});
|
||||
|
||||
const NoteText = Text.withProps({
|
||||
size: "xs",
|
||||
c: "dimmed",
|
||||
});
|
||||
|
||||
/**
|
||||
* Era-accurate note for a pending sampling/elicitation request. On a modern
|
||||
* MRTR round (`origin: "input-required"`, SEP-2322) the request was embedded in
|
||||
* a tool-call/prompt/resource `input_required` result rather than sent as a
|
||||
* server→client JSON-RPC request, and the user's answer is echoed back to the
|
||||
* server as a retry of the original call. Legacy requests
|
||||
* (`origin: "server-request"`) render nothing so their panels are unchanged.
|
||||
*/
|
||||
export function MrtrOriginNote({
|
||||
origin = "server-request",
|
||||
}: MrtrOriginNoteProps) {
|
||||
if (origin !== "input-required") return null;
|
||||
return (
|
||||
<NoteRow>
|
||||
<Badge variant="outline" color="blue">
|
||||
input_required
|
||||
</Badge>
|
||||
<NoteText>
|
||||
The server returned input_required; your answer is sent back as a retry
|
||||
of the original request (MRTR).
|
||||
</NoteText>
|
||||
</NoteRow>
|
||||
);
|
||||
}
|
||||
|
|
@ -8,11 +8,13 @@ import {
|
|||
Text,
|
||||
} from "@mantine/core";
|
||||
import type { ElicitRequestFormParams } from "@modelcontextprotocol/client";
|
||||
import type { PendingRequestOrigin } from "@inspector/core/mcp/types.js";
|
||||
import {
|
||||
hasMissingRequiredFields,
|
||||
type InspectorFormSchema,
|
||||
} from "../../../utils/jsonUtils";
|
||||
import { SchemaForm } from "../SchemaForm/SchemaForm";
|
||||
import { MrtrOriginNote } from "../../elements/MrtrOriginNote/MrtrOriginNote";
|
||||
|
||||
export interface ElicitationFormPanelProps {
|
||||
request: ElicitRequestFormParams;
|
||||
|
|
@ -24,6 +26,12 @@ export interface ElicitationFormPanelProps {
|
|||
onDecline: () => void;
|
||||
/** Dismissal without an explicit choice (maps to the spec's `cancel`). */
|
||||
onCancel: () => void;
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* A response has been dispatched; lock the actions so a second click can't
|
||||
* resolve the request twice (the underlying handler throws if called again).
|
||||
|
|
@ -66,6 +74,7 @@ export function ElicitationFormPanel({
|
|||
onSubmit,
|
||||
onDecline,
|
||||
onCancel,
|
||||
origin = "server-request",
|
||||
busy = false,
|
||||
}: ElicitationFormPanelProps) {
|
||||
const requestedSchema = request.requestedSchema as InspectorFormSchema;
|
||||
|
|
@ -74,6 +83,7 @@ export function ElicitationFormPanel({
|
|||
return (
|
||||
<Stack gap="md">
|
||||
<QuotedMessage>{formatQuoted(request.message)}</QuotedMessage>
|
||||
<MrtrOriginNote origin={origin} />
|
||||
<Divider />
|
||||
<FieldScroll>
|
||||
<SchemaForm
|
||||
|
|
|
|||
|
|
@ -8,11 +8,19 @@ import {
|
|||
Stack,
|
||||
Text,
|
||||
} from "@mantine/core";
|
||||
import type { PendingRequestOrigin } from "@inspector/core/mcp/types.js";
|
||||
import { MrtrOriginNote } from "../../elements/MrtrOriginNote/MrtrOriginNote";
|
||||
|
||||
export interface ElicitationUrlPanelProps {
|
||||
message: string;
|
||||
url: string;
|
||||
requestId: string;
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* The URL has been opened and we're waiting for the user to confirm they
|
||||
* finished the external flow. Reveals the "I've completed it" action; opening
|
||||
|
|
@ -65,11 +73,13 @@ export function ElicitationUrlPanel({
|
|||
onOpenInBrowser,
|
||||
onComplete,
|
||||
onCancel,
|
||||
origin = "server-request",
|
||||
busy = false,
|
||||
}: ElicitationUrlPanelProps) {
|
||||
return (
|
||||
<Stack gap="md">
|
||||
<ItalicMessage>{message}</ItalicMessage>
|
||||
<MrtrOriginNote origin={origin} />
|
||||
<Divider />
|
||||
<Text size="sm">The server is requesting you visit:</Text>
|
||||
<WrappingCode>{url}</WrappingCode>
|
||||
|
|
|
|||
|
|
@ -41,6 +41,21 @@ describe("InlineElicitationRequest", () => {
|
|||
expect(screen.getByText("elicitation/create (form)")).toBeInTheDocument();
|
||||
expect(screen.getByText(formRequest.message)).toBeInTheDocument();
|
||||
expect(screen.getByText("1 of 1")).toBeInTheDocument();
|
||||
// Default origin is a legacy server request — no MRTR note.
|
||||
expect(screen.queryByText("input_required")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows the MRTR note for a modern input_required round", () => {
|
||||
renderWithMantine(
|
||||
<InlineElicitationRequest
|
||||
{...baseProps}
|
||||
request={formRequest}
|
||||
values={{}}
|
||||
origin="input-required"
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByText("input_required")).toBeInTheDocument();
|
||||
expect(screen.getByText(/sent back as a retry/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders schema fields and a Submit button in form mode", () => {
|
||||
|
|
|
|||
|
|
@ -12,14 +12,22 @@ import type {
|
|||
ElicitRequest,
|
||||
ElicitRequestFormParams,
|
||||
} from "@modelcontextprotocol/client";
|
||||
import type { PendingRequestOrigin } from "@inspector/core/mcp/types.js";
|
||||
import type { InspectorFormSchema } from "../../../utils/jsonUtils";
|
||||
import { SchemaForm } from "../SchemaForm/SchemaForm";
|
||||
import { MrtrOriginNote } from "../../elements/MrtrOriginNote/MrtrOriginNote";
|
||||
|
||||
export interface InlineElicitationRequestProps {
|
||||
request: ElicitRequest["params"];
|
||||
queuePosition: string;
|
||||
values?: Record<string, unknown>;
|
||||
isWaiting?: boolean;
|
||||
/**
|
||||
* 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;
|
||||
onChange: (values: Record<string, unknown>) => void;
|
||||
onSubmit: () => void;
|
||||
onCancel: () => void;
|
||||
|
|
@ -73,6 +81,7 @@ export function InlineElicitationRequest({
|
|||
queuePosition,
|
||||
values,
|
||||
isWaiting,
|
||||
origin = "server-request",
|
||||
onChange,
|
||||
onSubmit,
|
||||
onCancel,
|
||||
|
|
@ -86,6 +95,7 @@ export function InlineElicitationRequest({
|
|||
</Group>
|
||||
|
||||
<ItalicMessage>{request.message}</ItalicMessage>
|
||||
<MrtrOriginNote origin={origin} />
|
||||
|
||||
{isFormMode(request) && (
|
||||
<SchemaForm
|
||||
|
|
|
|||
|
|
@ -84,6 +84,20 @@ describe("InlineSamplingRequest", () => {
|
|||
expect(screen.getByText("sampling/createMessage")).toBeInTheDocument();
|
||||
expect(screen.getByText("1 of 1")).toBeInTheDocument();
|
||||
expect(screen.getByText("Please analyze this code.")).toBeInTheDocument();
|
||||
// Default origin is a legacy server request — no MRTR note.
|
||||
expect(screen.queryByText("input_required")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows the MRTR note for a modern input_required round", () => {
|
||||
renderWithMantine(
|
||||
<InlineSamplingRequest
|
||||
{...baseProps}
|
||||
request={textRequest}
|
||||
origin="input-required"
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByText("input_required")).toBeInTheDocument();
|
||||
expect(screen.getByText(/sent back as a retry/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders model hints when provided", () => {
|
||||
|
|
|
|||
|
|
@ -3,11 +3,19 @@ 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;
|
||||
|
|
@ -94,6 +102,7 @@ export function InlineSamplingRequest({
|
|||
request,
|
||||
queuePosition,
|
||||
draftResult,
|
||||
origin = "server-request",
|
||||
onAutoRespond,
|
||||
onEditAndSend,
|
||||
onReject,
|
||||
|
|
@ -111,6 +120,8 @@ export function InlineSamplingRequest({
|
|||
<QueueLabel>{queuePosition}</QueueLabel>
|
||||
</Group>
|
||||
|
||||
<MrtrOriginNote origin={origin} />
|
||||
|
||||
{modelHints && <Text size="sm">{formatModelHints(modelHints)}</Text>}
|
||||
|
||||
<PreviewText>{messagePreview}</PreviewText>
|
||||
|
|
|
|||
|
|
@ -112,7 +112,12 @@ type Story = StoryObj<typeof PendingClientRequestModal>;
|
|||
|
||||
export const Sampling: Story = {
|
||||
args: {
|
||||
request: { kind: "sampling", id: "sampling-1", request: samplingRequest },
|
||||
request: {
|
||||
kind: "sampling",
|
||||
id: "sampling-1",
|
||||
request: samplingRequest,
|
||||
origin: "server-request",
|
||||
},
|
||||
},
|
||||
play: async ({ canvasElement, args }) => {
|
||||
const body = within(canvasElement.ownerDocument.body);
|
||||
|
|
@ -125,12 +130,32 @@ export const Sampling: Story = {
|
|||
},
|
||||
};
|
||||
|
||||
// A modern MRTR round: the sampling request was embedded in a tool-call
|
||||
// `input_required` result, so the panel shows the era-accurate note.
|
||||
export const SamplingInputRequired: Story = {
|
||||
args: {
|
||||
request: {
|
||||
kind: "sampling",
|
||||
id: "sampling-mrtr",
|
||||
request: samplingRequest,
|
||||
origin: "input-required",
|
||||
},
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const body = within(canvasElement.ownerDocument.body);
|
||||
await body.findByText("Sampling Request");
|
||||
expect(body.getByText("input_required")).toBeInTheDocument();
|
||||
expect(body.getByText(/sent back as a retry/i)).toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const SamplingTall: Story = {
|
||||
args: {
|
||||
request: {
|
||||
kind: "sampling",
|
||||
id: "sampling-tall",
|
||||
request: tallSamplingRequest,
|
||||
origin: "server-request",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
@ -141,6 +166,7 @@ export const ElicitationForm: Story = {
|
|||
kind: "elicitation-form",
|
||||
id: "elicitation-1",
|
||||
request: formRequest,
|
||||
origin: "server-request",
|
||||
},
|
||||
},
|
||||
play: async ({ canvasElement, args }) => {
|
||||
|
|
@ -163,6 +189,7 @@ export const ElicitationFormTall: Story = {
|
|||
kind: "elicitation-form",
|
||||
id: "elicitation-tall",
|
||||
request: tallFormRequest,
|
||||
origin: "server-request",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
@ -174,6 +201,7 @@ export const ElicitationUrl: Story = {
|
|||
id: "elicitation-2",
|
||||
message: "Authorize access in your browser to continue.",
|
||||
url: "https://example.com/authorize?token=abc123",
|
||||
origin: "server-request",
|
||||
},
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
|
|
|
|||
|
|
@ -32,12 +32,14 @@ const samplingContent: PendingClientRequestContent = {
|
|||
kind: "sampling",
|
||||
id: "sampling-1",
|
||||
request: samplingRequest,
|
||||
origin: "server-request",
|
||||
};
|
||||
|
||||
const formContent: PendingClientRequestContent = {
|
||||
kind: "elicitation-form",
|
||||
id: "elicitation-1",
|
||||
request: formRequest,
|
||||
origin: "server-request",
|
||||
};
|
||||
|
||||
const urlContent: PendingClientRequestContent = {
|
||||
|
|
@ -45,6 +47,7 @@ const urlContent: PendingClientRequestContent = {
|
|||
id: "elicitation-2",
|
||||
message: "Authorize access in your browser.",
|
||||
url: "https://example.com/authorize",
|
||||
origin: "server-request",
|
||||
};
|
||||
|
||||
const baseProps = {
|
||||
|
|
@ -77,6 +80,19 @@ describe("PendingClientRequestModal", () => {
|
|||
expect(
|
||||
screen.getByText("The server is requesting an LLM completion."),
|
||||
).toBeInTheDocument();
|
||||
// Legacy server-request origin: no MRTR note.
|
||||
expect(screen.queryByText("input_required")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows the MRTR note when the request is a modern input_required round", () => {
|
||||
renderWithMantine(
|
||||
<PendingClientRequestModal
|
||||
{...baseProps}
|
||||
request={{ ...samplingContent, origin: "input-required" }}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByText("input_required")).toBeInTheDocument();
|
||||
expect(screen.getByText(/sent back as a retry/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("sends the default stub sampling result when the draft is untouched", async () => {
|
||||
|
|
@ -176,6 +192,7 @@ describe("PendingClientRequestModal", () => {
|
|||
},
|
||||
},
|
||||
},
|
||||
origin: "server-request",
|
||||
};
|
||||
renderWithMantine(
|
||||
<PendingClientRequestModal {...baseProps} request={formWithDefaults} />,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import type {
|
|||
ElicitRequestFormParams,
|
||||
ElicitResult,
|
||||
} from "@modelcontextprotocol/client";
|
||||
import type { PendingRequestOrigin } from "@inspector/core/mcp/types.js";
|
||||
import { SamplingRequestPanel } from "../SamplingRequestPanel/SamplingRequestPanel";
|
||||
import { ElicitationFormPanel } from "../ElicitationFormPanel/ElicitationFormPanel";
|
||||
import { ElicitationUrlPanel } from "../ElicitationUrlPanel/ElicitationUrlPanel";
|
||||
|
|
@ -17,12 +18,30 @@ import {
|
|||
/**
|
||||
* The server-initiated request currently shown in the modal. `id` is the
|
||||
* client-side request id; it keys the modal body so per-request draft state
|
||||
* resets when the active request changes.
|
||||
* resets when the active request changes. `origin` distinguishes a legacy
|
||||
* server→client request from a modern MRTR `input_required` round so the panels
|
||||
* can show era-accurate semantics (#1704).
|
||||
*/
|
||||
export type PendingClientRequestContent =
|
||||
| { kind: "sampling"; id: string; request: CreateMessageRequestParams }
|
||||
| { kind: "elicitation-form"; id: string; request: ElicitRequestFormParams }
|
||||
| { kind: "elicitation-url"; id: string; message: string; url: string };
|
||||
| {
|
||||
kind: "sampling";
|
||||
id: string;
|
||||
request: CreateMessageRequestParams;
|
||||
origin: PendingRequestOrigin;
|
||||
}
|
||||
| {
|
||||
kind: "elicitation-form";
|
||||
id: string;
|
||||
request: ElicitRequestFormParams;
|
||||
origin: PendingRequestOrigin;
|
||||
}
|
||||
| {
|
||||
kind: "elicitation-url";
|
||||
id: string;
|
||||
message: string;
|
||||
url: string;
|
||||
origin: PendingRequestOrigin;
|
||||
};
|
||||
|
||||
export interface PendingClientRequestModalProps {
|
||||
/** The active request to display, or null when nothing is pending. */
|
||||
|
|
@ -103,10 +122,12 @@ function useRespondOnce(): {
|
|||
|
||||
function SamplingModalBody({
|
||||
request,
|
||||
origin,
|
||||
onRespond,
|
||||
onReject,
|
||||
}: {
|
||||
request: CreateMessageRequestParams;
|
||||
origin: PendingRequestOrigin;
|
||||
onRespond: (result: CreateMessageResult) => void;
|
||||
onReject: () => void;
|
||||
}) {
|
||||
|
|
@ -117,6 +138,7 @@ function SamplingModalBody({
|
|||
return (
|
||||
<SamplingRequestPanel
|
||||
request={request}
|
||||
origin={origin}
|
||||
draftResult={draftResult}
|
||||
onResultChange={setDraftResult}
|
||||
onSend={once(() => onRespond(draftResult))}
|
||||
|
|
@ -129,10 +151,12 @@ function SamplingModalBody({
|
|||
function ElicitationFormModalBody({
|
||||
request,
|
||||
serverName,
|
||||
origin,
|
||||
onRespond,
|
||||
}: {
|
||||
request: ElicitRequestFormParams;
|
||||
serverName: string;
|
||||
origin: PendingRequestOrigin;
|
||||
onRespond: (result: ElicitResult) => void;
|
||||
}) {
|
||||
// Seed with the schema's defaults so default-only fields the user never
|
||||
|
|
@ -147,6 +171,7 @@ function ElicitationFormModalBody({
|
|||
<ElicitationFormPanel
|
||||
request={request}
|
||||
serverName={serverName}
|
||||
origin={origin}
|
||||
values={values}
|
||||
onChange={setValues}
|
||||
onSubmit={once(() =>
|
||||
|
|
@ -166,11 +191,13 @@ function ElicitationUrlModalBody({
|
|||
id,
|
||||
message,
|
||||
url,
|
||||
origin,
|
||||
onRespond,
|
||||
}: {
|
||||
id: string;
|
||||
message: string;
|
||||
url: string;
|
||||
origin: PendingRequestOrigin;
|
||||
onRespond: (result: ElicitResult) => void;
|
||||
}) {
|
||||
const [isWaiting, setIsWaiting] = useState(false);
|
||||
|
|
@ -179,6 +206,7 @@ function ElicitationUrlModalBody({
|
|||
<ElicitationUrlPanel
|
||||
message={message}
|
||||
url={url}
|
||||
origin={origin}
|
||||
requestId={id}
|
||||
isWaiting={isWaiting}
|
||||
onCopyUrl={() => {
|
||||
|
|
@ -237,6 +265,7 @@ export function PendingClientRequestModal({
|
|||
<SamplingModalBody
|
||||
key={request.id}
|
||||
request={request.request}
|
||||
origin={request.origin}
|
||||
onRespond={onSamplingRespond}
|
||||
onReject={onSamplingReject}
|
||||
/>
|
||||
|
|
@ -246,6 +275,7 @@ export function PendingClientRequestModal({
|
|||
key={request.id}
|
||||
request={request.request}
|
||||
serverName={serverName}
|
||||
origin={request.origin}
|
||||
onRespond={onElicitationRespond}
|
||||
/>
|
||||
)}
|
||||
|
|
@ -255,6 +285,7 @@ export function PendingClientRequestModal({
|
|||
id={request.id}
|
||||
message={request.message}
|
||||
url={request.url}
|
||||
origin={request.origin}
|
||||
onRespond={onElicitationRespond}
|
||||
/>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@ import type {
|
|||
CreateMessageRequestParams,
|
||||
CreateMessageResult,
|
||||
} from "@modelcontextprotocol/client";
|
||||
import type { PendingRequestOrigin } from "@inspector/core/mcp/types.js";
|
||||
import { MessageBubble } from "../../elements/MessageBubble/MessageBubble";
|
||||
import { MrtrOriginNote } from "../../elements/MrtrOriginNote/MrtrOriginNote";
|
||||
|
||||
export interface SamplingRequestPanelProps {
|
||||
request: CreateMessageRequestParams;
|
||||
|
|
@ -25,6 +27,12 @@ export interface SamplingRequestPanelProps {
|
|||
onResultChange: (result: CreateMessageResult) => void;
|
||||
onSend: () => void;
|
||||
onReject: () => void;
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* A response has been dispatched; lock the actions so a second click can't
|
||||
* resolve the request twice (the underlying handler throws if called again).
|
||||
|
|
@ -90,6 +98,7 @@ export function SamplingRequestPanel({
|
|||
onResultChange,
|
||||
onSend,
|
||||
onReject,
|
||||
origin = "server-request",
|
||||
busy = false,
|
||||
}: SamplingRequestPanelProps) {
|
||||
const {
|
||||
|
|
@ -110,6 +119,7 @@ export function SamplingRequestPanel({
|
|||
<ContentScroll>
|
||||
<ContentStack>
|
||||
<HintText>The server is requesting an LLM completion.</HintText>
|
||||
<MrtrOriginNote origin={origin} />
|
||||
|
||||
<SectionTitle>Messages:</SectionTitle>
|
||||
{messages.map((message, index) => (
|
||||
|
|
|
|||
Loading…
Reference in a new issue