File tree Expand file tree Collapse file tree
packages/server/src/server Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ import type {
3636import {
3737 CallToolRequestSchema ,
3838 CallToolResultSchema ,
39+ ClientCapabilitiesSchema ,
3940 CreateMessageResultSchema ,
4041 CreateMessageResultWithToolsSchema ,
4142 ElicitResultSchema ,
@@ -144,7 +145,13 @@ export class Server extends Protocol<ServerContext> {
144145 const sendOpts = ( options ?: RequestOptions ) : RequestOptions => ( { ...options , relatedRequestId : ctx . mcpReq . id } ) ;
145146 // SEP-2575: prefer per-request peer scope (lifted from `_meta` by S4) over the
146147 // singleton handshake state. Falls back to the singleton for the connect() path.
147- const reqCaps = ctx . mcpReq . clientCapabilities ?? this . _clientCapabilities ;
148+ // Normalize the per-request value: it may arrive raw from a transport adapter
149+ // (e.g. SessionCompat stores `initialize.params.capabilities` off the wire), and
150+ // ElicitationCapabilitySchema's preprocess (e.g. `{}` -> `{form:{}}`) must run
151+ // before the `_elicitInputVia` capability gate reads `caps.elicitation.form`.
152+ const rawReqCaps = ctx . mcpReq . clientCapabilities ;
153+ const reqCaps =
154+ rawReqCaps === undefined ? this . _clientCapabilities : ( ClientCapabilitiesSchema . safeParse ( rawReqCaps ) . data ?? rawReqCaps ) ;
148155 const reqLogLevel = ctx . mcpReq . logLevel ;
149156 return {
150157 ...ctx ,
You can’t perform that action at this time.
0 commit comments