Skip to content

Commit 878d595

Browse files
committed
Update API
1 parent 9ce219a commit 878d595

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,8 @@ public final class io/modelcontextprotocol/kotlin/sdk/JSONRPCRequest : io/modelc
11501150
public fun <init> (Ljava/lang/String;)V
11511151
public fun <init> (Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/json/JsonElement;)V
11521152
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/json/JsonElement;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
1153+
public fun <init> (Ljava/lang/String;Lkotlinx/serialization/json/JsonElement;)V
1154+
public synthetic fun <init> (Ljava/lang/String;Lkotlinx/serialization/json/JsonElement;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
11531155
public final fun component1 ()Lio/modelcontextprotocol/kotlin/sdk/RequestId;
11541156
public final fun component2 ()Ljava/lang/String;
11551157
public final fun component3 ()Lkotlinx/serialization/json/JsonElement;

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import kotlin.concurrent.atomics.AtomicLong
1717
import kotlin.concurrent.atomics.ExperimentalAtomicApi
1818
import kotlin.concurrent.atomics.incrementAndFetch
1919
import kotlin.jvm.JvmInline
20+
import kotlin.jvm.JvmOverloads
2021
import kotlin.time.ExperimentalTime
2122
import kotlin.time.Instant
2223
import kotlin.uuid.ExperimentalUuidApi
@@ -251,19 +252,18 @@ public data class JSONRPCRequest(
251252
) : this(id = RequestId.StringId(id), method = method, params = params)
252253

253254
/**
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.
255+
* Creates a JSON-RPC request with a randomly generated string ID (using UUID),
256+
* the given method name and parameters.
260257
*
261258
* @param method The method name for the request.
259+
* @param params The parameters for the request as a JSON element. If not provided, an empty JSON object is used.
262260
*/
263261
@OptIn(ExperimentalUuidApi::class)
262+
@JvmOverloads
264263
public constructor(
265264
method: String,
266-
) : this(id = RequestId.NumberId(REQUEST_MESSAGE_ID.incrementAndFetch()), method = method)
265+
params: JsonElement = EmptyJsonObject,
266+
) : this(id = RequestId.StringId(Uuid.random().toHexString()), method = method, params = params)
267267

268268
/**
269269
* Creates a JSON-RPC request with a numeric ID (long) generated by a counter (to ensure uniqueness)

0 commit comments

Comments
 (0)