Skip to content

Commit 79b2444

Browse files
committed
fix elicitation
1 parent b6e3974 commit 79b2444

1 file changed

Lines changed: 71 additions & 76 deletions

File tree

  • src/modules/mcp/services

src/modules/mcp/services/mcp.ts

Lines changed: 71 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -454,14 +454,14 @@ export const createMcpServer = (): McpServerWrapper => {
454454
name: ToolName.ELICIT_INPUTS,
455455
description:
456456
"Elicitation test tool that demonstrates how to request user input with various field types",
457-
inputSchema: zodToJsonSchema(ElicitInputsSchema) as ToolInput,
457+
inputSchema: { type: "object" , properties: {} },
458458
},
459459
];
460460

461461
return { tools };
462462
});
463463

464-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
464+
server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
465465
const { name, arguments: args } = request.params;
466466

467467
if (name === ToolName.ECHO) {
@@ -635,84 +635,79 @@ export const createMcpServer = (): McpServerWrapper => {
635635
}
636636

637637
if (name === ToolName.ELICIT_INPUTS) {
638-
ElicitInputsSchema.parse(args);
639-
640638
// Call elicitInput on the server to request user input
641-
const result = await server.request(
642-
{
643-
method: "sampling/elicitInput",
644-
params: {
645-
message: "Please provide inputs for the following fields:",
646-
requestedSchema: {
647-
type: "object",
648-
properties: {
649-
name: {
650-
title: "Full Name",
651-
type: "string",
652-
description: "Your full, legal name",
653-
},
654-
check: {
655-
title: "Agree to terms",
656-
type: "boolean",
657-
description: "A boolean check",
658-
},
659-
color: {
660-
title: "Favorite Color",
661-
type: "string",
662-
description: "Favorite color (open text)",
663-
default: "blue",
664-
},
665-
email: {
666-
title: "Email Address",
667-
type: "string",
668-
format: "email",
669-
description:
670-
"Your email address (will be verified, and never shared with anyone else)",
671-
},
672-
homepage: {
673-
type: "string",
674-
format: "uri",
675-
description: "Homepage / personal site",
676-
},
677-
birthdate: {
678-
title: "Birthdate",
679-
type: "string",
680-
format: "date",
681-
description:
682-
"Your date of birth (will never be shared with anyone else)",
683-
},
684-
integer: {
685-
title: "Favorite Integer",
686-
type: "integer",
687-
description:
688-
"Your favorite integer (do not give us your phone number, pin, or other sensitive info)",
689-
minimum: 1,
690-
maximum: 100,
691-
default: 42,
692-
},
693-
number: {
694-
title: "Favorite Number",
695-
type: "number",
696-
description: "Favorite number (there are no wrong answers)",
697-
minimum: 0,
698-
maximum: 1000,
699-
default: 3.14,
700-
},
701-
petType: {
702-
title: "Pet type",
703-
type: "string",
704-
enum: ["cats", "dogs", "birds", "fish", "reptiles"],
705-
enumNames: ["Cats", "Dogs", "Birds", "Fish", "Reptiles"],
706-
default: "dogs",
707-
description: "Your favorite pet type",
708-
},
639+
const result = await extra.sendRequest({
640+
method: 'elicitation/create',
641+
params: {
642+
message: "Please provide inputs for the following fields:",
643+
requestedSchema: {
644+
type: "object",
645+
properties: {
646+
name: {
647+
title: "Full Name",
648+
type: "string",
649+
description: "Your full, legal name",
650+
},
651+
check: {
652+
title: "Agree to terms",
653+
type: "boolean",
654+
description: "A boolean check",
655+
},
656+
color: {
657+
title: "Favorite Color",
658+
type: "string",
659+
description: "Favorite color (open text)",
660+
default: "blue",
661+
},
662+
email: {
663+
title: "Email Address",
664+
type: "string",
665+
format: "email",
666+
description:
667+
"Your email address (will be verified, and never shared with anyone else)",
668+
},
669+
homepage: {
670+
type: "string",
671+
format: "uri",
672+
description: "Homepage / personal site",
673+
},
674+
birthdate: {
675+
title: "Birthdate",
676+
type: "string",
677+
format: "date",
678+
description:
679+
"Your date of birth (will never be shared with anyone else)",
680+
},
681+
integer: {
682+
title: "Favorite Integer",
683+
type: "integer",
684+
description:
685+
"Your favorite integer (do not give us your phone number, pin, or other sensitive info)",
686+
minimum: 1,
687+
maximum: 100,
688+
default: 42,
689+
},
690+
number: {
691+
title: "Favorite Number",
692+
type: "number",
693+
description: "Favorite number (there are no wrong answers)",
694+
minimum: 0,
695+
maximum: 1000,
696+
default: 3.14,
697+
},
698+
petType: {
699+
title: "Pet type",
700+
type: "string",
701+
enum: ["cats", "dogs", "birds", "fish", "reptiles"],
702+
enumNames: ["Cats", "Dogs", "Birds", "Fish", "Reptiles"],
703+
default: "dogs",
704+
description: "Your favorite pet type",
709705
},
710-
required: ["name"],
711706
},
707+
required: ["name"],
712708
},
713-
},
714-
ElicitResultSchema
715-
);
709+
}
710+
}, ElicitResultSchema, {timeout: 10 * 60 * 1000 /* 10 minutes */});
716711

717712
return {
718713
content: [

0 commit comments

Comments
 (0)