Suppress startElicitation tool if client does not advertise support for elicitation capability

* In everything.ts
  - remove inappropriate elicitation entry from server capabilities (this is a client capability)
  - When creating tool list, only add `ToolName.ELICITATION` definition to tools array if `clientCapabilities` includes `elicitation`

* In package.json / package-lock.json
  - bump @modelcontextprotocol/sdk to "^1.17.4", adding `elicitation` to `ClientCapabilities` type
This commit is contained in:
cliffhall
2025-08-28 14:13:47 -04:00
parent d47104ad00
commit a32f15750d
3 changed files with 14 additions and 14 deletions

View File

@@ -164,8 +164,7 @@ export const createServer = () => {
resources: { subscribe: true },
tools: {},
logging: {},
completions: {},
elicitation: {},
completions: {}
},
instructions
}
@@ -177,7 +176,7 @@ export const createServer = () => {
let logLevel: LoggingLevel = "debug";
let logsUpdateInterval: NodeJS.Timeout | undefined;
// Store client capabilities
// Store client capabilities
let clientCapabilities: ClientCapabilities | undefined;
// Roots state management
@@ -523,11 +522,6 @@ export const createServer = () => {
"Returns a resource reference that can be used by MCP clients",
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,
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.",
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 };
});