Annotation Interface McpPromptListChanged
@Target({METHOD,ANNOTATION_TYPE})
@Retention(RUNTIME)
@Documented
public @interface McpPromptListChanged
Annotation for methods that handle prompt list change notifications from MCP servers.
This annotation is applicable only for MCP clients.
Methods annotated with this annotation are used to listen for notifications when the
list of available prompts changes on an MCP server. According to the MCP specification,
servers that declare the listChanged capability will send notifications when
their prompt list is modified.
The annotated method must have a void return type for synchronous consumers, or can
return Mono<Void> for asynchronous consumers. The method should accept a single
parameter of type List<McpSchema.Prompt> that represents the updated list of
prompts after the change notification.
Example usage:
@McpPromptListChanged(clients = "test-client")
public void onPromptListChanged(List<McpSchema.Prompt> updatedPrompts) {
// Handle prompt list change notification with the updated prompts
logger.info("Prompt list updated, now contains {} prompts", updatedPrompts.size());
// Process the updated prompt list
}
@McpPromptListChanged(clients = "test-client")
public Mono<Void> onPromptListChangedAsync(List<McpSchema.Prompt> updatedPrompts) {
// Handle prompt list change notification asynchronously
return processUpdatedPrompts(updatedPrompts);
}
- Author:
- Christian Tzolov
- See Also:
-
Required Element Summary
Required Elements
-
Element Details
-
clients
String[] clientsUsed as connection or client identifier to select the MCP client that the prompt change listener is associated with. At least one client identifier must be specified.- Returns:
- the client identifier, or empty string to listen to all clients
-