From ed837ba8580add190853854281e50ccd0cd68659 Mon Sep 17 00:00:00 2001 From: SeanChinJunKai Date: Wed, 9 Apr 2025 12:00:40 +0800 Subject: [PATCH] feat: add message field to ProgressNotification to provide descriptive status updates --- .../kotlin/sdk/shared/Protocol.kt | 3 ++- .../io/modelcontextprotocol/kotlin/sdk/types.kt | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/shared/Protocol.kt b/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/shared/Protocol.kt index d9808ff..7553bf1 100644 --- a/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/shared/Protocol.kt +++ b/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/shared/Protocol.kt @@ -260,6 +260,7 @@ public abstract class Protocol( LOGGER.trace { "Received progress notification: token=${notification.progressToken}, progress=${notification.progress}/${notification.total}" } val progress = notification.progress val total = notification.total + val message = notification.message val progressToken = notification.progressToken val handler = progressHandlers[progressToken] @@ -272,7 +273,7 @@ public abstract class Protocol( return } - handler.invoke(Progress(progress, total)) + handler.invoke(Progress(progress, total, message)) } private fun onResponse(response: JSONRPCResponse?, error: JSONRPCError?) { diff --git a/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types.kt b/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types.kt index d2fa2cb..33b0fb2 100644 --- a/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types.kt +++ b/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types.kt @@ -510,6 +510,11 @@ public sealed interface ProgressBase { * Total number of items to a process (or total progress required), if known. */ public val total: Double? + + /** + * An optional message describing the current progress. + */ + public val message: String? } /* Progress notifications */ @@ -530,6 +535,11 @@ public open class Progress( * Total number of items to a process (or total progress required), if known. */ override val total: Double?, + + /** + * An optional message describing the current progress. + */ + override val message: String?, ) : ProgressBase /** @@ -546,6 +556,7 @@ public data class ProgressNotification( public val progressToken: ProgressToken, @Suppress("PropertyName") val _meta: JsonObject = EmptyJsonObject, override val total: Double?, + override val message: String?, ) : ClientNotification, ServerNotification, ProgressBase { override val method: Method = Method.Defined.NotificationsProgress }