McpTool

interface McpTool

The contract every droid-mcp tool implements. A tool is a single, self-describing capability — its name, description, and parameters are surfaced verbatim through MCP tools/list, and execute services a tools/call.

Tools are collected by a module's provider object (e.g. CalendarTools.all(context)) and registered into a ToolRegistry. They are invoked off the main thread (on Dispatchers.IO) and must degrade gracefully — when a required permission is missing or the device lacks a capability, return ToolResult.error rather than throwing.

The wire contract is the name, the parameters (names + types), and the keys of the map returned in ToolResult.data. These are frozen at 1.0; treat renames as breaking.

Properties

Link copied to clipboard

Behavioural hints for clients; defaults to all-false (ToolAnnotations with no hints set).

Link copied to clipboard
abstract val description: String

One-line, human- and LLM-readable summary of what the tool does. Surfaced in tools/list.

Link copied to clipboard
abstract val name: String

Stable, unique tool identifier in snake_case (e.g. read_calendar). Part of the wire contract.

Link copied to clipboard

Declared input parameters, rendered into the tool's JSON Schema inputSchema.

Functions

Link copied to clipboard
abstract suspend fun execute(params: Map<String, Any>): ToolResult

Run the tool. Called on a background dispatcher in response to a tools/call.