{"record":{"id":"5bb8eb23d25a4eb4","repo":"spring-projects/spring-ai","slug":"method-cannot-have-more-than-one-completerequest-p","errorCode":null,"errorMessage":"Method cannot have more than one CompleteRequest parameter: {method} in {class}","messagePattern":"Method cannot have more than one CompleteRequest parameter: (.+?) in (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"mcp/mcp-annotations/src/main/java/org/springframework/ai/mcp/annotation/method/complete/AbstractMcpCompleteMethodCallback.java","lineNumber":241,"sourceCode":"\t\t\t\thasRequestContextParam = true;\n\t\t\t}\n\t\t\telse if (McpTransportContext.class.isAssignableFrom(paramType)) {\n\t\t\t\tif (hasTransportContext) {\n\t\t\t\t\tthrow new IllegalArgumentException(\"Method cannot have more than one transport context parameter: \"\n\t\t\t\t\t\t\t+ method.getName() + \" in \" + method.getDeclaringClass().getName());\n\t\t\t\t}\n\t\t\t\thasTransportContext = true;\n\t\t\t}\n\t\t\telse if (isExchangeType(paramType)) {\n\t\t\t\tif (hasExchangeParam) {\n\t\t\t\t\tthrow new IllegalArgumentException(\"Method cannot have more than one exchange parameter: \"\n\t\t\t\t\t\t\t+ method.getName() + \" in \" + method.getDeclaringClass().getName());\n\t\t\t\t}\n\t\t\t\thasExchangeParam = true;\n\t\t\t}\n\t\t\telse if (CompleteRequest.class.isAssignableFrom(paramType)) {\n\t\t\t\tif (hasRequestParam) {\n\t\t\t\t\tthrow new IllegalArgumentException(\"Method cannot have more than one CompleteRequest parameter: \"\n\t\t\t\t\t\t\t+ method.getName() + \" in \" + method.getDeclaringClass().getName());\n\t\t\t\t}\n\t\t\t\thasRequestParam = true;\n\t\t\t}\n\t\t\telse if (CompleteRequest.CompleteArgument.class.isAssignableFrom(paramType)) {\n\t\t\t\tif (hasArgumentParam) {\n\t\t\t\t\tthrow new IllegalArgumentException(\"Method cannot have more than one CompleteArgument parameter: \"\n\t\t\t\t\t\t\t+ method.getName() + \" in \" + method.getDeclaringClass().getName());\n\t\t\t\t}\n\t\t\t\thasArgumentParam = true;\n\t\t\t}\n\t\t\telse if (!String.class.isAssignableFrom(paramType)) {\n\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\t\"Method parameters must be exchange, CompleteRequest, CompleteArgument, or String: \"\n\t\t\t\t\t\t\t\t+ method.getName() + \" in \" + method.getDeclaringClass().getName()\n\t\t\t\t\t\t\t\t+ \" has parameter of type \" + paramType.getName());\n\t\t\t}\n\t\t}","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/mcp/mcp-annotations/src/main/java/org/springframework/ai/mcp/annotation/method/complete/AbstractMcpCompleteMethodCallback.java#L223-L259","documentation":"Thrown while validating an @McpComplete-annotated method's signature: the parameter scan in validateParameters found a second parameter whose type is assignable to CompleteRequest. Each supported parameter type is tracked with a boolean flag (e.g. hasRequestParam), and this guard fires when that flag is already true for a later CompleteRequest-typed parameter — the callback factory cannot decide which of the duplicates should receive the parsed request.","triggerScenarios":"A method signature includes two parameters assignable to CompleteRequest.","commonSituations":"Copy-paste of signatures; adding the request explicitly while an inherited/generated one already exists.","solutions":["Remove the duplicate CompleteRequest parameter, keeping one","Rebuild the callback"],"exampleFix":"// before\npublic String complete(CompleteRequest r1, CompleteRequest r2) { ... }\n// after\npublic String complete(CompleteRequest request) { ... }","handlingStrategy":"validation","validationCode":"long r = Arrays.stream(m.getParameterTypes()).filter(CompleteRequest.class::isAssignableFrom).count();\nif (r > 1) throw new IllegalStateException(\"Only one CompleteRequest parameter allowed: \" + m);","typeGuard":null,"tryCatchPattern":"try {\n    callbackBuilder.build();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"more than one CompleteRequest\")) { /* keep a single CompleteRequest */ }\n    throw e;\n}","preventionTips":["Declare CompleteRequest at most once per completion method","Favor CompleteRequest plus CompleteArgument pair rather than duplicating types"],"tags":["mcp","method-validation","duplicate-parameter","complete-request"],"backgroundTag":"invalid-argument-value","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}