mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-17 23:53:24 +02:00
[WIP] Refactor everything server to be more modular and use recommended APIs.
Adding Trigger Elicitation Request and Get Roots List tools
* Updated architecture.md
* Added roots.ts
- tracks roots by sessionId
- setRootsListChangedHandler
- listens for roots changed notification from the client
- updates the roots map by sessionId
- sends log notification or error to the client
* In server/index.ts
- import setRootsListChangedHandler
- in clientConnected callback
- call setRootsListChangedHandler passing server and sessionId
* In sse.ts, stdio.ts, and streamableHttp.ts
- receive clientConnected from server factory
- call clientConnected when server is connected to transport
* Added get-roots-list.ts
- registerGetRootsListTool
- Registers the 'get-roots-list' tool with the given MCP server.
* Added trigger-elicitation-request.ts
- registerTriggerElicitationRequestTool
- registered tool sends an elicitation request that exercises all supported field types
* In tools/index.ts
- imports registerTriggerElicitationRequestTool and registerGetRootsListTool
- in registerTools
- call registerTriggerElicitationRequestTool and registerGetRootsListTool, passing server
This commit is contained in:
@@ -39,110 +39,122 @@ export const registerTriggerElicitationRequestTool = (server: McpServer) => {
|
||||
params: {
|
||||
message: "Please provide inputs for the following fields:",
|
||||
requestedSchema: {
|
||||
type: 'object',
|
||||
type: "object",
|
||||
properties: {
|
||||
name: {
|
||||
title: 'String',
|
||||
type: 'string',
|
||||
description: 'Your full, legal name',
|
||||
title: "String",
|
||||
type: "string",
|
||||
description: "Your full, legal name",
|
||||
},
|
||||
check: {
|
||||
title: 'Boolean',
|
||||
type: 'boolean',
|
||||
description: 'Agree to the terms and conditions',
|
||||
title: "Boolean",
|
||||
type: "boolean",
|
||||
description: "Agree to the terms and conditions",
|
||||
},
|
||||
firstLine: {
|
||||
title: 'String with default',
|
||||
type: 'string',
|
||||
description: 'Favorite first line of a story',
|
||||
default: 'It was a dark and stormy night.',
|
||||
title: "String with default",
|
||||
type: "string",
|
||||
description: "Favorite first line of a story",
|
||||
default: "It was a dark and stormy night.",
|
||||
},
|
||||
email: {
|
||||
title: 'String with email format',
|
||||
type: 'string',
|
||||
format: 'email',
|
||||
description: 'Your email address (will be verified, and never shared with anyone else)',
|
||||
title: "String with email format",
|
||||
type: "string",
|
||||
format: "email",
|
||||
description:
|
||||
"Your email address (will be verified, and never shared with anyone else)",
|
||||
},
|
||||
homepage: {
|
||||
type: 'string',
|
||||
format: 'uri',
|
||||
title: 'String with uri format',
|
||||
description: 'Portfolio / personal website',
|
||||
type: "string",
|
||||
format: "uri",
|
||||
title: "String with uri format",
|
||||
description: "Portfolio / personal website",
|
||||
},
|
||||
birthdate: {
|
||||
title: 'String with date format',
|
||||
type: 'string',
|
||||
format: 'date',
|
||||
description: 'Your date of birth',
|
||||
title: "String with date format",
|
||||
type: "string",
|
||||
format: "date",
|
||||
description: "Your date of birth",
|
||||
},
|
||||
integer: {
|
||||
title: 'Integer',
|
||||
type: 'integer',
|
||||
description: 'Your favorite integer (do not give us your phone number, pin, or other sensitive info)',
|
||||
title: "Integer",
|
||||
type: "integer",
|
||||
description:
|
||||
"Your favorite integer (do not give us your phone number, pin, or other sensitive info)",
|
||||
minimum: 1,
|
||||
maximum: 100,
|
||||
default: 42,
|
||||
},
|
||||
number: {
|
||||
title: 'Number in range 1-1000',
|
||||
type: 'number',
|
||||
description: 'Favorite number (there are no wrong answers)',
|
||||
title: "Number in range 1-1000",
|
||||
type: "number",
|
||||
description: "Favorite number (there are no wrong answers)",
|
||||
minimum: 0,
|
||||
maximum: 1000,
|
||||
default: 3.14,
|
||||
},
|
||||
untitledSingleSelectEnum: {
|
||||
type: 'string',
|
||||
title: 'Untitled Single Select Enum',
|
||||
description: 'Choose your favorite friend',
|
||||
enum: ['Monica', 'Rachel', 'Joey', 'Chandler', 'Ross', 'Phoebe'],
|
||||
default: 'Monica'
|
||||
type: "string",
|
||||
title: "Untitled Single Select Enum",
|
||||
description: "Choose your favorite friend",
|
||||
enum: [
|
||||
"Monica",
|
||||
"Rachel",
|
||||
"Joey",
|
||||
"Chandler",
|
||||
"Ross",
|
||||
"Phoebe",
|
||||
],
|
||||
default: "Monica",
|
||||
},
|
||||
untitledMultipleSelectEnum: {
|
||||
type: 'array',
|
||||
title: 'Untitled Multiple Select Enum',
|
||||
description: 'Choose your favorite instruments',
|
||||
type: "array",
|
||||
title: "Untitled Multiple Select Enum",
|
||||
description: "Choose your favorite instruments",
|
||||
minItems: 1,
|
||||
maxItems: 3,
|
||||
items: { type: 'string', enum: ['Guitar', 'Piano', 'Violin', 'Drums', 'Bass'] },
|
||||
default: ['Guitar']
|
||||
items: {
|
||||
type: "string",
|
||||
enum: ["Guitar", "Piano", "Violin", "Drums", "Bass"],
|
||||
},
|
||||
default: ["Guitar"],
|
||||
},
|
||||
titledSingleSelectEnum: {
|
||||
type: 'string',
|
||||
title: 'Titled Single Select Enum',
|
||||
description: 'Choose your favorite hero',
|
||||
type: "string",
|
||||
title: "Titled Single Select Enum",
|
||||
description: "Choose your favorite hero",
|
||||
oneOf: [
|
||||
{ const: 'hero-1', title: 'Superman' },
|
||||
{ const: 'hero-2', title: 'Green Lantern' },
|
||||
{ const: 'hero-3', title: 'Wonder Woman' }
|
||||
{ const: "hero-1", title: "Superman" },
|
||||
{ const: "hero-2", title: "Green Lantern" },
|
||||
{ const: "hero-3", title: "Wonder Woman" },
|
||||
],
|
||||
default: 'hero-1'
|
||||
default: "hero-1",
|
||||
},
|
||||
titledMultipleSelectEnum: {
|
||||
type: 'array',
|
||||
title: 'Titled Multiple Select Enum',
|
||||
description: 'Choose your favorite types of fish',
|
||||
type: "array",
|
||||
title: "Titled Multiple Select Enum",
|
||||
description: "Choose your favorite types of fish",
|
||||
minItems: 1,
|
||||
maxItems: 3,
|
||||
items: {
|
||||
anyOf: [
|
||||
{ const: 'fish-1', title: 'Tuna' },
|
||||
{ const: 'fish-2', title: 'Salmon' },
|
||||
{ const: 'fish-3', title: 'Trout' }
|
||||
]
|
||||
{ const: "fish-1", title: "Tuna" },
|
||||
{ const: "fish-2", title: "Salmon" },
|
||||
{ const: "fish-3", title: "Trout" },
|
||||
],
|
||||
},
|
||||
default: ['fish-1']
|
||||
default: ["fish-1"],
|
||||
},
|
||||
legacyTitledEnum: {
|
||||
type: 'string',
|
||||
title: 'Legacy Titled Single Select Enum',
|
||||
description: 'Choose your favorite type of pet',
|
||||
enum: ['pet-1', 'pet-2', 'pet-3', 'pet-4', 'pet-5'],
|
||||
enumNames: ['Cats', 'Dogs', 'Birds', 'Fish', 'Reptiles'],
|
||||
default: 'pet-1',
|
||||
}
|
||||
type: "string",
|
||||
title: "Legacy Titled Single Select Enum",
|
||||
description: "Choose your favorite type of pet",
|
||||
enum: ["pet-1", "pet-2", "pet-3", "pet-4", "pet-5"],
|
||||
enumNames: ["Cats", "Dogs", "Birds", "Fish", "Reptiles"],
|
||||
default: "pet-1",
|
||||
},
|
||||
},
|
||||
required: ['name'],
|
||||
required: ["name"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user