Skip to content

Commit b0290e8

Browse files
ptitjesdevcrocod
authored andcommitted
Add serialization test for Annotations
1 parent 344db2c commit b0290e8

File tree

1 file changed

+19
-0
lines changed
  • kotlin-sdk-core/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk

1 file changed

+19
-0
lines changed

kotlin-sdk-core/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/TypesTest.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import kotlin.test.assertEquals
66
import kotlin.test.assertIs
77
import kotlin.test.assertNotEquals
88
import kotlin.test.assertTrue
9+
import kotlin.time.ExperimentalTime
10+
import kotlin.time.Instant
911

1012
class TypesTest {
1113

@@ -236,6 +238,23 @@ class TypesTest {
236238
assertEquals("text/x-rust", textResource.mimeType)
237239
}
238240

241+
@OptIn(ExperimentalTime::class)
242+
@Test
243+
fun `should serialize and deserialize annotations correctly`() {
244+
val annotations = Annotations(
245+
audience = listOf(Role.assistant),
246+
lastModified = Instant.parse("2025-06-18T00:00:00Z"),
247+
priority = 0.5,
248+
)
249+
250+
val json = McpJson.encodeToString(annotations)
251+
val decoded = McpJson.decodeFromString<Annotations>(json)
252+
253+
assertEquals(listOf(Role.assistant), decoded.audience)
254+
assertEquals(Instant.parse("2025-06-18T00:00:00Z"), decoded.lastModified)
255+
assertEquals(0.5, decoded.priority)
256+
}
257+
239258
@Test
240259
fun `should serialize and deserialize prompt message correctly`() {
241260
val imageContent = ImageContent(

0 commit comments

Comments
 (0)