addResourceTemplate

Registers a resource template. Clients can discover it via resources/templates/list and read matching URIs via resources/read.

Parameters

template

The ResourceTemplate describing the URI template pattern.

readHandler

A suspend function invoked when a client reads a URI that matches the template. The second parameter contains the URI variables extracted from the match.

Throws

If the server does not support resources.


fun addResourceTemplate(uriTemplate: String, name: String, description: String? = null, mimeType: String? = null, readHandler: suspend ClientConnection.(ReadResourceRequest, Map<String, String>) -> ReadResourceResult)(source)

Registers a resource template by constructing a ResourceTemplate from given parameters.

Parameters

uriTemplate

The RFC 6570 URI template string (e.g. "file:///{path}").

name

A human-readable name for the template.

description

A human-readable description of the resource template.

mimeType

The MIME type of resource content served by this template.

readHandler

A suspend function invoked when a client reads a URI that matches the template. The second parameter contains the URI variables extracted from the match.

Throws

If the server does not support resources.