onResourceContentUpdated method

void onResourceContentUpdated(
  1. dynamic handler(
    1. String uri,
    2. ResourceContents content
    )
)

Register a handler for notifications/resources/updated that carries the new content: the handler gets the resource's URI and its contents. A notification without content (the usual case) does not reach it — use onResourceUpdated for those.

Implementation

void onResourceContentUpdated(
  Function(String uri, ResourceContents content) handler,
) {
  onNotification(McpProtocol.methodResourceUpdated, (params) {
    final uri = params['uri'] as String;
    final contentData = params['content'];
    if (contentData is! Map) return;
    handler(uri, ResourceContents.fromJson(Map<String, Object?>.from(contentData)));
  });
}