Interface Prompts

All Known Subinterfaces:
PromptRegistry
All Known Implementing Classes:
DefaultPromptRegistry

public interface Prompts
Façade interface for MCP prompts
  • Method Details

    • register

      Prompts register(PromptDescriptor descriptor, PromptFn fn)
      Registers a prompt descriptor with its synchronous function.
      Parameters:
      descriptor - the prompt descriptor to register
      fn - the prompt function
      Returns:
      this registry, or the registry instance resulting from registration
    • register

      default Prompts register(Consumer<PromptDescriptor.Builder> configurer, PromptFn fn)
      Registers a prompt configured through a descriptor builder.
      Parameters:
      configurer - configures the prompt descriptor
      fn - the prompt function
      Returns:
      the prompt registry
    • registerAsync

      Prompts registerAsync(PromptDescriptor descriptor, AsyncPromptFn fn)
      Registers a prompt with an asynchronous function.
      Parameters:
      descriptor - the prompt descriptor
      fn - the asynchronous prompt function
      Returns:
      the prompt registry
    • registerAsync

      default Prompts registerAsync(Consumer<PromptDescriptor.Builder> descriptor, AsyncPromptFn fn)
      Registers an asynchronous prompt configured through a descriptor builder.
      Parameters:
      descriptor - the consumer that configures the prompt descriptor
      fn - the asynchronous function for the prompt
      Returns:
      the prompt registry
    • register

      @ExperimentalApi default Prompts register(PromptDescriptor descriptor, List<PromptMessage> messages)
      Registers a prompt that returns the specified messages for every request.
      Parameters:
      descriptor - the descriptor for the prompt
      messages - the messages returned by the prompt
      Returns:
      this prompt registry
    • register

      @ExperimentalApi default Prompts register(Consumer<PromptDescriptor.Builder> descriptor, List<PromptMessage> messages)
      Registers a prompt with a descriptor configured by the supplied consumer and a fixed list of messages.
      Parameters:
      descriptor - a consumer that configures the prompt descriptor
      messages - the messages returned by the prompt
      Returns:
      this prompt registry
    • unregister

      boolean unregister(String name)
      Removes the registered prompt with the specified name.
      Parameters:
      name - the name of the prompt to remove
      Returns:
      true if a registration was removed, false otherwise
    • find

      Finds a registered prompt descriptor by name.
      Parameters:
      name - the name of the prompt to find
      Returns:
      an optional containing the matching prompt descriptor, or empty if no prompt is registered with that name
    • descriptors

      List<PromptDescriptor> descriptors()
      Retrieves all registered prompt descriptors.
      Returns:
      a list of registered prompt descriptors