File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -1054,6 +1054,8 @@ public data class Tool(
10541054 val properties : JsonObject = EmptyJsonObject ,
10551055 val required : List <String >? = null ,
10561056 ) {
1057+ @OptIn(ExperimentalSerializationApi ::class )
1058+ @EncodeDefault
10571059 val type: String = " object"
10581060 }
10591061}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package io.modelcontextprotocol.kotlin.sdk
33import io.kotest.assertions.json.shouldEqualJson
44import io.modelcontextprotocol.kotlin.sdk.shared.McpJson
55import kotlinx.serialization.encodeToString
6+ import kotlinx.serialization.json.Json
67import kotlinx.serialization.json.JsonPrimitive
78import kotlinx.serialization.json.buildJsonObject
89import kotlin.test.Test
@@ -54,4 +55,11 @@ class ToolSerializationTest {
5455 assertEquals(expected = getWeatherTool, actual = tool)
5556 }
5657
58+ @Test
59+ fun `should always serialize default value` () {
60+ val json = Json (from = McpJson ) {
61+ encodeDefaults = false
62+ }
63+ json.encodeToString(getWeatherTool) shouldEqualJson getWeatherToolJson
64+ }
5765}
You can’t perform that action at this time.
0 commit comments