Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 49 additions & 3 deletions src/everything/everything.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
CompleteRequestSchema,
CreateMessageRequest,
CreateMessageResultSchema,
ElicitRequest,
ElicitResultSchema,
GetPromptRequestSchema,
ListPromptsRequestSchema,
ListResourcesRequestSchema,
Expand Down Expand Up @@ -66,7 +68,7 @@ const EXAMPLE_COMPLETIONS = {
resourceId: ["1", "2", "3", "4", "5"],
};

const GetTinyImageSchema = z.object({});
const NoArgSchema = z.object({});

const AnnotatedMessageSchema = z.object({
messageType: z
Expand All @@ -92,6 +94,7 @@ enum ToolName {
LONG_RUNNING_OPERATION = "longRunningOperation",
PRINT_ENV = "printEnv",
SAMPLE_LLM = "sampleLLM",
ELICITATION = "elicitationRequest",
GET_TINY_IMAGE = "getTinyImage",
ANNOTATED_MESSAGE = "annotatedMessage",
GET_RESOURCE_REFERENCE = "getResourceReference",
Expand Down Expand Up @@ -206,6 +209,36 @@ export const createServer = () => {
return await server.request(request, CreateMessageResultSchema);
};

// Helper method to elicitation user input from client
const elicitUserInput = async () => {
const request: ElicitRequest = {
"method": "elicitation/create",
"params": {
"message": "Describe your upcoming travel plans.",
"requestedSchema": {
"type": "object",
"properties": {
"destination": {
"type": "string",
"description": "Your travel destination"
},
"distance": {
"type": "number",
"description": "Distance you expect to travel in miles"
},
"mixtape": {
"type": "string",
"description": "Name of mixtape you plan to listen to on the way"
}
},
"required": ["destination", "distance"]
}
}
};

return await server.request(request, ElicitResultSchema);
};

const ALL_RESOURCES: Resource[] = Array.from({ length: 100 }, (_, i) => {
const uri = `test://static/resource/${i + 1}`;
if (i % 2 === 0) {
Expand Down Expand Up @@ -442,10 +475,15 @@ export const createServer = () => {
description: "Samples from an LLM using MCP's sampling feature",
inputSchema: zodToJsonSchema(SampleLLMSchema) as ToolInput,
},
{
name: ToolName.ELICITATION,
description: "Elicits input from the user",
inputSchema: zodToJsonSchema(NoArgSchema) as ToolInput,
},
{
name: ToolName.GET_TINY_IMAGE,
description: "Returns the MCP_TINY_IMAGE",
inputSchema: zodToJsonSchema(GetTinyImageSchema) as ToolInput,
inputSchema: zodToJsonSchema(NoArgSchema) as ToolInput,
},
{
name: ToolName.ANNOTATED_MESSAGE,
Expand Down Expand Up @@ -547,8 +585,16 @@ export const createServer = () => {
};
}

if (name === ToolName.ELICITATION) {
const result = await elicitUserInput();
return {
content: [
{ type: "text", text: `Traveling ${result?.content?.distance} miles to ${result?.content?.destination}, listening to ${result?.content?.mixtape}` },
],
};
}

if (name === ToolName.GET_TINY_IMAGE) {
GetTinyImageSchema.parse(args);
return {
content: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/everything/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"start:streamableHttp": "node dist/streamableHttp.js"
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.12.0",
"@modelcontextprotocol/sdk": "^1.14.0",
"express": "^4.21.1",
"zod": "^3.23.8",
"zod-to-json-schema": "^3.23.5"
Expand Down