@@ -163,6 +163,26 @@ await request.Server.ElicitAsync(new()
163163 throw new McpException ( ex . Message ) ;
164164 }
165165 }
166+ else if ( request . Params . Name == "TestFormElicitationMissingSchema" )
167+ {
168+ try
169+ {
170+ await request . Server . ElicitAsync ( new ( )
171+ {
172+ Message = "Form elicitation without schema should fail." ,
173+ } ,
174+ cancellationToken ) ;
175+ }
176+ catch ( ArgumentException ex )
177+ {
178+ throw new McpException ( ex . Message ) ;
179+ }
180+
181+ return new CallToolResult
182+ {
183+ Content = [ new TextContentBlock { Text = "missing-schema-succeeded" } ] ,
184+ } ;
185+ }
166186
167187 Assert . Fail ( $ "Unexpected tool name: { request . Params . Name } ") ;
168188 return new CallToolResult { Content = [ ] } ;
@@ -506,6 +526,35 @@ public async Task UrlElicitationRequired_Exception_Propagates_To_Client()
506526 Assert . Equal ( "Authorization is required to access Example Co." , elicitation . Message ) ;
507527 }
508528
529+ [ Fact ]
530+ public async Task FormElicitation_Requires_RequestedSchema ( )
531+ {
532+ var elicitationHandlerCalled = false ;
533+
534+ await using McpClient client = await CreateMcpClientForServer ( new McpClientOptions
535+ {
536+ Capabilities = new ClientCapabilities
537+ {
538+ Elicitation = new ( ) ,
539+ } ,
540+ Handlers = new McpClientHandlers ( )
541+ {
542+ ElicitationHandler = ( request , cancellationToken ) =>
543+ {
544+ elicitationHandlerCalled = true ;
545+ return new ValueTask < ElicitResult > ( new ElicitResult ( ) ) ;
546+ } ,
547+ }
548+ } ) ;
549+
550+ var result = await client . CallToolAsync ( "TestFormElicitationMissingSchema" , cancellationToken : TestContext . Current . CancellationToken ) ;
551+
552+ Assert . True ( result . IsError ) ;
553+ var textContent = Assert . IsType < TextContentBlock > ( result . Content [ 0 ] ) ;
554+ Assert . Equal ( "An error occurred invoking 'TestFormElicitationMissingSchema': Form mode elicitation requests require a requested schema." , textContent . Text ) ;
555+ Assert . False ( elicitationHandlerCalled ) ;
556+ }
557+
509558 private ElicitationCapability AssertServerElicitationCapability ( )
510559 {
511560 var capabilities = Server . ClientCapabilities ;
0 commit comments