Phase 2: Refactor Sampling/Elicitation cluster to MCP SDK types
Replace ad hoc local types with SDK schema types across the Sampling and Elicitation group components. - SamplingRequestPanel: accept `request: CreateMessageRequestParams` + `draftResult: CreateMessageResult` instead of 16 flat props; derive messages, model preferences, and parameters from the request object; drop `tools`/`toolChoice` (not in MCP 2025-11-25 CreateMessageRequest) - InlineSamplingRequest: accept `request: CreateMessageRequestParams`; derive messagePreview and modelHints from the request - ElicitationFormPanel: accept `request: ElicitRequest['params']` + `serverName`; pass requestedSchema directly to SchemaForm - ElicitationUrlPanel: rename `elicitationId` to `requestId` - InlineElicitationRequest: accept `request: ElicitRequest['params']`; discriminate form vs URL mode on request shape instead of `mode` prop - PendingClientRequests: unchanged (children-based wrapper) - Delete local `SamplingTool` type - Update all stories with real SDK type fixtures Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7b74598f83
commit
c1a63cb37d
1 changed files with 326 additions and 299 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
||||
import type { ElicitRequest } from "@modelcontextprotocol/sdk/types.js";
|
||||
import { fn } from "storybook/test";
|
||||
import { PendingClientRequests } from "./PendingClientRequests";
|
||||
import { InlineSamplingRequest } from "../InlineSamplingRequest/InlineSamplingRequest";
|
||||
|
|
@ -12,13 +13,50 @@ const meta: Meta<typeof PendingClientRequests> = {
|
|||
export default meta;
|
||||
type Story = StoryObj<typeof PendingClientRequests>;
|
||||
|
||||
const elicitFormRequest = {
|
||||
message: "Please provide your database connection details.",
|
||||
requestedSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
host: { type: "string" as const, title: "Host" },
|
||||
port: { type: "string" as const, title: "Port" },
|
||||
},
|
||||
},
|
||||
} satisfies ElicitRequest["params"];
|
||||
|
||||
const elicitDeployRequest = {
|
||||
message: "Please confirm the deployment target.",
|
||||
requestedSchema: {
|
||||
type: "object" as const,
|
||||
properties: {
|
||||
environment: {
|
||||
type: "string" as const,
|
||||
title: "Environment",
|
||||
enum: ["staging", "production"],
|
||||
},
|
||||
confirm: { type: "boolean" as const, title: "Confirm deployment" },
|
||||
},
|
||||
},
|
||||
} satisfies ElicitRequest["params"];
|
||||
|
||||
export const SingleSampling: Story = {
|
||||
args: {
|
||||
count: 1,
|
||||
children: (
|
||||
<InlineSamplingRequest
|
||||
request={{
|
||||
messages: [
|
||||
{
|
||||
role: "user",
|
||||
content: {
|
||||
type: "text",
|
||||
text: "Please analyze the following code and suggest improvements.",
|
||||
},
|
||||
},
|
||||
],
|
||||
maxTokens: 1024,
|
||||
}}
|
||||
queuePosition="1 of 1"
|
||||
messagePreview="Please analyze the following code and suggest improvements."
|
||||
responseText=""
|
||||
onAutoRespond={fn()}
|
||||
onEditAndSend={fn()}
|
||||
|
|
@ -34,17 +72,8 @@ export const SingleElicitation: Story = {
|
|||
count: 1,
|
||||
children: (
|
||||
<InlineElicitationRequest
|
||||
mode="form"
|
||||
message="Please provide your database connection details."
|
||||
request={elicitFormRequest}
|
||||
queuePosition="1 of 1"
|
||||
schema={{
|
||||
type: "object",
|
||||
properties: {
|
||||
host: { type: "string", title: "Host" },
|
||||
port: { type: "integer", title: "Port" },
|
||||
},
|
||||
required: ["host"],
|
||||
}}
|
||||
values={{}}
|
||||
onChange={fn()}
|
||||
onSubmit={fn()}
|
||||
|
|
@ -60,8 +89,19 @@ export const MultipleMixed: Story = {
|
|||
children: (
|
||||
<>
|
||||
<InlineSamplingRequest
|
||||
request={{
|
||||
messages: [
|
||||
{
|
||||
role: "user",
|
||||
content: {
|
||||
type: "text",
|
||||
text: "Please analyze the following code and suggest improvements.",
|
||||
},
|
||||
},
|
||||
],
|
||||
maxTokens: 1024,
|
||||
}}
|
||||
queuePosition="1 of 2"
|
||||
messagePreview="Please analyze the following code and suggest improvements."
|
||||
responseText=""
|
||||
onAutoRespond={fn()}
|
||||
onEditAndSend={fn()}
|
||||
|
|
@ -69,21 +109,8 @@ export const MultipleMixed: Story = {
|
|||
onViewDetails={fn()}
|
||||
/>
|
||||
<InlineElicitationRequest
|
||||
mode="form"
|
||||
message="Please confirm the deployment target."
|
||||
request={elicitDeployRequest}
|
||||
queuePosition="2 of 2"
|
||||
schema={{
|
||||
type: "object",
|
||||
properties: {
|
||||
environment: {
|
||||
type: "string",
|
||||
title: "Environment",
|
||||
enum: ["staging", "production"],
|
||||
},
|
||||
confirm: { type: "boolean", title: "Confirm deployment" },
|
||||
},
|
||||
required: ["environment", "confirm"],
|
||||
}}
|
||||
values={{}}
|
||||
onChange={fn()}
|
||||
onSubmit={fn()}
|
||||
|
|
|
|||
Loading…
Reference in a new issue