Skip to content

Commit b60e12a

Browse files
SeanChinJunKaie5l
andauthored
feat: add message field to ProgressNotification according to 2025-03-26 spec (#69)
* feat: add message field to ProgressNotification to provide descriptive status updates * chore: commit api dump --------- Co-authored-by: Leonid Stashevsky <[email protected]>
1 parent 129731c commit b60e12a

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

api/kotlin-sdk.api

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,8 +1485,9 @@ public final class io/modelcontextprotocol/kotlin/sdk/PingRequest$Companion {
14851485

14861486
public class io/modelcontextprotocol/kotlin/sdk/Progress : io/modelcontextprotocol/kotlin/sdk/ProgressBase {
14871487
public static final field Companion Lio/modelcontextprotocol/kotlin/sdk/Progress$Companion;
1488-
public synthetic fun <init> (IILjava/lang/Double;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
1489-
public fun <init> (ILjava/lang/Double;)V
1488+
public synthetic fun <init> (IILjava/lang/Double;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
1489+
public fun <init> (ILjava/lang/Double;Ljava/lang/String;)V
1490+
public fun getMessage ()Ljava/lang/String;
14901491
public fun getProgress ()I
14911492
public fun getTotal ()Ljava/lang/Double;
14921493
public static final synthetic fun write$Self (Lio/modelcontextprotocol/kotlin/sdk/Progress;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
@@ -1509,6 +1510,7 @@ public final class io/modelcontextprotocol/kotlin/sdk/Progress$Companion {
15091510

15101511
public abstract interface class io/modelcontextprotocol/kotlin/sdk/ProgressBase {
15111512
public static final field Companion Lio/modelcontextprotocol/kotlin/sdk/ProgressBase$Companion;
1513+
public abstract fun getMessage ()Ljava/lang/String;
15121514
public abstract fun getProgress ()I
15131515
public abstract fun getTotal ()Ljava/lang/Double;
15141516
}
@@ -1519,15 +1521,17 @@ public final class io/modelcontextprotocol/kotlin/sdk/ProgressBase$Companion {
15191521

15201522
public final class io/modelcontextprotocol/kotlin/sdk/ProgressNotification : io/modelcontextprotocol/kotlin/sdk/ClientNotification, io/modelcontextprotocol/kotlin/sdk/ProgressBase, io/modelcontextprotocol/kotlin/sdk/ServerNotification {
15211523
public static final field Companion Lio/modelcontextprotocol/kotlin/sdk/ProgressNotification$Companion;
1522-
public fun <init> (ILio/modelcontextprotocol/kotlin/sdk/RequestId;Lkotlinx/serialization/json/JsonObject;Ljava/lang/Double;)V
1523-
public synthetic fun <init> (ILio/modelcontextprotocol/kotlin/sdk/RequestId;Lkotlinx/serialization/json/JsonObject;Ljava/lang/Double;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
1524+
public fun <init> (ILio/modelcontextprotocol/kotlin/sdk/RequestId;Lkotlinx/serialization/json/JsonObject;Ljava/lang/Double;Ljava/lang/String;)V
1525+
public synthetic fun <init> (ILio/modelcontextprotocol/kotlin/sdk/RequestId;Lkotlinx/serialization/json/JsonObject;Ljava/lang/Double;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
15241526
public final fun component1 ()I
15251527
public final fun component2 ()Lio/modelcontextprotocol/kotlin/sdk/RequestId;
15261528
public final fun component3 ()Lkotlinx/serialization/json/JsonObject;
15271529
public final fun component4 ()Ljava/lang/Double;
1528-
public final fun copy (ILio/modelcontextprotocol/kotlin/sdk/RequestId;Lkotlinx/serialization/json/JsonObject;Ljava/lang/Double;)Lio/modelcontextprotocol/kotlin/sdk/ProgressNotification;
1529-
public static synthetic fun copy$default (Lio/modelcontextprotocol/kotlin/sdk/ProgressNotification;ILio/modelcontextprotocol/kotlin/sdk/RequestId;Lkotlinx/serialization/json/JsonObject;Ljava/lang/Double;ILjava/lang/Object;)Lio/modelcontextprotocol/kotlin/sdk/ProgressNotification;
1530+
public final fun component5 ()Ljava/lang/String;
1531+
public final fun copy (ILio/modelcontextprotocol/kotlin/sdk/RequestId;Lkotlinx/serialization/json/JsonObject;Ljava/lang/Double;Ljava/lang/String;)Lio/modelcontextprotocol/kotlin/sdk/ProgressNotification;
1532+
public static synthetic fun copy$default (Lio/modelcontextprotocol/kotlin/sdk/ProgressNotification;ILio/modelcontextprotocol/kotlin/sdk/RequestId;Lkotlinx/serialization/json/JsonObject;Ljava/lang/Double;Ljava/lang/String;ILjava/lang/Object;)Lio/modelcontextprotocol/kotlin/sdk/ProgressNotification;
15301533
public fun equals (Ljava/lang/Object;)Z
1534+
public fun getMessage ()Ljava/lang/String;
15311535
public fun getMethod ()Lio/modelcontextprotocol/kotlin/sdk/Method;
15321536
public fun getProgress ()I
15331537
public final fun getProgressToken ()Lio/modelcontextprotocol/kotlin/sdk/RequestId;

src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/shared/Protocol.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ public abstract class Protocol(
260260
LOGGER.trace { "Received progress notification: token=${notification.progressToken}, progress=${notification.progress}/${notification.total}" }
261261
val progress = notification.progress
262262
val total = notification.total
263+
val message = notification.message
263264
val progressToken = notification.progressToken
264265

265266
val handler = progressHandlers[progressToken]
@@ -272,7 +273,7 @@ public abstract class Protocol(
272273
return
273274
}
274275

275-
handler.invoke(Progress(progress, total))
276+
handler.invoke(Progress(progress, total, message))
276277
}
277278

278279
private fun onResponse(response: JSONRPCResponse?, error: JSONRPCError?) {

src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,11 @@ public sealed interface ProgressBase {
512512
* Total number of items to a process (or total progress required), if known.
513513
*/
514514
public val total: Double?
515+
516+
/**
517+
* An optional message describing the current progress.
518+
*/
519+
public val message: String?
515520
}
516521

517522
/* Progress notifications */
@@ -532,6 +537,11 @@ public open class Progress(
532537
* Total number of items to a process (or total progress required), if known.
533538
*/
534539
override val total: Double?,
540+
541+
/**
542+
* An optional message describing the current progress.
543+
*/
544+
override val message: String?,
535545
) : ProgressBase
536546

537547
/**
@@ -548,6 +558,7 @@ public data class ProgressNotification(
548558
public val progressToken: ProgressToken,
549559
@Suppress("PropertyName") val _meta: JsonObject = EmptyJsonObject,
550560
override val total: Double?,
561+
override val message: String?,
551562
) : ClientNotification, ServerNotification, ProgressBase {
552563
override val method: Method = Method.Defined.NotificationsProgress
553564
}

0 commit comments

Comments
 (0)