Skip to content

Commit 9ce219a

Browse files
committed
Update API
1 parent e015f35 commit 9ce219a

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

kotlin-sdk-core/api/kotlin-sdk-core.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,7 @@ public final class io/modelcontextprotocol/kotlin/sdk/JSONRPCRequest : io/modelc
11471147
public synthetic fun <init> (JLjava/lang/String;Lkotlinx/serialization/json/JsonElement;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
11481148
public fun <init> (Lio/modelcontextprotocol/kotlin/sdk/RequestId;Ljava/lang/String;Lkotlinx/serialization/json/JsonElement;Ljava/lang/String;)V
11491149
public synthetic fun <init> (Lio/modelcontextprotocol/kotlin/sdk/RequestId;Ljava/lang/String;Lkotlinx/serialization/json/JsonElement;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
1150+
public fun <init> (Ljava/lang/String;)V
11501151
public fun <init> (Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/json/JsonElement;)V
11511152
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/json/JsonElement;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
11521153
public final fun component1 ()Lio/modelcontextprotocol/kotlin/sdk/RequestId;

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,21 @@ public data class JSONRPCRequest(
250250
params: JsonElement = EmptyJsonObject,
251251
) : this(id = RequestId.StringId(id), method = method, params = params)
252252

253+
/**
254+
* Creates a JSON-RPC request with a numeric ID generated by a counter (to ensure uniqueness)
255+
* and the given method name.
256+
*
257+
* This constructor initializes the `id` field with a `NumberId` instance using the counter
258+
* value from `REQUEST_MESSAGE_ID.incrementAndFetch()`, and assigns the provided method name
259+
* to the `method` field of the request.
260+
*
261+
* @param method The method name for the request.
262+
*/
263+
@OptIn(ExperimentalUuidApi::class)
264+
public constructor(
265+
method: String,
266+
) : this(id = RequestId.NumberId(REQUEST_MESSAGE_ID.incrementAndFetch()), method = method)
267+
253268
/**
254269
* Creates a JSON-RPC request with a numeric ID (long) generated by a counter (to ensure uniqueness)
255270
* and the given method and parameters.
@@ -337,7 +352,8 @@ public sealed interface NotificationParams : WithMeta
337352
/**
338353
* This notification can be sent by either side to indicate that it is cancelling a previously issued request.
339354
*
340-
* The request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished.
355+
* The request SHOULD still be in-flight, but due to communication latency,
356+
* it is always possible that this notification MAY arrive after the request has already finished.
341357
*
342358
* This notification indicates that the result will be unused, so any associated processing SHOULD cease.
343359
*

0 commit comments

Comments
 (0)