Skip to content

completion/complete is gated on the prompts capability instead of completions #845

Description

@rea9r

Describe the bug

Client.assertCapabilityForMethod gates completion/complete (CompletionComplete) on the server's prompts capability instead of completions. A server that declares completions but not prompts therefore cannot be used for completion.

Affected version: 0.13.0 / main.

To Reproduce

Steps to reproduce the behavior:

  1. Connect a Client (default options) to a server whose initialize response declares completions (and resources) but not prompts.
  2. Send a completion request:
val request = buildCompleteRequest {
    ref(ResourceTemplateReference("db://{table}/{id}"))
    argument("table", "user")
}
client.complete(request)
// throws IllegalStateException: "Server does not support prompts (required for CompletionComplete)"

Such a server is a legitimate configuration: completion also serves resource-template URIs (ref/resource), not only prompt arguments.

Expected behavior

completion/complete is gated on the server's completions capability: a server that declares completions (regardless of prompts) can be used for completion, and a server without completions is rejected.

Additional context

In Client.kt, CompletionComplete is grouped with PromptsGet / PromptsList and checked against serverCapabilities?.prompts, while completions is a separate capability in ServerCapabilities. The TypeScript SDK gates this method on completions in its own case.

A minimal fix gates completion/complete on completions, with a regression test. PR to follow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions