{"record":{"id":"577290c68ac612f8","repo":"spring-projects/spring-ai","slug":"method-cannot-have-more-than-one-completeargument","errorCode":null,"errorMessage":"Method cannot have more than one CompleteArgument parameter: {method} in {class}","messagePattern":"Method cannot have more than one CompleteArgument 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":248,"sourceCode":"\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}\n\t}\n\n\t/**\n\t * Builds the arguments array for invoking the method.\n\t * <p>\n\t * This method constructs an array of arguments based on the method's parameter types\n\t * and the available values (exchange, request, argument).","sourceCodeStart":230,"sourceCodeEnd":266,"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#L230-L266","documentation":"Thrown while validating an @McpComplete-annotated method's signature: validateParameters detected that the method declares more than one parameter typed as the complete-argument type (CompleteArgument). The same duplicate-parameter guard pattern used for other supported types fires here — the argument-binding flag was already set when a second CompleteArgument parameter was encountered, so the framework cannot bind a single completion argument to two parameters.","triggerScenarios":"A method signature includes two parameters assignable to CompleteRequest.CompleteArgument.","commonSituations":"Copy-paste signatures; declaring the argument both directly and inside another wrapper the developer also annotated.","solutions":["Remove the duplicate CompleteArgument parameter, keeping one","Rebuild the callback"],"exampleFix":"// before\npublic String complete(CompleteArgument a1, CompleteArgument a2) { ... }\n// after\npublic String complete(CompleteArgument argument) { ... }","handlingStrategy":"validation","validationCode":"long a = Arrays.stream(m.getParameterTypes()).filter(CompleteRequest.CompleteArgument.class::isAssignableFrom).count();\nif (a > 1) throw new IllegalStateException(\"Only one CompleteArgument parameter allowed: \" + m);","typeGuard":null,"tryCatchPattern":"try {\n    callbackBuilder.build();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"more than one CompleteArgument\")) { /* keep a single CompleteArgument */ }\n    throw e;\n}","preventionTips":["Declare CompleteArgument at most once; it represents the single value being completed"],"tags":["mcp","method-validation","duplicate-parameter","complete-argument"],"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"}