Interface Prompts
- All Known Subinterfaces:
PromptRegistry
- All Known Implementing Classes:
DefaultPromptRegistry
public interface Prompts
Façade interface for MCP prompts
-
Method Summary
Modifier and TypeMethodDescriptionRetrieves all registered prompt descriptors.Finds a registered prompt descriptor by name.register(PromptDescriptor descriptor, PromptFn fn) Registers a prompt descriptor with its synchronous function.default Promptsregister(PromptDescriptor descriptor, List<PromptMessage> messages) Registers a prompt that returns the specified messages for every request.default Promptsregister(Consumer<PromptDescriptor.Builder> configurer, PromptFn fn) Registers a prompt configured through a descriptor builder.default Promptsregister(Consumer<PromptDescriptor.Builder> descriptor, List<PromptMessage> messages) Registers a prompt with a descriptor configured by the supplied consumer and a fixed list of messages.registerAsync(PromptDescriptor descriptor, AsyncPromptFn fn) Registers a prompt with an asynchronous function.default PromptsregisterAsync(Consumer<PromptDescriptor.Builder> descriptor, AsyncPromptFn fn) Registers an asynchronous prompt configured through a descriptor builder.booleanunregister(String name) Removes the registered prompt with the specified name.
-
Method Details
-
register
Registers a prompt descriptor with its synchronous function.- Parameters:
descriptor- the prompt descriptor to registerfn- the prompt function- Returns:
- this registry, or the registry instance resulting from registration
-
register
Registers a prompt configured through a descriptor builder.- Parameters:
configurer- configures the prompt descriptorfn- the prompt function- Returns:
- the prompt registry
-
registerAsync
Registers a prompt with an asynchronous function.- Parameters:
descriptor- the prompt descriptorfn- the asynchronous prompt function- Returns:
- the prompt registry
-
registerAsync
Registers an asynchronous prompt configured through a descriptor builder.- Parameters:
descriptor- the consumer that configures the prompt descriptorfn- 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 promptmessages- 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 descriptormessages- the messages returned by the prompt- Returns:
- this prompt registry
-
unregister
Removes the registered prompt with the specified name.- Parameters:
name- the name of the prompt to remove- Returns:
trueif a registration was removed,falseotherwise
-
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
-