Add backwards compatibility constructors and tests (#395)

- Updated integration tests to include assertions for `meta` being
`null` in the `listTools`, `listResources`, `readResource`, and
`callTool` results.
- Renamed test cases in `SseServerIntegrationTest` for clarity.
- Added (deprecated) synthetic constructors for various request
parameter classes.
- Enhanced naming conventions and structure in integration test cases.
- Replaced `throw Error(...)` with `error(...)` for cleaner error
handling.

## Motivation and Context
To verify backwards-compatibility after schema change

## How Has This Been Tested?
CI, integration tests, regression tests (samples)

## Breaking Changes
<!-- Will users need to update their code or configurations? -->

## Types of changes
<!-- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [x] Test 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:
Konstantin Pavlov 2025-11-12 20:18:57 +02:00 • committed by GitHub
commit 8bdbd36c32
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 250 additions and 71 deletions

View file

@ -938,6 +938,8 @@ public final class io/modelcontextprotocol/kotlin/sdk/types/CommonKt {
public final class io/modelcontextprotocol/kotlin/sdk/types/CompleteRequest : io/modelcontextprotocol/kotlin/sdk/types/ClientRequest {
public static final field Companion Lio/modelcontextprotocol/kotlin/sdk/types/CompleteRequest$Companion;
public synthetic fun <init> (Lio/modelcontextprotocol/kotlin/sdk/types/CompleteRequestParams$Argument;Lio/modelcontextprotocol/kotlin/sdk/types/Reference;Lio/modelcontextprotocol/kotlin/sdk/types/CompleteRequestParams$Context;Lkotlinx/serialization/json/JsonObject;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Lio/modelcontextprotocol/kotlin/sdk/types/CompleteRequestParams$Argument;Lio/modelcontextprotocol/kotlin/sdk/types/Reference;Lio/modelcontextprotocol/kotlin/sdk/types/CompleteRequestParams$Context;Lkotlinx/serialization/json/JsonObject;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (Lio/modelcontextprotocol/kotlin/sdk/types/CompleteRequestParams;)V
public final fun component1 ()Lio/modelcontextprotocol/kotlin/sdk/types/CompleteRequestParams;
public final fun copy (Lio/modelcontextprotocol/kotlin/sdk/types/CompleteRequestParams;)Lio/modelcontextprotocol/kotlin/sdk/types/CompleteRequest;
@ -2057,12 +2059,14 @@ public final class io/modelcontextprotocol/kotlin/sdk/types/ListPromptsRequest :
public fun <init> ()V
public fun <init> (Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;)V
public synthetic fun <init> (Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lkotlinx/serialization/json/JsonObject;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lkotlinx/serialization/json/JsonObject;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;
public final fun copy (Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;)Lio/modelcontextprotocol/kotlin/sdk/types/ListPromptsRequest;
public static synthetic fun copy$default (Lio/modelcontextprotocol/kotlin/sdk/types/ListPromptsRequest;Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;ILjava/lang/Object;)Lio/modelcontextprotocol/kotlin/sdk/types/ListPromptsRequest;
public fun equals (Ljava/lang/Object;)Z
public final fun getCursor ()Ljava/lang/String;
public final fun getMeta-VI-3G7E ()Lkotlinx/serialization/json/JsonObject;
public fun getCursor ()Ljava/lang/String;
public fun getMeta-VI-3G7E ()Lkotlinx/serialization/json/JsonObject;
public fun getMethod ()Lio/modelcontextprotocol/kotlin/sdk/types/Method;
public fun getParams ()Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;
public synthetic fun getParams ()Lio/modelcontextprotocol/kotlin/sdk/types/RequestParams;
@ -2123,12 +2127,14 @@ public final class io/modelcontextprotocol/kotlin/sdk/types/ListResourceTemplate
public fun <init> ()V
public fun <init> (Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;)V
public synthetic fun <init> (Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lkotlinx/serialization/json/JsonObject;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lkotlinx/serialization/json/JsonObject;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;
public final fun copy (Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;)Lio/modelcontextprotocol/kotlin/sdk/types/ListResourceTemplatesRequest;
public static synthetic fun copy$default (Lio/modelcontextprotocol/kotlin/sdk/types/ListResourceTemplatesRequest;Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;ILjava/lang/Object;)Lio/modelcontextprotocol/kotlin/sdk/types/ListResourceTemplatesRequest;
public fun equals (Ljava/lang/Object;)Z
public final fun getCursor ()Ljava/lang/String;
public final fun getMeta-VI-3G7E ()Lkotlinx/serialization/json/JsonObject;
public fun getCursor ()Ljava/lang/String;
public fun getMeta-VI-3G7E ()Lkotlinx/serialization/json/JsonObject;
public fun getMethod ()Lio/modelcontextprotocol/kotlin/sdk/types/Method;
public fun getParams ()Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;
public synthetic fun getParams ()Lio/modelcontextprotocol/kotlin/sdk/types/RequestParams;
@ -2189,12 +2195,14 @@ public final class io/modelcontextprotocol/kotlin/sdk/types/ListResourcesRequest
public fun <init> ()V
public fun <init> (Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;)V
public synthetic fun <init> (Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lkotlinx/serialization/json/JsonObject;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lkotlinx/serialization/json/JsonObject;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;
public final fun copy (Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;)Lio/modelcontextprotocol/kotlin/sdk/types/ListResourcesRequest;
public static synthetic fun copy$default (Lio/modelcontextprotocol/kotlin/sdk/types/ListResourcesRequest;Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;ILjava/lang/Object;)Lio/modelcontextprotocol/kotlin/sdk/types/ListResourcesRequest;
public fun equals (Ljava/lang/Object;)Z
public final fun getCursor ()Ljava/lang/String;
public final fun getMeta-VI-3G7E ()Lkotlinx/serialization/json/JsonObject;
public fun getCursor ()Ljava/lang/String;
public fun getMeta-VI-3G7E ()Lkotlinx/serialization/json/JsonObject;
public fun getMethod ()Lio/modelcontextprotocol/kotlin/sdk/types/Method;
public fun getParams ()Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;
public synthetic fun getParams ()Lio/modelcontextprotocol/kotlin/sdk/types/RequestParams;
@ -2255,6 +2263,7 @@ public final class io/modelcontextprotocol/kotlin/sdk/types/ListRootsRequest : i
public fun <init> ()V
public fun <init> (Lio/modelcontextprotocol/kotlin/sdk/types/BaseRequestParams;)V
public synthetic fun <init> (Lio/modelcontextprotocol/kotlin/sdk/types/BaseRequestParams;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Lkotlinx/serialization/json/JsonObject;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Lio/modelcontextprotocol/kotlin/sdk/types/BaseRequestParams;
public final fun copy (Lio/modelcontextprotocol/kotlin/sdk/types/BaseRequestParams;)Lio/modelcontextprotocol/kotlin/sdk/types/ListRootsRequest;
public static synthetic fun copy$default (Lio/modelcontextprotocol/kotlin/sdk/types/ListRootsRequest;Lio/modelcontextprotocol/kotlin/sdk/types/BaseRequestParams;ILjava/lang/Object;)Lio/modelcontextprotocol/kotlin/sdk/types/ListRootsRequest;
@ -2318,12 +2327,14 @@ public final class io/modelcontextprotocol/kotlin/sdk/types/ListToolsRequest : i
public fun <init> ()V
public fun <init> (Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;)V
public synthetic fun <init> (Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lkotlinx/serialization/json/JsonObject;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lkotlinx/serialization/json/JsonObject;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;
public final fun copy (Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;)Lio/modelcontextprotocol/kotlin/sdk/types/ListToolsRequest;
public static synthetic fun copy$default (Lio/modelcontextprotocol/kotlin/sdk/types/ListToolsRequest;Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;ILjava/lang/Object;)Lio/modelcontextprotocol/kotlin/sdk/types/ListToolsRequest;
public fun equals (Ljava/lang/Object;)Z
public final fun getCursor ()Ljava/lang/String;
public final fun getMeta-VI-3G7E ()Lkotlinx/serialization/json/JsonObject;
public fun getCursor ()Ljava/lang/String;
public fun getMeta-VI-3G7E ()Lkotlinx/serialization/json/JsonObject;
public fun getMethod ()Lio/modelcontextprotocol/kotlin/sdk/types/Method;
public fun getParams ()Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;
public synthetic fun getParams ()Lio/modelcontextprotocol/kotlin/sdk/types/RequestParams;
@ -2641,6 +2652,8 @@ public final class io/modelcontextprotocol/kotlin/sdk/types/NotificationParams$D
public abstract interface class io/modelcontextprotocol/kotlin/sdk/types/PaginatedRequest : io/modelcontextprotocol/kotlin/sdk/types/Request {
public static final field Companion Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequest$Companion;
public fun getCursor ()Ljava/lang/String;
public fun getMeta-VI-3G7E ()Lkotlinx/serialization/json/JsonObject;
public abstract fun getParams ()Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams;
}
@ -2648,6 +2661,11 @@ public final class io/modelcontextprotocol/kotlin/sdk/types/PaginatedRequest$Com
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public final class io/modelcontextprotocol/kotlin/sdk/types/PaginatedRequest$DefaultImpls {
public static fun getCursor (Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequest;)Ljava/lang/String;
public static fun getMeta-VI-3G7E (Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequest;)Lkotlinx/serialization/json/JsonObject;
}
public final class io/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams : io/modelcontextprotocol/kotlin/sdk/types/RequestParams {
public static final field Companion Lio/modelcontextprotocol/kotlin/sdk/types/PaginatedRequestParams$Companion;
public synthetic fun <init> (Ljava/lang/String;Lkotlinx/serialization/json/JsonObject;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
@ -3023,6 +3041,8 @@ public final class io/modelcontextprotocol/kotlin/sdk/types/RPCError$ErrorCode {
public final class io/modelcontextprotocol/kotlin/sdk/types/ReadResourceRequest : io/modelcontextprotocol/kotlin/sdk/types/ClientRequest {
public static final field Companion Lio/modelcontextprotocol/kotlin/sdk/types/ReadResourceRequest$Companion;
public fun <init> (Lio/modelcontextprotocol/kotlin/sdk/types/ReadResourceRequestParams;)V
public synthetic fun <init> (Ljava/lang/String;Lkotlinx/serialization/json/JsonObject;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lkotlinx/serialization/json/JsonObject;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Lio/modelcontextprotocol/kotlin/sdk/types/ReadResourceRequestParams;
public final fun copy (Lio/modelcontextprotocol/kotlin/sdk/types/ReadResourceRequestParams;)Lio/modelcontextprotocol/kotlin/sdk/types/ReadResourceRequest;
public static synthetic fun copy$default (Lio/modelcontextprotocol/kotlin/sdk/types/ReadResourceRequest;Lio/modelcontextprotocol/kotlin/sdk/types/ReadResourceRequestParams;ILjava/lang/Object;)Lio/modelcontextprotocol/kotlin/sdk/types/ReadResourceRequest;
@ -3906,6 +3926,8 @@ public final class io/modelcontextprotocol/kotlin/sdk/types/StopReason$Companion
public final class io/modelcontextprotocol/kotlin/sdk/types/SubscribeRequest : io/modelcontextprotocol/kotlin/sdk/types/ClientRequest {
public static final field Companion Lio/modelcontextprotocol/kotlin/sdk/types/SubscribeRequest$Companion;
public fun <init> (Lio/modelcontextprotocol/kotlin/sdk/types/SubscribeRequestParams;)V
public synthetic fun <init> (Ljava/lang/String;Lkotlinx/serialization/json/JsonObject;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lkotlinx/serialization/json/JsonObject;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Lio/modelcontextprotocol/kotlin/sdk/types/SubscribeRequestParams;
public final fun copy (Lio/modelcontextprotocol/kotlin/sdk/types/SubscribeRequestParams;)Lio/modelcontextprotocol/kotlin/sdk/types/SubscribeRequest;
public static synthetic fun copy$default (Lio/modelcontextprotocol/kotlin/sdk/types/SubscribeRequest;Lio/modelcontextprotocol/kotlin/sdk/types/SubscribeRequestParams;ILjava/lang/Object;)Lio/modelcontextprotocol/kotlin/sdk/types/SubscribeRequest;
@ -4219,6 +4241,8 @@ public final class io/modelcontextprotocol/kotlin/sdk/types/UnknownResourceConte
public final class io/modelcontextprotocol/kotlin/sdk/types/UnsubscribeRequest : io/modelcontextprotocol/kotlin/sdk/types/ClientRequest {
public static final field Companion Lio/modelcontextprotocol/kotlin/sdk/types/UnsubscribeRequest$Companion;
public fun <init> (Lio/modelcontextprotocol/kotlin/sdk/types/UnsubscribeRequestParams;)V
public synthetic fun <init> (Ljava/lang/String;Lkotlinx/serialization/json/JsonObject;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lkotlinx/serialization/json/JsonObject;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Lio/modelcontextprotocol/kotlin/sdk/types/UnsubscribeRequestParams;
public final fun copy (Lio/modelcontextprotocol/kotlin/sdk/types/UnsubscribeRequestParams;)Lio/modelcontextprotocol/kotlin/sdk/types/UnsubscribeRequest;
public static synthetic fun copy$default (Lio/modelcontextprotocol/kotlin/sdk/types/UnsubscribeRequest;Lio/modelcontextprotocol/kotlin/sdk/types/UnsubscribeRequestParams;ILjava/lang/Object;)Lio/modelcontextprotocol/kotlin/sdk/types/UnsubscribeRequest;

View file

@ -397,7 +397,7 @@ public abstract class Protocol(@PublishedApi internal val options: ProtocolOptio
public suspend fun <T : RequestResult> request(request: Request, options: RequestOptions? = null): T {
logger.trace { "Sending request: ${request.method}" }
val result = CompletableDeferred<T>()
val transport = transport ?: throw Error("Not connected")
val transport = transport ?: error("Not connected")
if (this@Protocol.options?.enforceStrictCapabilities == true) {
assertCapabilityForMethod(request.method)

View file

@ -1,5 +1,7 @@
package io.modelcontextprotocol.kotlin.sdk.types
import io.modelcontextprotocol.kotlin.sdk.types.CompleteRequestParams.Argument
import io.modelcontextprotocol.kotlin.sdk.types.CompleteRequestParams.Context
import kotlinx.serialization.EncodeDefault
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.SerialName
@ -20,7 +22,7 @@ public data class CompleteRequest(override val params: CompleteRequestParams) :
/**
* The argument's information for which completion options are requested.
*/
public val argument: CompleteRequestParams.Argument
public val argument: Argument
get() = params.argument
/**
@ -32,11 +34,23 @@ public data class CompleteRequest(override val params: CompleteRequestParams) :
/**
* Additional, context for generating completions.
*/
public val context: CompleteRequestParams.Context?
public val context: Context?
get() = params.context
public val meta: RequestMeta?
get() = params.meta
@Deprecated(
message = "Will be removed in a future release.",
replaceWith = ReplaceWith(expression = "CompleteRequest(CompleteRequestParams(argument, ref, context, meta))"),
level = DeprecationLevel.WARNING,
)
public constructor(
argument: Argument,
ref: Reference,
context: Context? = null,
meta: RequestMeta? = null,
) : this(CompleteRequestParams(argument, ref, context, meta))
}
/**
@ -67,7 +81,7 @@ public data class CompleteRequestParams(
/**
* Additional context to help generate more relevant completions.
*
* @property arguments Previously-resolved variables in a URI template or prompt.
* @property arguments Previously resolved variables in a URI template or prompt.
* These can be used to provide context-aware completions.
* For example, if completing a file path, this might contain the repository or directory context.
*/
@ -100,8 +114,8 @@ public data class CompleteResult(
* This can exceed the number of values actually sent in the response,
* indicating that pagination or filtering may be needed.
* @property hasMore Indicates whether there are additional completion options beyond
* those provided in the current response, even if the exact total is unknown.
* Use this when the complete set of completions is too large to calculate upfront.
* those provided in the current response, even if the exact total is unknown.
* Use this when the complete set of completions is too large to calculate upfront.
*/
@Serializable
public data class Completion(val values: List<String>, val total: Int? = null, val hasMore: Boolean? = null) {

View file

@ -205,16 +205,24 @@ public data class ListPromptsRequest(override val params: PaginatedRequestParams
override val method: Method = Method.Defined.PromptsList
/**
* An opaque token representing the current pagination position.
* Secondary constructor for creating a [ListPromptsRequest] instance
* using optional cursor and metadata parameters.
*
* This constructor simplifies the creation of the [ListPromptsRequest] by allowing a cursor
* and metadata to be provided.
*
* @param cursor Optional cursor string to specify the starting point of the paginated request.
* @param meta Optional metadata associated with the request.
*/
public val cursor: String?
get() = params?.cursor
/**
* Metadata for this request. May include a progressToken for out-of-band progress notifications.
*/
public val meta: RequestMeta?
get() = params?.meta
@Deprecated(
message = "Use constructor with ListPromptsParams instead",
replaceWith = ReplaceWith("ListPromptsRequest(ListPromptsParams(name, arguments, meta))"),
level = DeprecationLevel.WARNING,
)
public constructor(
cursor: String?,
meta: RequestMeta? = null,
) : this(paginatedRequestParams(cursor, meta))
}
/**

View file

@ -27,6 +27,12 @@ public value class RequestMeta(public val json: JsonObject) {
@Serializable
public sealed interface RequestParams {
/**
* The `_meta` property/parameter is reserved by MCP
* to allow clients and servers to attach additional metadata to their interactions.
*
* @see <a href="https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta">MCP specification</a>
*/
@SerialName("_meta")
public val meta: RequestMeta?
}
@ -68,6 +74,18 @@ public sealed interface ServerRequest : Request
@Serializable
public sealed interface PaginatedRequest : Request {
public override val params: PaginatedRequestParams?
/**
* An opaque token representing the current pagination position.
*/
public val cursor: String?
get() = params?.cursor
/**
* Metadata for this request. May include a progressToken for out-of-band progress notifications.
*/
public val meta: RequestMeta?
get() = params?.meta
}
/**
@ -114,3 +132,10 @@ public data class PaginatedRequestParams(
@SerialName("_meta")
override val meta: RequestMeta? = null,
) : RequestParams
internal fun paginatedRequestParams(cursor: String?, meta: RequestMeta?): PaginatedRequestParams? =
if (cursor == null && meta == null) {
null
} else {
PaginatedRequestParams(cursor = cursor, meta = meta)
}

View file

@ -17,7 +17,7 @@ public sealed interface ResourceLike : WithMeta
* Resources represent data sources such as files, database entries, API responses,
* or other structured data that can be read by clients.
*
* @property uri The URI of this resource. Can use any protocol scheme (file://, http://, etc.).
* @property uri The URI of this resource. Can use any protocol scheme (`file://`, `http://`, etc.).
* @property name The programmatic identifier for this resource.
* Intended for logical use and API identification. If [title] is not provided,
* this should be used as a fallback display name.
@ -25,7 +25,8 @@ public sealed interface ResourceLike : WithMeta
* Clients can use this to improve the LLM's understanding of available resources.
* It can be thought of like a "hint" to the model.
* @property mimeType The MIME type of this resource, if known (e.g., "text/plain", "application/json", "image/png").
* @property size The size of the raw resource content in bytes (i.e., before base64 encoding or any tokenization), if known.
* @property size The size of the raw resource content in bytes
* (i.e., before base64 encoding or any tokenization), if known.
* Hosts can use this to display file sizes and estimate context window usage.
* @property title Optional human-readable display name for this resource.
* Intended for UI and end-user contexts, optimized to be easily understood
@ -192,16 +193,24 @@ public data class ListResourcesRequest(override val params: PaginatedRequestPara
override val method: Method = Method.Defined.ResourcesList
/**
* An opaque token representing the current pagination position.
* Secondary constructor for creating a [ListResourcesRequest] instance
* using optional cursor and metadata parameters.
*
* This constructor simplifies the creation of the [ListResourcesRequest] by allowing a cursor
* and metadata to be provided.
*
* @param cursor Optional cursor string to specify the starting point of the paginated request.
* @param meta Optional metadata associated with the request.
*/
public val cursor: String?
get() = params?.cursor
/**
* Metadata for this request. May include a progressToken for out-of-band progress notifications.
*/
public val meta: RequestMeta?
get() = params?.meta
@Deprecated(
message = "Use the constructor with PaginatedRequestParams property instead",
replaceWith = ReplaceWith("ReadResourceRequest(PaginatedRequestParams(cursor, meta))"),
level = DeprecationLevel.WARNING,
)
public constructor(
cursor: String?,
meta: RequestMeta? = null,
) : this(paginatedRequestParams(cursor, meta))
}
/**
@ -252,6 +261,16 @@ public data class ReadResourceRequest(override val params: ReadResourceRequestPa
*/
public val meta: RequestMeta?
get() = params.meta
@Deprecated(
message = "Use the constructor with ReadResourceRequestParams property instead",
replaceWith = ReplaceWith("ReadResourceRequest(ReadResourceRequestParams(uri, meta))"),
level = DeprecationLevel.WARNING,
)
public constructor(
uri: String,
meta: RequestMeta? = null,
) : this(ReadResourceRequestParams(uri, meta))
}
/**
@ -318,6 +337,16 @@ public data class SubscribeRequest(override val params: SubscribeRequestParams)
*/
public val meta: RequestMeta?
get() = params.meta
@Deprecated(
message = "Use the constructor with SubscribeRequestParams property instead",
replaceWith = ReplaceWith("ReadResourceRequest(SubscribeRequestParams(uri, meta))"),
level = DeprecationLevel.WARNING,
)
public constructor(
uri: String,
meta: RequestMeta? = null,
) : this(SubscribeRequestParams(uri, meta))
}
/**
@ -363,6 +392,11 @@ public data class UnsubscribeRequest(override val params: UnsubscribeRequestPara
*/
public val meta: RequestMeta?
get() = params.meta
public constructor(
uri: String,
meta: RequestMeta? = null,
) : this(UnsubscribeRequestParams(uri, meta))
}
/**
@ -401,16 +435,24 @@ public data class ListResourceTemplatesRequest(override val params: PaginatedReq
override val method: Method = Method.Defined.ResourcesTemplatesList
/**
* An opaque token representing the current pagination position.
* Secondary constructor for creating a [ListResourceTemplatesRequest] instance
* using optional cursor and metadata parameters.
*
* This constructor simplifies the creation of the [ListResourceTemplatesRequest] by allowing a cursor
* and metadata to be provided.
*
* @param cursor Optional cursor string to specify the starting point of the paginated request.
* @param meta Optional metadata associated with the request.
*/
public val cursor: String?
get() = params?.cursor
/**
* Metadata for this request. May include a progressToken for out-of-band progress notifications.
*/
public val meta: RequestMeta?
get() = params?.meta
@Deprecated(
message = "Use the constructor with PaginatedRequestParams property instead",
replaceWith = ReplaceWith("ListResourceTemplatesRequest(PaginatedRequestParams(cursor, meta))"),
level = DeprecationLevel.WARNING,
)
public constructor(
cursor: String?,
meta: RequestMeta? = null,
) : this(paginatedRequestParams(cursor, meta))
}
/**

View file

@ -62,6 +62,15 @@ public data class ListRootsRequest(override val params: BaseRequestParams? = nul
public val meta: RequestMeta?
get() = params?.meta
@Deprecated(
message = "Use the constructor with BaseRequestParams property instead",
replaceWith = ReplaceWith("ListRootsRequest(BaseRequestParams(meta))"),
level = DeprecationLevel.WARNING,
)
public constructor(
meta: RequestMeta?,
) : this(BaseRequestParams(meta))
}
/**

View file

@ -228,16 +228,24 @@ public data class ListToolsRequest(override val params: PaginatedRequestParams?
override val method: Method = Method.Defined.ToolsList
/**
* An opaque token representing the current pagination position.
* Secondary constructor for creating a [ListToolsRequest] instance
* using optional cursor and metadata parameters.
*
* This constructor simplifies the creation of the [ListToolsRequest] by allowing a cursor
* and metadata to be provided.
*
* @param cursor Optional cursor string to specify the starting point of the paginated request.
* @param meta Optional metadata associated with the request.
*/
public val cursor: String?
get() = params?.cursor
/**
* Metadata for this request. May include a progressToken for out-of-band progress notifications.
*/
public val meta: RequestMeta?
get() = params?.meta
@Deprecated(
message = "Use the constructor with BaseRequestParams property instead",
replaceWith = ReplaceWith("ListToolsRequest(BaseRequestParams(meta))"),
level = DeprecationLevel.WARNING,
)
public constructor(
cursor: String?,
meta: RequestMeta? = null,
) : this(paginatedRequestParams(cursor, meta))
}
/**