mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
Pass ClientInfo into MCP call (cherry picked from commit aa91dac054f062664c1eb436e2f7dc6de8dd8e3b) GitOrigin-RevId: 2250cc7cf91b28d3e148f3b15597e94346ce7711
13 lines
562 B
Kotlin
13 lines
562 B
Kotlin
package com.intellij.mcpserver
|
|
|
|
import kotlin.coroutines.CoroutineContext
|
|
|
|
class ClientInfo(val name: String, val version: String)
|
|
|
|
internal class ClientInfoElement(val info: ClientInfo?) : CoroutineContext.Element {
|
|
companion object Key : CoroutineContext.Key<ClientInfoElement>
|
|
override val key: CoroutineContext.Key<*> = Key
|
|
}
|
|
|
|
val CoroutineContext.clientInfoOrNull: ClientInfo? get() = get(ClientInfoElement.Key)?.info
|
|
val CoroutineContext.clientInfo: ClientInfo get() = get(ClientInfoElement.Key)?.info ?: ClientInfo("Unknown client", "Unknown version") |