fix: Return empty prompt completion result when prompt has no arguments (#934)

Recent changes don't coerce null completion arguments to empty lists so we have
to check for null when handling prompt completions.

Resolves #932

Signed-off-by: Dariusz Jędrzejczyk <2554306+chemicL@users.noreply.github.com>
This commit is contained in:
Dariusz Jędrzejczyk 2026-04-24 14:05:12 +02:00 • committed by GitHub
commit 5895b2edd2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 45 additions and 19 deletions

View file

@ -999,12 +999,9 @@ public class McpAsyncServer {
.message("Prompt not found: " + promptReference.name())
.build());
}
if (!promptSpec.prompt()
.arguments()
.stream()
.filter(arg -> arg.name().equals(argumentName))
.findFirst()
.isPresent()) {
List<McpSchema.PromptArgument> arguments = promptSpec.prompt().arguments();
if (arguments == null
|| !arguments.stream().filter(arg -> arg.name().equals(argumentName)).findFirst().isPresent()) {
logger.warn("Argument not found: {} in prompt: {}", argumentName, promptReference.name());

View file

@ -744,12 +744,9 @@ public class McpStatelessAsyncServer {
.message("Prompt not found: " + promptReference.name())
.build());
}
if (!promptSpec.prompt()
.arguments()
.stream()
.filter(arg -> arg.name().equals(argumentName))
.findFirst()
.isPresent()) {
List<McpSchema.PromptArgument> arguments = promptSpec.prompt().arguments();
if (arguments == null
|| !arguments.stream().filter(arg -> arg.name().equals(argumentName)).findFirst().isPresent()) {
logger.warn("Argument not found: {} in prompt: {}", argumentName, promptReference.name());