DroidMcp

class DroidMcp

The SDK entry point. Built via DroidMcp.builder / Builder, it owns a ToolRegistry and both transports: an always-on InProcessTransport for on-device LLMs (listTools / callTool) and an optional HttpTransport for desktop MCP clients (startServer).

Also surfaces the 1.0 hardening controls: runtime per-tool gating (setToolEnabled / setDisabledTools), token rotation (rotateToken), per-client pairing (pairClient / revokeClient / pairedClients), and the TLS fingerprint (tlsFingerprint) to pin in a pairing QR.

Types

Link copied to clipboard
class Builder

Fluent builder for DroidMcp. Add tools, optionally enable the HTTP server, TLS, and an audit sink, then call build. All setters return this for chaining.

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The HTTP server's effective bearer token, or null if the server is disabled or open (no auth).

Link copied to clipboard

SHA-256 fingerprint of the server's TLS certificate to pin in the pairing QR, or null if the server is plaintext. See TlsConfig.certFingerprintSha256.

Functions

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

Invoke a tool directly in-process, bypassing JSON-RPC. Honours runtime gating.

Link copied to clipboard

Names currently gated off.

Link copied to clipboard

Whether the HTTP server is currently running.

Link copied to clipboard

The registered tools as live McpTool instances (in-process).

Link copied to clipboard

The registered tools serialised to a JSON catalogue; see InProcessTransport.listToolsJson.

Link copied to clipboard
fun pairClient(label: String): String?

Mint a revocable token for a named client. Re-pairing an existing label replaces its token. Returns the new token, or null when there's no authenticated HTTP server.

Link copied to clipboard

Snapshot of paired clients (excludes the primary).

Link copied to clipboard

Revoke a paired client's token. @return true if a client with that label existed.

Link copied to clipboard

Rotate the primary bearer token, invalidating the old one (paired clients keep theirs). Returns the new token, or null if the HTTP server is disabled or running without auth. Re-issue the pairing QR after calling.

Link copied to clipboard

Replace the full set of gated-off tools in one call.

Link copied to clipboard
fun setToolEnabled(name: String, enabled: Boolean)

Gate a single tool on or off at runtime. A disabled tool disappears from tools/list and is rejected by tools/call (both transports) without being unregistered, so the host can drive a per-tool checkbox grid without rebuilding the server. No-op for unknown names.

Link copied to clipboard

Start the HTTP server. Throws if the server was not enabled via Builder.enableHttpServer.

Link copied to clipboard

Stop the HTTP server if running; no-op when the server is disabled.