-
Notifications
You must be signed in to change notification settings - Fork 147
Add missing title, size and annotation attributes on Resource/ResourceTemplate and other types #219
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
Merged
devcrocod
merged 4 commits into
modelcontextprotocol:main
from
ptitjes:feat/159-resource-missing-attributes
Aug 19, 2025
+168
−20
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -17,6 +17,8 @@ import kotlin.concurrent.atomics.AtomicLong | |||||
import kotlin.concurrent.atomics.ExperimentalAtomicApi | ||||||
import kotlin.concurrent.atomics.incrementAndFetch | ||||||
import kotlin.jvm.JvmInline | ||||||
import kotlin.time.ExperimentalTime | ||||||
import kotlin.time.Instant | ||||||
|
||||||
public const val LATEST_PROTOCOL_VERSION: String = "2025-03-26" | ||||||
|
||||||
|
@@ -710,6 +712,18 @@ public data class Resource( | |||||
* The MIME type of this resource, if known. | ||||||
*/ | ||||||
val mimeType: String?, | ||||||
/** | ||||||
* The optional human-readable name of this resource for display purposes. | ||||||
*/ | ||||||
val title: String? = null, | ||||||
/** | ||||||
* The optional size of this resource in bytes, if known. | ||||||
*/ | ||||||
val size: Long? = null, | ||||||
/** | ||||||
* Optional annotations for the client. | ||||||
*/ | ||||||
val annotations: Annotations? = null, | ||||||
) | ||||||
|
||||||
/** | ||||||
|
@@ -738,6 +752,14 @@ public data class ResourceTemplate( | |||||
* The MIME type for all resources that match this template. This should only be included if all resources matching this template have the same type. | ||||||
*/ | ||||||
val mimeType: String?, | ||||||
/** | ||||||
* The optional human-readable name of this resource for display purposes. | ||||||
*/ | ||||||
val title: String? = null, | ||||||
/** | ||||||
* Optional annotations for the client. | ||||||
*/ | ||||||
val annotations: Annotations? = null, | ||||||
) | ||||||
|
||||||
/** | ||||||
|
@@ -971,6 +993,11 @@ public data class TextContent( | |||||
* The text content of the message. | ||||||
*/ | ||||||
val text: String? = null, | ||||||
|
||||||
/** | ||||||
* Optional annotations for the client. | ||||||
*/ | ||||||
val annotations: Annotations? = null, | ||||||
) : PromptMessageContentMultimodal { | ||||||
override val type: String = TYPE | ||||||
|
||||||
|
@@ -993,6 +1020,11 @@ public data class ImageContent( | |||||
* The MIME type of the image. Different providers may support different image types. | ||||||
*/ | ||||||
val mimeType: String, | ||||||
|
||||||
/** | ||||||
* Optional annotations for the client. | ||||||
*/ | ||||||
val annotations: Annotations? = null, | ||||||
) : PromptMessageContentMultimodal { | ||||||
override val type: String = TYPE | ||||||
|
||||||
|
@@ -1015,6 +1047,11 @@ public data class AudioContent( | |||||
* The MIME type of the audio. Different providers may support different audio types. | ||||||
*/ | ||||||
val mimeType: String, | ||||||
|
||||||
/** | ||||||
* Optional annotations for the client. | ||||||
*/ | ||||||
val annotations: Annotations? = null, | ||||||
) : PromptMessageContentMultimodal { | ||||||
override val type: String = TYPE | ||||||
|
||||||
|
@@ -1033,7 +1070,17 @@ public data class UnknownContent(override val type: String) : PromptMessageConte | |||||
* The contents of a resource, embedded into a prompt or tool call result. | ||||||
*/ | ||||||
@Serializable | ||||||
public data class EmbeddedResource(val resource: ResourceContents) : PromptMessageContent { | ||||||
public data class EmbeddedResource( | ||||||
/** | ||||||
* The contents of the embedded resource. | ||||||
*/ | ||||||
val resource: ResourceContents, | ||||||
|
||||||
/** | ||||||
* Optional annotations for the client. | ||||||
*/ | ||||||
val annotations: Annotations? = null, | ||||||
) : PromptMessageContent { | ||||||
override val type: String = TYPE | ||||||
|
||||||
public companion object { | ||||||
|
@@ -1051,6 +1098,34 @@ public enum class Role { | |||||
assistant, | ||||||
} | ||||||
|
||||||
/** | ||||||
* Optional annotations for the client. | ||||||
* The client can use annotations to inform how objects are used or displayed. | ||||||
*/ | ||||||
@Serializable | ||||||
public data class Annotations( | ||||||
/** | ||||||
* Describes who the intended customer of this object or data is. | ||||||
*/ | ||||||
val audience: List<Role>?, | ||||||
/** | ||||||
* The moment the resource was last modified. | ||||||
*/ | ||||||
@OptIn(ExperimentalTime::class) | ||||||
val lastModified: Instant?, | ||||||
/** | ||||||
* Describes how important this data is for operating the server. | ||||||
* | ||||||
* A value of 1.0 means "most important", and indicates that the data is effectively required, | ||||||
* while 0.0 means "less important", and indicates that the data is entirely optional. | ||||||
*/ | ||||||
val priority: Double?, | ||||||
) { | ||||||
init { | ||||||
require(priority == null || priority in 0.0..1.0) { "Priority must be between 0.0 and 1.0" } | ||||||
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. [nitpick] The validation logic could be more explicit about inclusive bounds. Consider using a more descriptive error message that clarifies both bounds are inclusive: "Priority must be between 0.0 and 1.0 (inclusive)"
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
} | ||||||
} | ||||||
|
||||||
/** | ||||||
* Describes a message returned as part of a prompt. | ||||||
*/ | ||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.