mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-22 05:45:15 +02:00
Updated based on PR feedback
This commit is contained in:
@@ -86,13 +86,7 @@ const GetResourceReferenceSchema = z.object({
|
|||||||
.describe("ID of the resource to reference (1-100)"),
|
.describe("ID of the resource to reference (1-100)"),
|
||||||
});
|
});
|
||||||
|
|
||||||
const ElicitationSchema = z.object({
|
const ElicitationSchema = z.object({});
|
||||||
message: z.string().describe("Message to use for elicitation"),
|
|
||||||
includeSchema: z
|
|
||||||
.boolean()
|
|
||||||
.default(true)
|
|
||||||
.describe("Whether to include the favorite things schema"),
|
|
||||||
});
|
|
||||||
|
|
||||||
enum ToolName {
|
enum ToolName {
|
||||||
ECHO = "echo",
|
ECHO = "echo",
|
||||||
@@ -679,7 +673,7 @@ export const createServer = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (name === ToolName.ELICITATION) {
|
if (name === ToolName.ELICITATION) {
|
||||||
const { message, includeSchema } = ElicitationSchema.parse(args);
|
ElicitationSchema.parse(args);
|
||||||
|
|
||||||
const elicitationResult = await requestElicitation(
|
const elicitationResult = await requestElicitation(
|
||||||
'What are your favorite things?',
|
'What are your favorite things?',
|
||||||
@@ -697,18 +691,40 @@ export const createServer = () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
// Handle different response actions
|
||||||
content: [
|
const content = [];
|
||||||
{
|
|
||||||
type: "text",
|
if (elicitationResult.action === 'accept' && elicitationResult.content) {
|
||||||
text: `Elicitation demo completed! Message: ${message}`,
|
content.push({
|
||||||
},
|
type: "text",
|
||||||
{
|
text: `✅ User provided their favorite things!`,
|
||||||
type: "text",
|
});
|
||||||
text: `Elicitation result: ${JSON.stringify(elicitationResult, null, 2)}`,
|
|
||||||
},
|
// Only access elicitationResult.content when action is accept
|
||||||
],
|
const { color, number, pets } = elicitationResult.content;
|
||||||
};
|
content.push({
|
||||||
|
type: "text",
|
||||||
|
text: `Their favorites are:\n- Color: ${color || 'not specified'}\n- Number: ${number || 'not specified'}\n- Pets: ${pets || 'not specified'}`,
|
||||||
|
});
|
||||||
|
} else if (elicitationResult.action === 'decline') {
|
||||||
|
content.push({
|
||||||
|
type: "text",
|
||||||
|
text: `❌ User declined to provide their favorite things.`,
|
||||||
|
});
|
||||||
|
} else if (elicitationResult.action === 'cancel') {
|
||||||
|
content.push({
|
||||||
|
type: "text",
|
||||||
|
text: `⚠️ User cancelled the elicitation dialog.`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Include raw result for debugging
|
||||||
|
content.push({
|
||||||
|
type: "text",
|
||||||
|
text: `\nRaw result: ${JSON.stringify(elicitationResult, null, 2)}`,
|
||||||
|
});
|
||||||
|
|
||||||
|
return { content };
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(`Unknown tool: ${name}`);
|
throw new Error(`Unknown tool: ${name}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user