Replace Instant with String for lastModified in Annotations (#383)
Replace `Instant` with `String` for `lastModified` in `Annotations` ## Motivation and Context To fix serialization/kotlin library version conflicts ## How Has This Been Tested? Unit test ## Breaking Changes Yes ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [x] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [ ] New and existing tests pass locally - [ ] I have added appropriate error handling - [ ] I have added or updated documentation as needed ## Additional context <!-- Add any other context, implementation notes, or design decisions -->
This commit is contained in:
parent
33b5fc33df
commit
e6432dbf26
4 changed files with 20 additions and 13 deletions
|
|
@ -1,14 +1,14 @@
|
||||||
public final class io/modelcontextprotocol/kotlin/sdk/Annotations {
|
public final class io/modelcontextprotocol/kotlin/sdk/Annotations {
|
||||||
public static final field Companion Lio/modelcontextprotocol/kotlin/sdk/Annotations$Companion;
|
public static final field Companion Lio/modelcontextprotocol/kotlin/sdk/Annotations$Companion;
|
||||||
public fun <init> (Ljava/util/List;Lkotlin/time/Instant;Ljava/lang/Double;)V
|
public fun <init> (Ljava/util/List;Ljava/lang/String;Ljava/lang/Double;)V
|
||||||
public final fun component1 ()Ljava/util/List;
|
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 component3 ()Ljava/lang/Double;
|
||||||
public final fun copy (Ljava/util/List;Lkotlin/time/Instant;Ljava/lang/Double;)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;Lkotlin/time/Instant;Ljava/lang/Double;ILjava/lang/Object;)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 fun equals (Ljava/lang/Object;)Z
|
||||||
public final fun getAudience ()Ljava/util/List;
|
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 final fun getPriority ()Ljava/lang/Double;
|
||||||
public fun hashCode ()I
|
public fun hashCode ()I
|
||||||
public fun toString ()Ljava/lang/String;
|
public fun toString ()Ljava/lang/String;
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,6 @@ import kotlin.concurrent.atomics.AtomicLong
|
||||||
import kotlin.concurrent.atomics.ExperimentalAtomicApi
|
import kotlin.concurrent.atomics.ExperimentalAtomicApi
|
||||||
import kotlin.concurrent.atomics.incrementAndFetch
|
import kotlin.concurrent.atomics.incrementAndFetch
|
||||||
import kotlin.jvm.JvmInline
|
import kotlin.jvm.JvmInline
|
||||||
import kotlin.time.ExperimentalTime
|
|
||||||
import kotlin.time.Instant
|
|
||||||
|
|
||||||
public const val LATEST_PROTOCOL_VERSION: String = "2025-03-26"
|
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
|
public sealed interface NotificationParams : WithMeta
|
||||||
|
|
||||||
/* Cancellation */
|
/* Cancellation */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This notification can be sent by either side to indicate that it is cancelling a previously issued request.
|
* 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 */
|
/* Initialization */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describes the name and version of an MCP implementation.
|
* Describes the name and version of an MCP implementation.
|
||||||
*/
|
*/
|
||||||
|
|
@ -531,6 +531,7 @@ public data class InitializedNotification(override val params: Params = Params()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ping */
|
/* Ping */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A ping, issued by either the server or the client, to check that the other party is still alive.
|
* 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.
|
* The receiver must promptly respond, or else it may be disconnected.
|
||||||
|
|
@ -564,6 +565,7 @@ public sealed interface ProgressBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Progress notifications */
|
/* Progress notifications */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a progress notification.
|
* Represents a progress notification.
|
||||||
*
|
*
|
||||||
|
|
@ -623,6 +625,7 @@ public data class ProgressNotification(override val params: Params) :
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pagination */
|
/* Pagination */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a request supporting pagination.
|
* Represents a request supporting pagination.
|
||||||
*/
|
*/
|
||||||
|
|
@ -650,6 +653,7 @@ public sealed interface PaginatedResult : RequestResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Resources */
|
/* Resources */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The contents of a specific resource or sub-resource.
|
* The contents of a specific resource or sub-resource.
|
||||||
*/
|
*/
|
||||||
|
|
@ -892,6 +896,7 @@ public data class ResourceUpdatedNotification(override val params: Params) : Ser
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prompts */
|
/* Prompts */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describes an argument that a prompt can accept.
|
* Describes an argument that a prompt can accept.
|
||||||
*/
|
*/
|
||||||
|
|
@ -1115,8 +1120,7 @@ public data class Annotations(
|
||||||
/**
|
/**
|
||||||
* The moment the resource was last modified.
|
* The moment the resource was last modified.
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalTime::class)
|
val lastModified: String?,
|
||||||
val lastModified: Instant?,
|
|
||||||
/**
|
/**
|
||||||
* Describes how important this data is for operating the server.
|
* Describes how important this data is for operating the server.
|
||||||
*
|
*
|
||||||
|
|
@ -1162,6 +1166,7 @@ public data class PromptListChangedNotification(override val params: Params = Pa
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tools */
|
/* Tools */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Additional properties describing a Tool to clients.
|
* Additional properties describing a Tool to clients.
|
||||||
*
|
*
|
||||||
|
|
@ -1345,6 +1350,7 @@ public data class ToolListChangedNotification(override val params: Params = Para
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Logging */
|
/* Logging */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The severity of a log message.
|
* The severity of a log message.
|
||||||
*/
|
*/
|
||||||
|
|
@ -1404,6 +1410,7 @@ public data class LoggingMessageNotification(override val params: Params) : Serv
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sampling */
|
/* Sampling */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hints to use for model selection.
|
* Hints to use for model selection.
|
||||||
*/
|
*/
|
||||||
|
|
@ -1648,6 +1655,7 @@ public data class CompleteResult(val completion: Completion, override val _meta:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Roots */
|
/* Roots */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a root directory or file that the server can operate on.
|
* Represents a root directory or file that the server can operate on.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import kotlin.test.assertIs
|
||||||
import kotlin.test.assertNotEquals
|
import kotlin.test.assertNotEquals
|
||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
import kotlin.time.ExperimentalTime
|
import kotlin.time.ExperimentalTime
|
||||||
import kotlin.time.Instant
|
|
||||||
|
|
||||||
class TypesTest {
|
class TypesTest {
|
||||||
|
|
||||||
|
|
@ -243,7 +242,7 @@ class TypesTest {
|
||||||
fun `should serialize and deserialize annotations correctly`() {
|
fun `should serialize and deserialize annotations correctly`() {
|
||||||
val annotations = Annotations(
|
val annotations = Annotations(
|
||||||
audience = listOf(Role.assistant),
|
audience = listOf(Role.assistant),
|
||||||
lastModified = Instant.parse("2025-06-18T00:00:00Z"),
|
lastModified = "2025-06-18T00:00:00Z",
|
||||||
priority = 0.5,
|
priority = 0.5,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -251,7 +250,7 @@ class TypesTest {
|
||||||
val decoded = McpJson.decodeFromString<Annotations>(json)
|
val decoded = McpJson.decodeFromString<Annotations>(json)
|
||||||
|
|
||||||
assertEquals(listOf(Role.assistant), decoded.audience)
|
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)
|
assertEquals(0.5, decoded.priority)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ internal suspend fun WebSocketServerSession.mcpWebSocketEndpoint(block: () -> Se
|
||||||
try {
|
try {
|
||||||
session = server.createSession(transport)
|
session = server.createSession(transport)
|
||||||
awaitCancellation()
|
awaitCancellation()
|
||||||
} catch (e: CancellationException) {
|
} catch (_: CancellationException) {
|
||||||
session?.close()
|
session?.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue