-
Notifications
You must be signed in to change notification settings - Fork 158
158 support resource links #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0e50346
610b9d6
3d182bc
f6c8843
cf7976d
2e7c450
8f00711
c3746a4
f2b04d3
ae1ead0
0bc0304
c210a3a
72cd564
56d8681
cebb28d
c821241
7a2ae41
5136548
98247fb
a0ac8a2
8858a6c
cfad8a5
9a40df1
c62db93
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -970,19 +970,34 @@ public data class GetPromptRequest( | |
override val method: Method = Method.Defined.PromptsGet | ||
} | ||
|
||
/** | ||
* Represents the content of a prompt message. | ||
*/ | ||
@Serializable(with = PromptMessageContentPolymorphicSerializer::class) | ||
@Deprecated("For backwards compatibility; use ContentBlock instead", ReplaceWith("ContentBlock")) | ||
public sealed interface PromptMessageContent { | ||
public val type: String | ||
} | ||
|
||
@Deprecated( | ||
"For backwards compatibility; use CreateMessageResultContent or SamplingMessageContent instead", | ||
ReplaceWith("CreateMessageResultContent"), | ||
) | ||
public sealed interface PromptMessageContentMultimodal : PromptMessageContent | ||
|
||
/** | ||
* Represents prompt message content that is either text, image or audio. | ||
* Represents the types of a ContentBlock | ||
*/ | ||
@Serializable(with = PromptMessageContentMultimodalPolymorphicSerializer::class) | ||
public sealed interface PromptMessageContentMultimodal : PromptMessageContent | ||
@Serializable(with = ContentBlockPolymorphicSerializer::class) | ||
public sealed interface ContentBlock : PromptMessageContent | ||
|
||
/** | ||
* Represents content for the CreateMessageResult | ||
*/ | ||
@Serializable(with = CreateMessageResultContentMultimodalPolymorphicSerializer::class) | ||
public sealed interface CreateMessageResultContent : ContentBlock | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CreateMessageResult supports only https://modelcontextprotocol.io/specification/2025-06-18/schema#createmessageresult |
||
|
||
/** | ||
* Represents content for the SamplingMessage | ||
*/ | ||
@Serializable(with = SamplingMessageContentMultimodalPolymorphicSerializer::class) | ||
public sealed interface SamplingMessageContent : ContentBlock | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SamplingMessage supports only https://modelcontextprotocol.io/specification/2025-06-18/schema#samplingmessage |
||
|
||
/** | ||
* Text provided to or from an LLM. | ||
|
@@ -998,7 +1013,9 @@ public data class TextContent( | |
* Optional annotations for the client. | ||
*/ | ||
val annotations: Annotations? = null, | ||
) : PromptMessageContentMultimodal { | ||
) : ContentBlock, | ||
CreateMessageResultContent, | ||
SamplingMessageContent { | ||
override val type: String = TYPE | ||
|
||
public companion object { | ||
|
@@ -1025,7 +1042,9 @@ public data class ImageContent( | |
* Optional annotations for the client. | ||
*/ | ||
val annotations: Annotations? = null, | ||
) : PromptMessageContentMultimodal { | ||
) : ContentBlock, | ||
CreateMessageResultContent, | ||
SamplingMessageContent { | ||
override val type: String = TYPE | ||
|
||
public companion object { | ||
|
@@ -1052,19 +1071,80 @@ public data class AudioContent( | |
* Optional annotations for the client. | ||
*/ | ||
val annotations: Annotations? = null, | ||
) : PromptMessageContentMultimodal { | ||
) : ContentBlock, | ||
CreateMessageResultContent, | ||
SamplingMessageContent { | ||
override val type: String = TYPE | ||
|
||
public companion object { | ||
public const val TYPE: String = "audio" | ||
} | ||
} | ||
|
||
/** | ||
* A Resource Link provided to or from an LLM. | ||
*/ | ||
@Serializable | ||
public data class ResourceLink( | ||
/** | ||
* A description of what this resource represents. | ||
* | ||
* This can be used by clients to improve the LLM’s understanding of available resources. It can be thought of like a “hint” to the model. | ||
* | ||
*/ | ||
val description: String? = null, | ||
|
||
/** | ||
* Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn’t present). | ||
*/ | ||
val name: String, | ||
|
||
/** | ||
* The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known. | ||
* | ||
* This can be used by Hosts to display file sizes and estimate context window usage. | ||
* | ||
*/ | ||
val size: Long? = null, | ||
|
||
/** | ||
* Intended for UI and end-user contexts — optimized to be human-readable and easily understood, even by those unfamiliar with domain-specific terminology. | ||
* | ||
* If not provided, the name should be used for display (except for Tool, where annotations.title should be given precedence over using name, if present). | ||
* | ||
*/ | ||
val title: String? = null, | ||
|
||
/** | ||
* The URI of this resource. | ||
*/ | ||
val uri: String, | ||
|
||
/** | ||
* The MIME type of this resource, if known. | ||
*/ | ||
val mimeType: String, | ||
|
||
/** | ||
* Optional annotations for the client. | ||
*/ | ||
val annotations: Annotations? = null, | ||
) : ContentBlock { | ||
override val type: String = TYPE | ||
|
||
public companion object { | ||
public const val TYPE: String = "resource_link" | ||
} | ||
} | ||
|
||
/** | ||
* Unknown content provided to or from an LLM. | ||
*/ | ||
@Serializable | ||
public data class UnknownContent(override val type: String) : PromptMessageContentMultimodal | ||
public data class UnknownContent(override val type: String) : | ||
ContentBlock, | ||
CreateMessageResultContent, | ||
SamplingMessageContent | ||
|
||
/** | ||
* The contents of a resource, embedded into a prompt or tool call result. | ||
|
@@ -1080,7 +1160,7 @@ public data class EmbeddedResource( | |
* Optional annotations for the client. | ||
*/ | ||
val annotations: Annotations? = null, | ||
) : PromptMessageContent { | ||
) : ContentBlock { | ||
override val type: String = TYPE | ||
|
||
public companion object { | ||
|
@@ -1130,7 +1210,7 @@ public data class Annotations( | |
* Describes a message returned as part of a prompt. | ||
*/ | ||
@Serializable | ||
public data class PromptMessage(val role: Role, val content: PromptMessageContent) | ||
public data class PromptMessage(val role: Role, val content: ContentBlock) | ||
|
||
/** | ||
* The server's response to a prompts/get request from the client. | ||
|
@@ -1282,7 +1362,7 @@ public class ListToolsResult( | |
*/ | ||
@Serializable | ||
public sealed interface CallToolResultBase : ServerResult { | ||
public val content: List<PromptMessageContent> | ||
public val content: List<ContentBlock> | ||
public val structuredContent: JsonObject? | ||
public val isError: Boolean? get() = false | ||
} | ||
|
@@ -1292,7 +1372,7 @@ public sealed interface CallToolResultBase : ServerResult { | |
*/ | ||
@Serializable | ||
public class CallToolResult( | ||
override val content: List<PromptMessageContent>, | ||
override val content: List<ContentBlock>, | ||
override val structuredContent: JsonObject? = null, | ||
override val isError: Boolean? = false, | ||
override val _meta: JsonObject = EmptyJsonObject, | ||
|
@@ -1303,7 +1383,7 @@ public class CallToolResult( | |
*/ | ||
@Serializable | ||
public class CompatibilityCallToolResult( | ||
override val content: List<PromptMessageContent>, | ||
override val content: List<ContentBlock>, | ||
override val structuredContent: JsonObject? = null, | ||
override val isError: Boolean? = false, | ||
override val _meta: JsonObject = EmptyJsonObject, | ||
|
@@ -1448,7 +1528,7 @@ public class ModelPreferences( | |
* Describes a message issued to or received from an LLM API. | ||
*/ | ||
@Serializable | ||
public data class SamplingMessage(val role: Role, val content: PromptMessageContentMultimodal) | ||
public data class SamplingMessage(val role: Role, val content: SamplingMessageContent) | ||
|
||
/** | ||
* A request from the server to sample an LLM via the client. | ||
|
@@ -1530,7 +1610,7 @@ public data class CreateMessageResult( | |
*/ | ||
val stopReason: StopReason? = null, | ||
val role: Role, | ||
val content: PromptMessageContentMultimodal, | ||
val content: CreateMessageResultContent, | ||
override val _meta: JsonObject = EmptyJsonObject, | ||
) : ClientResult | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to add KDoc to all public methods?