@@ -422,13 +422,13 @@ public async Task<McpGatewayInvokeResult> InvokeAsync(
422422
423423 if ( ! string . IsNullOrWhiteSpace ( request . Query ) &&
424424 ! arguments . ContainsKey ( QueryArgumentName ) &&
425- entry . Descriptor . RequiredArguments . Contains ( QueryArgumentName , StringComparer . OrdinalIgnoreCase ) )
425+ SupportsArgument ( entry . Descriptor , QueryArgumentName ) )
426426 {
427427 arguments [ QueryArgumentName ] = request . Query ;
428428 }
429429
430- MapRequestArgument ( arguments , entry . Descriptor . RequiredArguments , ContextArgumentName , request . Context ) ;
431- MapRequestArgument ( arguments , entry . Descriptor . RequiredArguments , ContextSummaryArgumentName , request . ContextSummary ) ;
430+ MapRequestArgument ( arguments , entry . Descriptor , ContextArgumentName , request . Context ) ;
431+ MapRequestArgument ( arguments , entry . Descriptor , ContextSummaryArgumentName , request . ContextSummary ) ;
432432
433433 try
434434 {
@@ -948,13 +948,13 @@ private static void AppendJsonElementTerms(List<string> terms, string key, JsonE
948948
949949 private static void MapRequestArgument (
950950 IDictionary < string , object ? > arguments ,
951- IReadOnlyList < string > requiredArguments ,
951+ McpGatewayToolDescriptor descriptor ,
952952 string argumentName ,
953953 object ? value )
954954 {
955955 if ( value is null ||
956956 arguments . ContainsKey ( argumentName ) ||
957- ! requiredArguments . Contains ( argumentName , StringComparer . OrdinalIgnoreCase ) )
957+ ! SupportsArgument ( descriptor , argumentName ) )
958958 {
959959 return ;
960960 }
@@ -967,6 +967,39 @@ private static void MapRequestArgument(
967967 arguments [ argumentName ] = value ;
968968 }
969969
970+ private static bool SupportsArgument (
971+ McpGatewayToolDescriptor descriptor ,
972+ string argumentName )
973+ {
974+ if ( descriptor . RequiredArguments . Contains ( argumentName , StringComparer . OrdinalIgnoreCase ) )
975+ {
976+ return true ;
977+ }
978+
979+ if ( string . IsNullOrWhiteSpace ( descriptor . InputSchemaJson ) )
980+ {
981+ return false ;
982+ }
983+
984+ try
985+ {
986+ using var schemaDocument = JsonDocument . Parse ( descriptor . InputSchemaJson ) ;
987+ if ( ! schemaDocument . RootElement . TryGetProperty ( "properties" , out var properties ) ||
988+ properties . ValueKind != JsonValueKind . Object )
989+ {
990+ return false ;
991+ }
992+
993+ return properties
994+ . EnumerateObject ( )
995+ . Any ( property => string . Equals ( property . Name , argumentName , StringComparison . OrdinalIgnoreCase ) ) ;
996+ }
997+ catch ( JsonException )
998+ {
999+ return false ;
1000+ }
1001+ }
1002+
9701003 private static McpClientTool AttachInvocationMeta ( McpClientTool tool , McpGatewayInvokeRequest request )
9711004 {
9721005 var meta = BuildInvocationMeta ( request ) ;
@@ -1039,12 +1072,7 @@ private static double CalculateLexicalScore(
10391072 return 0d ;
10401073 }
10411074
1042- var corpus = BuildSearchTerms ( string . Join (
1043- " " ,
1044- entry . Descriptor . ToolName ,
1045- entry . Descriptor . DisplayName ,
1046- entry . Descriptor . Description ,
1047- entry . Descriptor . SourceId ) ) ;
1075+ var corpus = BuildSearchTerms ( entry . Document ) ;
10481076
10491077 var score = 0d ;
10501078 foreach ( var term in searchTerms )
0 commit comments