Skip to content

Conversation

ptitjes
Copy link
Contributor

@ptitjes ptitjes commented Aug 7, 2025

This PR adds:

  • missing Annotations type
  • missing attributes:
    • Resource.title, Resource.size and Resource.annotations
    • ResourceTemplate.title and ResourceTemplate.annotations
    • TextContent.annotations
    • ImageContent.annotations
    • AudioContent.annotations
    • EmeddedResource.annotations

Fixes #159.

(PS: the solution I described in the issue was wrong. I checked with the specification's schema to be sure of the changes.)

Motivation and Context

Adherence to the latest specification version, cf. #159.

How Has This Been Tested?

I only added a serialization/deserialization test for Annotations to ensure that the serializer for kotlin.time.Instant was indeed present. Cf. below in "Additional Context".

Breaking Changes

N/A

Types of changes

  • 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

Checklist

  • I have read the MCP Documentation
  • 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

I took two liberties:

  • used kotlin.time.Instant to represent the Annotations.lastModified, as this must be encoded as an ISO 8601 date.
  • added a check for Annotations.priority to verify that it is between 0 and 1.

@ptitjes ptitjes force-pushed the feat/159-resource-missing-attributes branch from faeebc5 to 4cd3f6e Compare August 7, 2025 17:34
@devcrocod devcrocod requested review from Copilot and devcrocod August 11, 2025 08:17
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds missing attributes and the Annotations type to align the Kotlin SDK with the latest MCP specification. The changes include adding missing attributes to several resource and content types, implementing the new Annotations data class, and ensuring proper serialization support.

  • Adds the missing Annotations type with validation for priority values
  • Extends Resource, ResourceTemplate, and various content types with missing attributes
  • Includes serialization/deserialization tests for the new Annotations type

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
kotlin-sdk-core/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types.kt Implements the Annotations data class and adds missing attributes to resource and content types
kotlin-sdk-core/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/TypesTest.kt Adds test coverage for Annotations serialization/deserialization
kotlin-sdk-core/api/kotlin-sdk-core.api Updates API signatures to reflect the new attributes and Annotations type

val priority: Double?,
) {
init {
require(priority == null || priority in 0.0..1.0) { "Priority must be between 0.0 and 1.0" }
Copy link
Preview

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

The 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
require(priority == null || priority in 0.0..1.0) { "Priority must be between 0.0 and 1.0" }
require(priority == null || priority in 0.0..1.0) { "Priority must be between 0.0 and 1.0 (inclusive)" }

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@devcrocod devcrocod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!
lgtm

I have just one small question

@devcrocod devcrocod force-pushed the feat/159-resource-missing-attributes branch from 4cd3f6e to c7c5b5a Compare August 11, 2025 08:28
@devcrocod devcrocod merged commit ad82052 into modelcontextprotocol:main Aug 19, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add missing resource name, title and annotations
2 participants