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