Interface Completions

All Known Subinterfaces:
CompletionRegistry
All Known Implementing Classes:
DefaultCompletionRegistry

public interface Completions
Façade interface for completion/complete providers, keyed by the MCP reference they answer for: a prompt name (ref/prompt) or a resource URI / resource-template URI ( ref/resource, matched verbatim against the URI the client sends — the same string returned by resources/templates/list).

A ref with no registered handler yields an empty completion result rather than an error — the MCP spec does not require completions to be exhaustively declared.

  • Method Details

    • registerForPrompt

      Completions registerForPrompt(String promptName, CompletionFn fn)
      Registers a completion function for a prompt's arguments.
      Parameters:
      promptName - the prompt name, as declared in its PromptDescriptor
      fn - the completion function
      Returns:
      this registry
    • registerForPromptAsync

      Completions registerForPromptAsync(String promptName, AsyncCompletionFn fn)
      Registers an asynchronous completion function for a prompt's arguments.
      Parameters:
      promptName - the prompt name
      fn - the asynchronous completion function
      Returns:
      this registry
    • registerForResource

      Completions registerForResource(String uriOrTemplate, CompletionFn fn)
      Registers a completion function for a resource or resource-template's variables.
      Parameters:
      uriOrTemplate - the resource URI, or the resource template's uriTemplate
      fn - the completion function
      Returns:
      this registry
    • registerForResourceAsync

      Completions registerForResourceAsync(String uriOrTemplate, AsyncCompletionFn fn)
      Registers an asynchronous completion function for a resource or resource-template's variables.
      Parameters:
      uriOrTemplate - the resource URI, or the resource template's uriTemplate
      fn - the asynchronous completion function
      Returns:
      this registry
    • unregisterForPrompt

      boolean unregisterForPrompt(String promptName)
      Removes the completion function registered for the specified prompt name.
      Parameters:
      promptName - the prompt name
      Returns:
      true if a function was removed, false otherwise
    • unregisterForResource

      boolean unregisterForResource(String uriOrTemplate)
      Removes the completion function registered for the specified resource URI or template.
      Parameters:
      uriOrTemplate - the resource URI or template
      Returns:
      true if a function was removed, false otherwise