Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonNull
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonPrimitive
import kotlin.coroutines.cancellation.CancellationException

/**
* Options for configuring the MCP client.
Expand Down Expand Up @@ -100,7 +101,11 @@ public open class Client(
notification(InitializedNotification())
} catch (error: Throwable) {
close()
throw error
if (error !is CancellationException) {
throw IllegalStateException("Error connecting to transport", error)
} else {
throw error
}
}
}

Expand Down