@@ -135,8 +135,8 @@ public List<String> generateMcpDefinitionMethod(boolean kt) {
135135 indent (6 ), "var req = schema.putArray(" , string ("required" ), ")" , semicolon (kt )));
136136 }
137137
138- for (MvcParameter param : getParameters (false )) {
139- String type = param .getType ().getRawType ().toString ();
138+ for (var param : getParameters (true )) {
139+ var type = param .getType ().getRawType ().toString ();
140140 if (type .equals ("io.modelcontextprotocol.server.McpSyncServerExchange" )
141141 || type .equals ("io.jooby.Context" )) continue ;
142142
@@ -290,13 +290,13 @@ public List<String> generateMcpDefinitionMethod(boolean kt) {
290290 semicolon (kt )));
291291 }
292292
293- for (MvcParameter param : getParameters (false )) {
294- String type = param .getType ().getRawType ().toString ();
293+ for (var param : getParameters (true )) {
294+ var type = param .getType ().getRawType ().toString ();
295295 if (type .equals ("io.modelcontextprotocol.server.McpSyncServerExchange" )
296296 || type .equals ("io.jooby.Context" )) continue ;
297297
298- String mcpName = param .getMcpName ();
299- boolean isRequired = !param .isNullable (kt );
298+ var mcpName = param .getMcpName ();
299+ var isRequired = !param .isNullable (kt );
300300
301301 if (kt ) {
302302 buffer .add (
@@ -343,13 +343,13 @@ public List<String> generateMcpDefinitionMethod(boolean kt) {
343343 buffer .add (statement (indent (4 ), "}\n " ));
344344
345345 } else if (isMcpResource () || isMcpResourceTemplate ()) {
346- String uri = extractAnnotationValue ("io.jooby.annotation.McpResource" , "value" );
347- String name = extractAnnotationValue ("io.jooby.annotation.McpResource" , "name" );
346+ var uri = extractAnnotationValue ("io.jooby.annotation.McpResource" , "value" );
347+ var name = extractAnnotationValue ("io.jooby.annotation.McpResource" , "name" );
348348 if (name .isEmpty ()) name = getMethodName ();
349- String description = extractAnnotationValue ("io.jooby.annotation.McpResource" , "description" );
349+ var description = extractAnnotationValue ("io.jooby.annotation.McpResource" , "description" );
350350
351- boolean isTemplate = isMcpResourceTemplate ();
352- String specType = isTemplate ? "ResourceTemplate" : "Resource" ;
351+ var isTemplate = isMcpResourceTemplate ();
352+ var specType = isTemplate ? "ResourceTemplate" : "Resource" ;
353353
354354 if (kt ) {
355355 buffer .add (
@@ -427,8 +427,6 @@ public List<String> generateMcpDefinitionMethod(boolean kt) {
427427 }
428428
429429 public List <String > generateMcpHandlerMethod (boolean kt ) {
430- List <String > buffer = new ArrayList <>();
431-
432430 String reqType = "" ;
433431 String resType = "" ;
434432 String toMethod = "" ;
@@ -446,9 +444,11 @@ public List<String> generateMcpHandlerMethod(boolean kt) {
446444 resType = "ReadResourceResult" ;
447445 toMethod = "toResourceResult" ;
448446 } else {
449- return buffer ;
447+ return List . of () ;
450448 }
451449
450+ List <String > buffer = new ArrayList <>();
451+
452452 if (kt ) {
453453 buffer .add (
454454 statement (
@@ -544,11 +544,11 @@ public List<String> generateMcpHandlerMethod(boolean kt) {
544544 statement (indent (6 ), kt ? "val " : "var " , "c = this.factory.apply(ctx)" , semicolon (kt )));
545545
546546 List <String > javaParamNames = new ArrayList <>();
547- for (MvcParameter param : getParameters (false )) {
548- String javaName = param .getName ();
549- String mcpName = param .getMcpName ();
550- String type = param .getType ().getRawType ().toString ();
551- boolean isNullable = param .isNullable (kt );
547+ for (var param : getParameters (true )) {
548+ var javaName = param .getName ();
549+ var mcpName = param .getMcpName ();
550+ var type = param .getType ().getRawType ().toString ();
551+ var isNullable = param .isNullable (kt );
552552 javaParamNames .add (javaName );
553553
554554 if (type .equals ("io.jooby.Context" )) {
@@ -642,7 +642,7 @@ public List<String> generateMcpHandlerMethod(boolean kt) {
642642 }
643643 }
644644
645- String methodCall = "c." + getMethodName () + "(" + String .join (", " , javaParamNames ) + ")" ;
645+ var methodCall = "c." + getMethodName () + "(" + String .join (", " , javaParamNames ) + ")" ;
646646
647647 if (getReturnType ().isVoid ()) {
648648 buffer .add (statement (indent (6 ), methodCall , semicolon (kt )));
0 commit comments