McpProtocolImpl

class McpProtocolImpl(registry: ToolRegistry, serverName: String = "droid-mcp", serverVersion: String = DROID_MCP_VERSION, readOnly: Boolean = false, auditSink: AuditSink? = null) : McpProtocol

The default McpProtocol implementation: a JSON-RPC 2.0 handler over a ToolRegistry. Services initialize, tools/list, tools/call, ping, and notifications/initialized. Malformed input yields a -32700 parse error and an unknown method a -32601; the handler never throws back to the transport.

Honours readOnly mode (filters tools/list to read-only tools and rejects mutating tools/calls with an isError content payload) and emits a ToolCallAudit to auditSink after every call — a failing sink is swallowed so it can never break a tool call.

Constructors

Link copied to clipboard
constructor(registry: ToolRegistry, serverName: String = "droid-mcp", serverVersion: String = DROID_MCP_VERSION, readOnly: Boolean = false, auditSink: AuditSink? = null)

Functions

Link copied to clipboard
open suspend override fun handleMessage(jsonRequest: String): String

Handle one JSON-RPC request and return the JSON-RPC response string.

open suspend override fun handleMessage(jsonRequest: String, clientLabel: String?): String

Handle a message attributing any tools/call to clientLabel for audit. Defaults to the unattributed form for implementations that don't audit.