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(
1054
1054
val properties : JsonObject = EmptyJsonObject ,
1055
1055
val required : List <String >? = null ,
1056
1056
) {
1057
+ @OptIn(ExperimentalSerializationApi ::class )
1058
+ @EncodeDefault
1057
1059
val type: String = " object"
1058
1060
}
1059
1061
}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package io.modelcontextprotocol.kotlin.sdk
3
3
import io.kotest.assertions.json.shouldEqualJson
4
4
import io.modelcontextprotocol.kotlin.sdk.shared.McpJson
5
5
import kotlinx.serialization.encodeToString
6
+ import kotlinx.serialization.json.Json
6
7
import kotlinx.serialization.json.JsonPrimitive
7
8
import kotlinx.serialization.json.buildJsonObject
8
9
import kotlin.test.Test
@@ -54,4 +55,11 @@ class ToolSerializationTest {
54
55
assertEquals(expected = getWeatherTool, actual = tool)
55
56
}
56
57
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
+ }
57
65
}
You can’t perform that action at this time.
0 commit comments