ResourceProvider

Supplies resources for one area of the device (photos, files, contacts, …). Registered through DroidMcp.Builder.addResourceProvider; each module exposes its own, e.g. MediaTools.resources(context).

Like McpTool.execute, list and read run on Dispatchers.IO and must not throw for an expected failure: return an empty list, or null from read, instead.

Properties

Link copied to clipboard

Tools whose data this provider serves (e.g. read_contact for contacts). The provider is hidden — not listed, not readable — unless all of them are registered, enabled and visible, so gating a tool off also gates the same data as a resource.

Link copied to clipboard

Templates this provider resolves; advertised by resources/templates/list.

Functions

Link copied to clipboard
open suspend fun complete(uriTemplate: String, argument: String, value: String, context: CompletionContext): List<String>

Suggested values for the argument variable of one of this provider's templates (uriTemplate), given what the user has typed so far (value); MCP completion/complete. Best matches first; the server sends at most 100. Defaults to no suggestions.

Link copied to clipboard
abstract fun handles(uri: String): Boolean

Whether uri belongs to this provider. Checked before read; must be cheap.

Link copied to clipboard
open suspend fun list(): List<McpResource>

Concrete resources to advertise. Keep it bounded (e.g. the most recent items).

Link copied to clipboard
abstract suspend fun read(uri: String): List<ResourceContents>?

The contents at uri, or null when it doesn't exist or can't be read (e.g. a missing permission).