fix(server): return empty completion when handler is absent

This commit is contained in:
King Star 2026-05-30 19:52:24 +08:00 • committed by Daniel Garnier-Moiroux
commit 301f8b06c7
2 changed files with 204 additions and 7 deletions

View file

@ -1090,9 +1090,7 @@ public class McpAsyncServer {
McpServerFeatures.AsyncCompletionSpecification specification = this.completions.get(request.ref());
if (specification == null) {
return Mono.error(McpError.builder(ErrorCodes.INVALID_PARAMS)
.message("AsyncCompletionSpecification not found: " + request.ref())
.build());
return EMPTY_COMPLETION_RESULT;
}
return Mono.defer(() -> specification.completionHandler().apply(exchange, request));

View file

@ -815,9 +815,7 @@ public class McpStatelessAsyncServer {
McpStatelessServerFeatures.AsyncCompletionSpecification specification = this.completions.get(request.ref());
if (specification == null) {
return Mono.error(McpError.builder(ErrorCodes.INVALID_PARAMS)
.message("AsyncCompletionSpecification not found: " + request.ref())
.build());
return EMPTY_COMPLETION_RESULT;
}
return specification.completionHandler().apply(ctx, request);