enableHttpServer

fun enableHttpServer(port: Int = 8080, token: String? = null, requireAuth: Boolean = true, readOnly: Boolean = false, context: Context? = null, allowedOrigins: Set<String> = emptySet()): DroidMcp.Builder

Enable the HTTP transport (Ktor) for desktop MCP clients.

Parameters

port

Plaintext port to bind (ignored when enableTls supplies an HTTPS port).

token

Fixed bearer token; when null and requireAuth is true, one is generated via SecureRandom and exposed as DroidMcp.serverToken.

requireAuth

Require a Bearer token on every request (default true). When false the server is open on the local network.

readOnly

Expose and accept only read-only tools (filters tools/list, rejects mutating tools/call).

context

Android context, used for mDNS service broadcast when available.

allowedOrigins

Browser origins (e.g. "http://localhost:6274" for MCP Inspector) allowed to call the server. Requests carrying any other Origin header are rejected with 403 to block DNS-rebinding and drive-by browser requests; native clients send no Origin and are unaffected.

Throws