removeResource method

  1. @override
void removeResource(
  1. String uri
)
override

Remove a resource from the server

Implementation

@override
void removeResource(String uri) {
  if (!_resources.containsKey(uri)) {
    throw McpError('Resource with URI "$uri" does not exist');
  }

  _resources.remove(uri);
  _resourceHandlers.remove(uri);

  // Invalidate cache for this resource
  _resourceCache.remove(uri);

  // Notify clients about resource changes if connected and supported
  if (isConnected && capabilities.hasResources && capabilities.resourcesListChanged) {
    _broadcastNotification('notifications/resources/list_changed', {});
  }

  // Emit change event
  _resourcesChangedController.add(null);
}