fix elicitation
This commit is contained in:
parent
b6e39748aa
commit
79b2444701
1 changed files with 71 additions and 76 deletions
|
|
@ -454,14 +454,14 @@ export const createMcpServer = (): McpServerWrapper => {
|
|||
name: ToolName.ELICIT_INPUTS,
|
||||
description:
|
||||
"Elicitation test tool that demonstrates how to request user input with various field types",
|
||||
inputSchema: zodToJsonSchema(ElicitInputsSchema) as ToolInput,
|
||||
inputSchema: { type: "object" , properties: {} },
|
||||
},
|
||||
];
|
||||
|
||||
return { tools };
|
||||
});
|
||||
|
||||
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
||||
const { name, arguments: args } = request.params;
|
||||
|
||||
if (name === ToolName.ECHO) {
|
||||
|
|
@ -635,84 +635,79 @@ export const createMcpServer = (): McpServerWrapper => {
|
|||
}
|
||||
|
||||
if (name === ToolName.ELICIT_INPUTS) {
|
||||
ElicitInputsSchema.parse(args);
|
||||
|
||||
// Call elicitInput on the server to request user input
|
||||
const result = await server.request(
|
||||
{
|
||||
method: "sampling/elicitInput",
|
||||
params: {
|
||||
message: "Please provide inputs for the following fields:",
|
||||
requestedSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
name: {
|
||||
title: "Full Name",
|
||||
type: "string",
|
||||
description: "Your full, legal name",
|
||||
},
|
||||
check: {
|
||||
title: "Agree to terms",
|
||||
type: "boolean",
|
||||
description: "A boolean check",
|
||||
},
|
||||
color: {
|
||||
title: "Favorite Color",
|
||||
type: "string",
|
||||
description: "Favorite color (open text)",
|
||||
default: "blue",
|
||||
},
|
||||
email: {
|
||||
title: "Email Address",
|
||||
type: "string",
|
||||
format: "email",
|
||||
description:
|
||||
"Your email address (will be verified, and never shared with anyone else)",
|
||||
},
|
||||
homepage: {
|
||||
type: "string",
|
||||
format: "uri",
|
||||
description: "Homepage / personal site",
|
||||
},
|
||||
birthdate: {
|
||||
title: "Birthdate",
|
||||
type: "string",
|
||||
format: "date",
|
||||
description:
|
||||
"Your date of birth (will never be shared with anyone else)",
|
||||
},
|
||||
integer: {
|
||||
title: "Favorite Integer",
|
||||
type: "integer",
|
||||
description:
|
||||
"Your favorite integer (do not give us your phone number, pin, or other sensitive info)",
|
||||
minimum: 1,
|
||||
maximum: 100,
|
||||
default: 42,
|
||||
},
|
||||
number: {
|
||||
title: "Favorite Number",
|
||||
type: "number",
|
||||
description: "Favorite number (there are no wrong answers)",
|
||||
minimum: 0,
|
||||
maximum: 1000,
|
||||
default: 3.14,
|
||||
},
|
||||
petType: {
|
||||
title: "Pet type",
|
||||
type: "string",
|
||||
enum: ["cats", "dogs", "birds", "fish", "reptiles"],
|
||||
enumNames: ["Cats", "Dogs", "Birds", "Fish", "Reptiles"],
|
||||
default: "dogs",
|
||||
description: "Your favorite pet type",
|
||||
},
|
||||
const result = await extra.sendRequest({
|
||||
method: 'elicitation/create',
|
||||
params: {
|
||||
message: "Please provide inputs for the following fields:",
|
||||
requestedSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
name: {
|
||||
title: "Full Name",
|
||||
type: "string",
|
||||
description: "Your full, legal name",
|
||||
},
|
||||
check: {
|
||||
title: "Agree to terms",
|
||||
type: "boolean",
|
||||
description: "A boolean check",
|
||||
},
|
||||
color: {
|
||||
title: "Favorite Color",
|
||||
type: "string",
|
||||
description: "Favorite color (open text)",
|
||||
default: "blue",
|
||||
},
|
||||
email: {
|
||||
title: "Email Address",
|
||||
type: "string",
|
||||
format: "email",
|
||||
description:
|
||||
"Your email address (will be verified, and never shared with anyone else)",
|
||||
},
|
||||
homepage: {
|
||||
type: "string",
|
||||
format: "uri",
|
||||
description: "Homepage / personal site",
|
||||
},
|
||||
birthdate: {
|
||||
title: "Birthdate",
|
||||
type: "string",
|
||||
format: "date",
|
||||
description:
|
||||
"Your date of birth (will never be shared with anyone else)",
|
||||
},
|
||||
integer: {
|
||||
title: "Favorite Integer",
|
||||
type: "integer",
|
||||
description:
|
||||
"Your favorite integer (do not give us your phone number, pin, or other sensitive info)",
|
||||
minimum: 1,
|
||||
maximum: 100,
|
||||
default: 42,
|
||||
},
|
||||
number: {
|
||||
title: "Favorite Number",
|
||||
type: "number",
|
||||
description: "Favorite number (there are no wrong answers)",
|
||||
minimum: 0,
|
||||
maximum: 1000,
|
||||
default: 3.14,
|
||||
},
|
||||
petType: {
|
||||
title: "Pet type",
|
||||
type: "string",
|
||||
enum: ["cats", "dogs", "birds", "fish", "reptiles"],
|
||||
enumNames: ["Cats", "Dogs", "Birds", "Fish", "Reptiles"],
|
||||
default: "dogs",
|
||||
description: "Your favorite pet type",
|
||||
},
|
||||
required: ["name"],
|
||||
},
|
||||
required: ["name"],
|
||||
},
|
||||
},
|
||||
ElicitResultSchema
|
||||
);
|
||||
}
|
||||
}, ElicitResultSchema, {timeout: 10 * 60 * 1000 /* 10 minutes */});
|
||||
|
||||
return {
|
||||
content: [
|
||||
|
|
|
|||
Loading…
Reference in a new issue