new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

MCP · Building servers and clients · all subjects

client: kotlin

3 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Kotlin MCP client: StdioClientTransport over a spawned process

The Kotlin SDK client is created as `Client(clientInfo = Implementation(name = "mcp-client-cli", version = "1.0.0"))`. You spawn the server yourself with `ProcessBuilder(command).start()` and wire a `StdioClientTransport(input = process.inputStream.asSource().buffered(), output = process.outputStream.asSink().buffered())`, then `mcp.connect(transport)`. Cleanup must call `mcp.close()` and `serverProcess?.destroy()`. Dependency: `io.modelcontextprotocol:kotlin-sdk` (e.g. 0.9.0), JDK 11+.

Kotlin callTool signature and result filtering

In the Kotlin SDK, tools are called as `mcp.callTool(name = toolName, arguments = toolArgs ?: emptyMap())` and the result's content is filtered with `result.content.filterIsInstance<TextContent>().joinToString("\n") { it.text }`. Tool metadata exposes `tool.name`, `tool.description` (nullable) and `tool.inputSchema` with `.type`, `.properties` and `.required`.

Kotlin MCP server: Server, ServerCapabilities and addTool

In Kotlin (kotlin-sdk 0.9.0, JDK 11+), create `Server(Implementation(name = "weather", version = "1.0.0"), ServerOptions(capabilities = ServerCapabilities(tools = ServerCapabilities.Tools(listChanged = true))))`. Register tools with `server.addTool(name = ..., description = ..., inputSchema = ToolSchema(properties = buildJsonObject { ... }, required = listOf("state")))` and return `CallToolResult(content = listOf(TextContent(...)))`. Arguments arrive as JSON: `request.arguments?.get("state")?.jsonPrimitive?.content`.

Give your agent this brain