Files
openide/plugins/mcp-server/src/com/intellij/mcpserver/ClientInfo.kt
Artem.Bukhonov b30fa93446 [MCP Server] Support propagation of headers into mcp tool call (to pass a project with headers)
Pass ClientInfo into MCP call

(cherry picked from commit aa91dac054f062664c1eb436e2f7dc6de8dd8e3b)

GitOrigin-RevId: 2250cc7cf91b28d3e148f3b15597e94346ce7711
2025-08-18 13:22:24 +00:00

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")