Annotation Interface McpToolListChanged
@Target({METHOD,ANNOTATION_TYPE})
@Retention(RUNTIME)
@Documented
public @interface McpToolListChanged
Annotation for methods that handle tool 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 tools changes on an MCP server. According to the MCP specification,
servers that declare the listChanged capability will send notifications when
their tool 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.Tool> that represents the updated list of
tools after the change notification.
Example usage:
@McpToolListChanged(clients = "test-client")
public void onToolListChanged(List<McpSchema.Tool> updatedTools) {
// Handle tool list change notification with the updated tools
logger.info("Tool list updated, now contains {} tools", updatedTools.size());
// Process the updated tool list
}
@McpToolListChanged(clients = "test-client")
public Mono<Void> onToolListChangedAsync(List<McpSchema.Tool> updatedTools) {
// Handle tool list change notification asynchronously
return processUpdatedTools(updatedTools);
}
- Author:
- Christian Tzolov
- See Also:
-
Required Element Summary
Required Elements
-
Element Details
-
clients
String[] clientsUsed as connection or client identifier to select the MCP clients that the tool change listener is associated with.- Returns:
- the client identifiers, or empty array to listen to all clients
-