Merge pull request #2641 from cliffhall/conditional-elicitation-tool

Make presence of `startElicitation` tool conditional on client support
This commit is contained in:
Ola Hungerford 2025-08-28 11:27:59 -07:00 • committed by GitHub
commit 9feeb51009
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 14 deletions

9
package-lock.json generated
View file

@ -5818,7 +5818,7 @@
"version": "0.6.2", "version": "0.6.2",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@modelcontextprotocol/sdk": "^1.12.0", "@modelcontextprotocol/sdk": "^1.17.4",
"express": "^4.21.1", "express": "^4.21.1",
"zod": "^3.23.8", "zod": "^3.23.8",
"zod-to-json-schema": "^3.23.5" "zod-to-json-schema": "^3.23.5"
@ -5833,9 +5833,9 @@
} }
}, },
"src/everything/node_modules/@modelcontextprotocol/sdk": { "src/everything/node_modules/@modelcontextprotocol/sdk": {
"version": "1.12.3", "version": "1.17.4",
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.12.3.tgz", "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.17.4.tgz",
"integrity": "sha512-DyVYSOafBvk3/j1Oka4z5BWT8o4AFmoNyZY9pALOm7Lh3GZglR71Co4r4dEUoqDWdDazIZQHBe7J2Nwkg6gHgQ==", "integrity": "sha512-zq24hfuAmmlNZvik0FLI58uE5sriN0WWsQzIlYnzSuKDAHFqJtBFrl/LfB1NLgJT5Y7dEBzaX4yAKqOPrcetaw==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"ajv": "^6.12.6", "ajv": "^6.12.6",
@ -5843,6 +5843,7 @@
"cors": "^2.8.5", "cors": "^2.8.5",
"cross-spawn": "^7.0.5", "cross-spawn": "^7.0.5",
"eventsource": "^3.0.2", "eventsource": "^3.0.2",
"eventsource-parser": "^3.0.0",
"express": "^5.0.1", "express": "^5.0.1",
"express-rate-limit": "^7.5.0", "express-rate-limit": "^7.5.0",
"pkce-challenge": "^5.0.0", "pkce-challenge": "^5.0.0",

View file

@ -164,8 +164,7 @@ export const createServer = () => {
resources: { subscribe: true }, resources: { subscribe: true },
tools: {}, tools: {},
logging: {}, logging: {},
completions: {}, completions: {}
elicitation: {},
}, },
instructions instructions
} }
@ -177,7 +176,7 @@ export const createServer = () => {
let logLevel: LoggingLevel = "debug"; let logLevel: LoggingLevel = "debug";
let logsUpdateInterval: NodeJS.Timeout | undefined; let logsUpdateInterval: NodeJS.Timeout | undefined;
// Store client capabilities // Store client capabilities
let clientCapabilities: ClientCapabilities | undefined; let clientCapabilities: ClientCapabilities | undefined;
// Roots state management // Roots state management
@ -523,11 +522,6 @@ export const createServer = () => {
"Returns a resource reference that can be used by MCP clients", "Returns a resource reference that can be used by MCP clients",
inputSchema: zodToJsonSchema(GetResourceReferenceSchema) as ToolInput, inputSchema: zodToJsonSchema(GetResourceReferenceSchema) as ToolInput,
}, },
{
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,
},
{ {
name: ToolName.GET_RESOURCE_LINKS, name: ToolName.GET_RESOURCE_LINKS,
description: description:
@ -548,7 +542,12 @@ export const createServer = () => {
"Lists the current MCP roots provided by the client. Demonstrates the roots protocol capability even though this server doesn't access files.", "Lists the current MCP roots provided by the client. Demonstrates the roots protocol capability even though this server doesn't access files.",
inputSchema: zodToJsonSchema(ListRootsSchema) as ToolInput, inputSchema: zodToJsonSchema(ListRootsSchema) as ToolInput,
}); });
if (clientCapabilities!.elicitation) tools.push ({
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,
});
return { tools }; return { tools };
}); });

View file

@ -22,7 +22,7 @@
"start:streamableHttp": "node dist/streamableHttp.js" "start:streamableHttp": "node dist/streamableHttp.js"
}, },
"dependencies": { "dependencies": {
"@modelcontextprotocol/sdk": "^1.12.0", "@modelcontextprotocol/sdk": "^1.17.4",
"express": "^4.21.1", "express": "^4.21.1",
"zod": "^3.23.8", "zod": "^3.23.8",
"zod-to-json-schema": "^3.23.5" "zod-to-json-schema": "^3.23.5"