Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/everything/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
63 changes: 63 additions & 0 deletions src/everything/everything.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -95,6 +103,7 @@ enum ToolName {
GET_TINY_IMAGE = "getTinyImage",
ANNOTATED_MESSAGE = "annotatedMessage",
GET_RESOURCE_REFERENCE = "getResourceReference",
ELICITATION_DEMO = "elicitationDemo",
}

enum PromptName {
Expand All @@ -116,6 +125,7 @@ export const createServer = () => {
tools: {},
logging: {},
completions: {},
elicitation: {},
},
instructions
}
Expand Down Expand Up @@ -206,6 +216,21 @@ export const createServer = () => {
return await server.request(request, CreateMessageResultSchema);
};

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) {
Expand Down Expand Up @@ -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 by asking the user to provide information about their favorite color, number, and pets.",
inputSchema: zodToJsonSchema(ElicitationSchema) as ToolInput,
},
];

return { tools };
Expand Down Expand Up @@ -648,6 +678,39 @@ export const createServer = () => {
return { content };
}

if (name === ToolName.ELICITATION_DEMO) {
const { message, includeSchema } = ElicitationSchema.parse(args);

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 },
pets: {
type: 'string',
enum: ['cats', 'dogs', 'birds', 'fish', 'reptiles'],
description: 'Favorite pets'
},
}
}
);

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}`);
});

Expand Down