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,12 +635,9 @@ 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: {
|
||||||
|
|
@ -709,10 +706,8 @@ export const createMcpServer = (): McpServerWrapper => {
|
||||||
},
|
},
|
||||||
required: ["name"],
|
required: ["name"],
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
},
|
}, ElicitResultSchema, {timeout: 10 * 60 * 1000 /* 10 minutes */});
|
||||||
ElicitResultSchema
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: [
|
content: [
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue