From 72714ed0f10d46f269836e4a5f07963ea5b060d4 Mon Sep 17 00:00:00 2001 From: Den Delimarsky Date: Mon, 23 Jun 2025 15:54:45 -0700 Subject: [PATCH 01/10] Elicitation support --- src/everything/everything.ts | 68 ++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/src/everything/everything.ts b/src/everything/everything.ts index 2abce9a075..3c8faf0167 100644 --- a/src/everything/everything.ts +++ b/src/everything/everything.ts @@ -86,6 +86,14 @@ const GetResourceReferenceSchema = z.object({ .describe("ID of the resource to reference (1-100)"), }); +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 { ECHO = "echo", ADD = "add", @@ -95,6 +103,7 @@ enum ToolName { GET_TINY_IMAGE = "getTinyImage", ANNOTATED_MESSAGE = "annotatedMessage", GET_RESOURCE_REFERENCE = "getResourceReference", + ELICITATION_DEMO = "elicitationDemo", } enum PromptName { @@ -109,13 +118,13 @@ export const createServer = () => { name: "example-servers/everything", version: "1.0.0", }, - { - capabilities: { + { capabilities: { prompts: {}, resources: { subscribe: true }, tools: {}, logging: {}, completions: {}, + elicitation: {}, }, instructions } @@ -206,6 +215,22 @@ export const createServer = () => { return await server.request(request, CreateMessageResultSchema); }; + // Helper method to make elicitation requests + const requestElicitation = async ( + message: string, + requestedSchema: any + ) => { + const request = { + method: 'elicitation/create', + params: { + message, + requestedSchema + } + }; + + return await server.request(request, z.any()); + }; + const ALL_RESOURCES: Resource[] = Array.from({ length: 100 }, (_, i) => { const uri = `test://static/resource/${i + 1}`; if (i % 2 === 0) { @@ -459,6 +484,11 @@ export const createServer = () => { "Returns a resource reference that can be used by MCP clients", inputSchema: zodToJsonSchema(GetResourceReferenceSchema) as ToolInput, }, + { + name: ToolName.ELICITATION_DEMO, + description: "Demonstrates the elicitation feature", + inputSchema: zodToJsonSchema(ElicitationSchema) as ToolInput, + }, ]; return { tools }; @@ -648,6 +678,40 @@ export const createServer = () => { return { content }; } + if (name === ToolName.ELICITATION_DEMO) { + const { message, includeSchema } = ElicitationSchema.parse(args); + + // Make the elicitation request like in your example + const elicitationResult = await requestElicitation( + 'What are your favorite things?', + { + type: 'object', + properties: { + color: { type: 'string', description: 'Favorite color' }, + number: { type: 'integer', description: 'Favorite number', minimum: 1, maximum: 100 }, + things: { + type: 'string', + enum: ['cats', 'dogs', 'birds', 'brown paper packages tied up with string'], + description: 'Favorite things' + }, + } + } + ); + + return { + content: [ + { + type: "text", + text: `Elicitation demo completed! Message: ${message}`, + }, + { + type: "text", + text: `Elicitation result: ${JSON.stringify(elicitationResult, null, 2)}`, + }, + ], + }; + } + throw new Error(`Unknown tool: ${name}`); }); From 642f3ac192fb6634e09c68636599f25304aa0dec Mon Sep 17 00:00:00 2001 From: Den Delimarsky Date: Mon, 23 Jun 2025 17:05:35 -0700 Subject: [PATCH 02/10] Update --- src/everything/everything.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/everything/everything.ts b/src/everything/everything.ts index 3c8faf0167..0cd830b72d 100644 --- a/src/everything/everything.ts +++ b/src/everything/everything.ts @@ -118,7 +118,8 @@ export const createServer = () => { name: "example-servers/everything", version: "1.0.0", }, - { capabilities: { + { + capabilities: { prompts: {}, resources: { subscribe: true }, tools: {}, From a2a83cc40ed29f6b6a425005fb808866d2b7873d Mon Sep 17 00:00:00 2001 From: Den Delimarsky Date: Wed, 25 Jun 2025 20:54:33 -0700 Subject: [PATCH 03/10] Update elicitation demo --- src/everything/everything.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/everything/everything.ts b/src/everything/everything.ts index 0cd830b72d..218b3b3601 100644 --- a/src/everything/everything.ts +++ b/src/everything/everything.ts @@ -690,10 +690,10 @@ export const createServer = () => { properties: { color: { type: 'string', description: 'Favorite color' }, number: { type: 'integer', description: 'Favorite number', minimum: 1, maximum: 100 }, - things: { + pets: { type: 'string', - enum: ['cats', 'dogs', 'birds', 'brown paper packages tied up with string'], - description: 'Favorite things' + enum: ['cats', 'dogs', 'birds', 'fish', 'reptiles'], + description: 'Favorite pets' }, } } From 0670875117bad66f5e5f2c40fd06854bd3d9306f Mon Sep 17 00:00:00 2001 From: Den Delimarsky Date: Wed, 25 Jun 2025 21:08:24 -0700 Subject: [PATCH 04/10] Remove comments --- src/everything/everything.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/everything/everything.ts b/src/everything/everything.ts index 218b3b3601..bd01e30f56 100644 --- a/src/everything/everything.ts +++ b/src/everything/everything.ts @@ -118,7 +118,7 @@ export const createServer = () => { name: "example-servers/everything", version: "1.0.0", }, - { + { capabilities: { prompts: {}, resources: { subscribe: true }, @@ -216,7 +216,6 @@ export const createServer = () => { return await server.request(request, CreateMessageResultSchema); }; - // Helper method to make elicitation requests const requestElicitation = async ( message: string, requestedSchema: any @@ -682,7 +681,6 @@ export const createServer = () => { if (name === ToolName.ELICITATION_DEMO) { const { message, includeSchema } = ElicitationSchema.parse(args); - // Make the elicitation request like in your example const elicitationResult = await requestElicitation( 'What are your favorite things?', { From ebdfa7d84f62bbf813e8a871d36620350399b661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Den=20Delimarsky=20=E2=9A=A1?= Date: Mon, 30 Jun 2025 14:27:57 -0700 Subject: [PATCH 05/10] Update src/everything/everything.ts Co-authored-by: Ola Hungerford --- src/everything/everything.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/everything/everything.ts b/src/everything/everything.ts index bd01e30f56..1f2dfa30b8 100644 --- a/src/everything/everything.ts +++ b/src/everything/everything.ts @@ -486,7 +486,7 @@ export const createServer = () => { }, { name: ToolName.ELICITATION_DEMO, - description: "Demonstrates the elicitation feature", + description: "Demonstrates the Elicitation feature by asking the user to provide information about their favorite color, number, and pets.", inputSchema: zodToJsonSchema(ElicitationSchema) as ToolInput, }, ]; From dacaf27d5aca2c3ff86ce89b08545d27d1c7b9e5 Mon Sep 17 00:00:00 2001 From: Den Delimarsky Date: Thu, 3 Jul 2025 11:40:05 -0700 Subject: [PATCH 06/10] Update README --- src/everything/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/everything/README.md b/src/everything/README.md index 261ce03374..dd69c23121 100644 --- a/src/everything/README.md +++ b/src/everything/README.md @@ -72,6 +72,14 @@ This MCP server attempts to exercise all the features of the MCP protocol. It is - Embedded resource with `type: "resource"` - Text instruction for using the resource URI +9. `elicitationDemo` + - Initiates an elicitation (interaction) within the MCP client. + - Inputs: + - `color` (string): Favorite color + - `number` (number, 1-100): Favorite number + - `pets` (enum): Favorite pet + - Returns: Confirmation of the elicitation demo with selection summary. + ### Resources The server provides 100 test resources in two formats: From 2de214f36a22fdb06407dddef68a552daa8642e9 Mon Sep 17 00:00:00 2001 From: Den Delimarsky Date: Thu, 3 Jul 2025 21:03:10 -0700 Subject: [PATCH 07/10] Some consistency changes --- src/everything/README.md | 2 +- src/everything/everything.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/everything/README.md b/src/everything/README.md index dd69c23121..3ab3299a9c 100644 --- a/src/everything/README.md +++ b/src/everything/README.md @@ -72,7 +72,7 @@ This MCP server attempts to exercise all the features of the MCP protocol. It is - Embedded resource with `type: "resource"` - Text instruction for using the resource URI -9. `elicitationDemo` +9. `startElicitation` - Initiates an elicitation (interaction) within the MCP client. - Inputs: - `color` (string): Favorite color diff --git a/src/everything/everything.ts b/src/everything/everything.ts index 1f2dfa30b8..72d66bcd13 100644 --- a/src/everything/everything.ts +++ b/src/everything/everything.ts @@ -86,7 +86,7 @@ const GetResourceReferenceSchema = z.object({ .describe("ID of the resource to reference (1-100)"), }); -const ElicitationSchema = z.object({ +const itationSchema = z.object({ message: z.string().describe("Message to use for elicitation"), includeSchema: z .boolean() @@ -103,7 +103,7 @@ enum ToolName { GET_TINY_IMAGE = "getTinyImage", ANNOTATED_MESSAGE = "annotatedMessage", GET_RESOURCE_REFERENCE = "getResourceReference", - ELICITATION_DEMO = "elicitationDemo", + ELICITATION = "startElicitation", } enum PromptName { @@ -485,7 +485,7 @@ export const createServer = () => { inputSchema: zodToJsonSchema(GetResourceReferenceSchema) as ToolInput, }, { - name: ToolName.ELICITATION_DEMO, + name: ToolName.ELICITATION, description: "Demonstrates the Elicitation feature by asking the user to provide information about their favorite color, number, and pets.", inputSchema: zodToJsonSchema(ElicitationSchema) as ToolInput, }, @@ -678,7 +678,7 @@ export const createServer = () => { return { content }; } - if (name === ToolName.ELICITATION_DEMO) { + if (name === ToolName.ELICITATION) { const { message, includeSchema } = ElicitationSchema.parse(args); const elicitationResult = await requestElicitation( From 11195cf3ffeb9f980b813791af69503074ab2ec2 Mon Sep 17 00:00:00 2001 From: Den Delimarsky Date: Thu, 3 Jul 2025 22:14:44 -0700 Subject: [PATCH 08/10] Update schema --- src/everything/everything.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/everything/everything.ts b/src/everything/everything.ts index 72d66bcd13..f3d12f765f 100644 --- a/src/everything/everything.ts +++ b/src/everything/everything.ts @@ -86,7 +86,7 @@ const GetResourceReferenceSchema = z.object({ .describe("ID of the resource to reference (1-100)"), }); -const itationSchema = z.object({ +const ElicitationSchema = z.object({ message: z.string().describe("Message to use for elicitation"), includeSchema: z .boolean() From d63329ded2e6eb3c6199baebcecfada70238e041 Mon Sep 17 00:00:00 2001 From: Den Delimarsky Date: Sat, 5 Jul 2025 11:44:05 -0700 Subject: [PATCH 09/10] Updated based on PR feedback --- src/everything/everything.ts | 56 +++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/src/everything/everything.ts b/src/everything/everything.ts index f3d12f765f..68e485e068 100644 --- a/src/everything/everything.ts +++ b/src/everything/everything.ts @@ -86,13 +86,7 @@ const GetResourceReferenceSchema = z.object({ .describe("ID of the resource to reference (1-100)"), }); -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"), -}); +const ElicitationSchema = z.object({}); enum ToolName { ECHO = "echo", @@ -679,7 +673,7 @@ export const createServer = () => { } if (name === ToolName.ELICITATION) { - const { message, includeSchema } = ElicitationSchema.parse(args); + ElicitationSchema.parse(args); const elicitationResult = await requestElicitation( 'What are your favorite things?', @@ -697,18 +691,40 @@ export const createServer = () => { } ); - return { - content: [ - { - type: "text", - text: `Elicitation demo completed! Message: ${message}`, - }, - { - type: "text", - text: `Elicitation result: ${JSON.stringify(elicitationResult, null, 2)}`, - }, - ], - }; + // Handle different response actions + const content = []; + + if (elicitationResult.action === 'accept' && elicitationResult.content) { + content.push({ + type: "text", + text: `✅ User provided their favorite things!`, + }); + + // 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}`); From a83c56256ef217fb895fc16f356e604562c4922c Mon Sep 17 00:00:00 2001 From: Den Delimarsky Date: Sun, 6 Jul 2025 21:18:43 -0700 Subject: [PATCH 10/10] Fix content return --- src/everything/everything.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/everything/everything.ts b/src/everything/everything.ts index c9d3b09688..b1f6950b0e 100644 --- a/src/everything/everything.ts +++ b/src/everything/everything.ts @@ -739,6 +739,8 @@ export const createServer = () => { type: "text", text: `\nRaw result: ${JSON.stringify(elicitationResult, null, 2)}`, }); + + return { content }; } if (name === ToolName.GET_RESOURCE_LINKS) {