File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -1046,13 +1046,16 @@ public data class Tool(
10461046 /* *
10471047 * A JSON object defining the expected parameters for the tool.
10481048 */
1049+ @SerialName(" input_schema" )
10491050 val inputSchema : Input ,
10501051) {
10511052 @Serializable
10521053 public data class Input (
10531054 val properties : JsonObject = EmptyJsonObject ,
10541055 val required : List <String >? = null ,
10551056 ) {
1057+ @OptIn(ExperimentalSerializationApi ::class )
1058+ @EncodeDefault
10561059 val type: String = " object"
10571060 }
10581061}
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