Annotation Interface McpResourceListChanged
@Target({METHOD,ANNOTATION_TYPE})
@Retention(RUNTIME)
@Documented
public @interface McpResourceListChanged
Annotation for methods that handle resource 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 resources changes on an MCP server. According to the MCP
specification, servers that declare the listChanged capability will send
notifications when their resource 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.Resource> that represents the updated list of
resources after the change notification.
Example usage:
@McpResourceListChanged(clients = "test-client")
public void onResourceListChanged(List<McpSchema.Resource> updatedResources) {
// Handle resource list change notification with the updated resources
logger.info("Resource list updated, now contains {} resources", updatedResources.size());
// Process the updated resource list
}
@McpResourceListChanged(clients = "test-client")
public Mono<Void> onResourceListChangedAsync(List<McpSchema.Resource> updatedResources) {
// Handle resource list change notification asynchronously
return processUpdatedResources(updatedResources);
}
- 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 resource change listener is associated with.- Returns:
- the client identifier, or empty string to listen to all clients
-