ResourceProvider

abstract class ResourceProvider

Provides access to a set of resources and (optionally) notifies about changes.

Subclasses can override supportsSubscriptions to indicate whether they can emit resource change notifications via onResourceChange or onResourcesListChanged.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
var onResourceChange: suspend (uri: String) -> Unit

Implementations should call this when a specific resource changes. By default, no-op.

Link copied to clipboard
var onResourcesListChanged: suspend () -> Unit

Implementations should call this when the overall list of resources changes (new ones added, removed, etc.). By default, no-op.

Link copied to clipboard

Whether this provider can emit resource change notifications.

Functions

Link copied to clipboard
open fun attachCallbacks(onResourceChange: suspend (String) -> Unit, onResourcesListChanged: suspend () -> Unit)

Sets callbacks for resource change notifications. Called by the server/manager.

Link copied to clipboard
open suspend fun listResources(): List<Resource>

Returns the list of currently available resources.

Link copied to clipboard

Returns any resource templates this provider supports, e.g. file:///{path}.

Link copied to clipboard
abstract suspend fun readResource(uri: String): ResourceContents?

Fetches the contents of the given resource URI, or null if unavailable.