From de7070f5c3311f6d6ba55eba7e2b688b1cb38285 Mon Sep 17 00:00:00 2001 From: Konstantin Pavlov <1517853+kpavlov@users.noreply.github.com> Date: Mon, 10 Nov 2025 17:35:11 +0200 Subject: [PATCH] Replace `Instant` with `String` for `lastModified` in `Annotations` --- kotlin-sdk-core/api/kotlin-sdk-core.api | 10 +++++----- .../io/modelcontextprotocol/kotlin/sdk/types.kt | 16 ++++++++++++---- .../modelcontextprotocol/kotlin/sdk/TypesTest.kt | 5 ++--- .../server/WebSocketMcpKtorServerExtensions.kt | 2 +- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/kotlin-sdk-core/api/kotlin-sdk-core.api b/kotlin-sdk-core/api/kotlin-sdk-core.api index 4f230ab4..0c56876d 100644 --- a/kotlin-sdk-core/api/kotlin-sdk-core.api +++ b/kotlin-sdk-core/api/kotlin-sdk-core.api @@ -1,14 +1,14 @@ public final class io/modelcontextprotocol/kotlin/sdk/Annotations { public static final field Companion Lio/modelcontextprotocol/kotlin/sdk/Annotations$Companion; - public fun (Ljava/util/List;Lkotlin/time/Instant;Ljava/lang/Double;)V + public fun (Ljava/util/List;Ljava/lang/String;Ljava/lang/Double;)V public final fun component1 ()Ljava/util/List; - public final fun component2 ()Lkotlin/time/Instant; + public final fun component2 ()Ljava/lang/String; public final fun component3 ()Ljava/lang/Double; - public final fun copy (Ljava/util/List;Lkotlin/time/Instant;Ljava/lang/Double;)Lio/modelcontextprotocol/kotlin/sdk/Annotations; - public static synthetic fun copy$default (Lio/modelcontextprotocol/kotlin/sdk/Annotations;Ljava/util/List;Lkotlin/time/Instant;Ljava/lang/Double;ILjava/lang/Object;)Lio/modelcontextprotocol/kotlin/sdk/Annotations; + public final fun copy (Ljava/util/List;Ljava/lang/String;Ljava/lang/Double;)Lio/modelcontextprotocol/kotlin/sdk/Annotations; + public static synthetic fun copy$default (Lio/modelcontextprotocol/kotlin/sdk/Annotations;Ljava/util/List;Ljava/lang/String;Ljava/lang/Double;ILjava/lang/Object;)Lio/modelcontextprotocol/kotlin/sdk/Annotations; public fun equals (Ljava/lang/Object;)Z public final fun getAudience ()Ljava/util/List; - public final fun getLastModified ()Lkotlin/time/Instant; + public final fun getLastModified ()Ljava/lang/String; public final fun getPriority ()Ljava/lang/Double; public fun hashCode ()I public fun toString ()Ljava/lang/String; diff --git a/kotlin-sdk-core/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types.kt b/kotlin-sdk-core/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types.kt index 60adcca4..a2383ac1 100644 --- a/kotlin-sdk-core/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types.kt +++ b/kotlin-sdk-core/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types.kt @@ -17,8 +17,6 @@ import kotlin.concurrent.atomics.AtomicLong import kotlin.concurrent.atomics.ExperimentalAtomicApi import kotlin.concurrent.atomics.incrementAndFetch import kotlin.jvm.JvmInline -import kotlin.time.ExperimentalTime -import kotlin.time.Instant public const val LATEST_PROTOCOL_VERSION: String = "2025-03-26" @@ -302,6 +300,7 @@ public data class JSONRPCError(val code: ErrorCode, val message: String, val dat public sealed interface NotificationParams : WithMeta /* Cancellation */ + /** * This notification can be sent by either side to indicate that it is cancelling a previously issued request. * @@ -334,6 +333,7 @@ public data class CancelledNotification(override val params: Params) : } /* Initialization */ + /** * Describes the name and version of an MCP implementation. */ @@ -531,6 +531,7 @@ public data class InitializedNotification(override val params: Params = Params() } /* Ping */ + /** * A ping, issued by either the server or the client, to check that the other party is still alive. * The receiver must promptly respond, or else it may be disconnected. @@ -564,6 +565,7 @@ public sealed interface ProgressBase { } /* Progress notifications */ + /** * Represents a progress notification. * @@ -623,6 +625,7 @@ public data class ProgressNotification(override val params: Params) : } /* Pagination */ + /** * Represents a request supporting pagination. */ @@ -650,6 +653,7 @@ public sealed interface PaginatedResult : RequestResult { } /* Resources */ + /** * The contents of a specific resource or sub-resource. */ @@ -892,6 +896,7 @@ public data class ResourceUpdatedNotification(override val params: Params) : Ser } /* Prompts */ + /** * Describes an argument that a prompt can accept. */ @@ -1115,8 +1120,7 @@ public data class Annotations( /** * The moment the resource was last modified. */ - @OptIn(ExperimentalTime::class) - val lastModified: Instant?, + val lastModified: String?, /** * Describes how important this data is for operating the server. * @@ -1162,6 +1166,7 @@ public data class PromptListChangedNotification(override val params: Params = Pa } /* Tools */ + /** * Additional properties describing a Tool to clients. * @@ -1345,6 +1350,7 @@ public data class ToolListChangedNotification(override val params: Params = Para } /* Logging */ + /** * The severity of a log message. */ @@ -1404,6 +1410,7 @@ public data class LoggingMessageNotification(override val params: Params) : Serv } /* Sampling */ + /** * Hints to use for model selection. */ @@ -1648,6 +1655,7 @@ public data class CompleteResult(val completion: Completion, override val _meta: } /* Roots */ + /** * Represents a root directory or file that the server can operate on. */ diff --git a/kotlin-sdk-core/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/TypesTest.kt b/kotlin-sdk-core/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/TypesTest.kt index 7a4938a8..96d25345 100644 --- a/kotlin-sdk-core/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/TypesTest.kt +++ b/kotlin-sdk-core/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/TypesTest.kt @@ -7,7 +7,6 @@ import kotlin.test.assertIs import kotlin.test.assertNotEquals import kotlin.test.assertTrue import kotlin.time.ExperimentalTime -import kotlin.time.Instant class TypesTest { @@ -243,7 +242,7 @@ class TypesTest { fun `should serialize and deserialize annotations correctly`() { val annotations = Annotations( audience = listOf(Role.assistant), - lastModified = Instant.parse("2025-06-18T00:00:00Z"), + lastModified = "2025-06-18T00:00:00Z", priority = 0.5, ) @@ -251,7 +250,7 @@ class TypesTest { val decoded = McpJson.decodeFromString(json) assertEquals(listOf(Role.assistant), decoded.audience) - assertEquals(Instant.parse("2025-06-18T00:00:00Z"), decoded.lastModified) + assertEquals("2025-06-18T00:00:00Z", decoded.lastModified) assertEquals(0.5, decoded.priority) } diff --git a/kotlin-sdk-server/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/server/WebSocketMcpKtorServerExtensions.kt b/kotlin-sdk-server/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/server/WebSocketMcpKtorServerExtensions.kt index a5a24927..cfa8ed8f 100644 --- a/kotlin-sdk-server/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/server/WebSocketMcpKtorServerExtensions.kt +++ b/kotlin-sdk-server/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/server/WebSocketMcpKtorServerExtensions.kt @@ -71,7 +71,7 @@ internal suspend fun WebSocketServerSession.mcpWebSocketEndpoint(block: () -> Se try { session = server.createSession(transport) awaitCancellation() - } catch (e: CancellationException) { + } catch (_: CancellationException) { session?.close() } }