Skip to content

Conversation

@kpavlov
Copy link
Owner

@kpavlov kpavlov commented Sep 8, 2025

  • Downgrade Kotlin 2.2.0->2.1.21 to make broader adoption possible. Update Kotlin compiler configuration
  • Add kotlinx-datetime dependency. Switch from kotlin.time.Instant to kotlinx.datetime.Instant.
  • Downgrade atomicfu 0.29.0->0.28.0
  • Downgrade kotlinx-serialization 1.9.0->1.8.1

- Downgrade Kotlin 2.2.0->2.1.21 to make broader adoption possible. Update Kotlin compiler configuration
- Add [kotlinx-datetime](https://github.com/Kotlin/kotlinx-datetime) dependency. Switch from `kotlin.time.Instant` to `kotlinx.datetime.Instant`.
- Downgrade atomicfu 0.29.0->0.28.0
- Downgrade kotlinx-serialization 1.9.0->1.8.1
@kpavlov kpavlov marked this pull request as ready for review September 8, 2025 07:29
@coderabbitai
Copy link

coderabbitai bot commented Sep 8, 2025

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Exposed a public LIB_VERSION constant.
    • Added kotlinx-datetime as an API dependency for date-time utilities.
  • Refactor

    • Migrated Annotations.lastModified from kotlin.time.Instant to kotlinx.datetime.Instant (breaking change for consumers).
    • Minor enum formatting and annotation cleanups.
  • Documentation

    • Added build prerequisites: Xcode/Command Line Tools for Mac/iOS; Node.js for JS/Wasm.
    • Updated README badges (added Kotlin badge, simplified Platforms badge).
  • Chores

    • Aligned to Kotlin 2.1.x and JVM 21, enabled explicit API mode, updated dependency versions, and adjusted Kotlin/Native and JS settings.

Walkthrough

Documentation updates, Gradle/KMP configuration changes targeting Kotlin 2.1, introduction of explicit API mode, generated public LIB_VERSION constant, dependency/version catalog adjustments, exposure of kotlinx-datetime as an API dependency, and migration from kotlin.time.Instant to kotlinx.datetime.Instant in core types and tests.

Changes

Cohort / File(s) Summary
Docs updates
CONTRIBUTING.md, README.md
Add platform prerequisites (Xcode/CLT, Node.js) and adjust README badges (new Kotlin badge; “Platforms” simplified to “Native”).
Multiplatform build config & generated version
buildSrc/src/main/kotlin/mcp.multiplatform.gradle.kts
Target Kotlin 2.1 language/api; set coreLibrariesVersion=2.1.21; enable explicit API (Strict); JVM toolchain 21 and parameter metadata; extra compiler warnings; add -Xwhen-guards; generate public LIB_VERSION via LibVersion.kt and include in commonMain sources.
Gradle properties
gradle.properties
Add kotlin.native.ignoreDisabledTargets=true and kotlin.js.yarn=false.
Version catalog adjustments
gradle/libs.versions.toml
Downgrade Kotlin to 2.1.21; adjust library versions (atomicfu 0.28.0, kotlinx-io 0.7.0); reintroduce serialization=1.8.1; add libraries: kotlinx-datetime, kotlin-logging, kotlinx-collections-immutable; restore kotlinx-serialization-json under serialization. Remove transient entries (e.g., kotest version, jreleaser, binaryCompatibilityValidatorPlugin).
Core module dependency exposure
kotlin-sdk-core/build.gradle.kts
Add api(libs.kotlinx.datetime) to commonMain dependencies.
Core types migration & annotations
kotlin-sdk-core/src/commonMain/kotlin/.../types.kt
Change Annotations.lastModified from kotlin.time.Instant? to kotlinx.datetime.Instant?; remove ExperimentalTime opt-in; add @Suppress("EnumEntryName") to enums; minor enum formatting; remove one @Suppress("CanBeParameter"); add doc blocks; adjust imports.
Tests import alignment
kotlin-sdk-core/src/commonTest/kotlin/.../TypesTest.kt
Replace kotlin.time.Instant import with kotlinx.datetime.Instant.

Sequence Diagram(s)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch kotlin-2.1

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a23856e and 65f0045.

📒 Files selected for processing (8)
  • CONTRIBUTING.md (1 hunks)
  • README.md (1 hunks)
  • buildSrc/src/main/kotlin/mcp.multiplatform.gradle.kts (2 hunks)
  • gradle.properties (1 hunks)
  • gradle/libs.versions.toml (2 hunks)
  • kotlin-sdk-core/build.gradle.kts (1 hunks)
  • kotlin-sdk-core/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types.kt (14 hunks)
  • kotlin-sdk-core/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/TypesTest.kt (1 hunks)
🔇 Additional comments (9)
gradle/libs.versions.toml (2)

35-41: Library aliases look good; confirm API exposure intent.

kotlinx-datetime is added and will be API-exposed by kotlin-sdk-core; that matches the Instant type change.


3-19: All checked libraries are compatible with Kotlin 2.1.21.
atomicfu 0.28.0, kotlinx-datetime 0.6.2, kotlinx-serialization-json 1.8.1, kotlinx-coroutines-core 1.10.2, Ktor 3.2.3, and binary-compatibility-validator 0.18.1 have been verified against Kotlin 2.1.21 with no conflicts.

gradle.properties (1)

10-10: native.ignoreDisabledTargets: confirm desired behavior in CI.

This hides errors for disabled targets; ensure CI still exercises the intended matrix so regressions aren’t masked.

kotlin-sdk-core/build.gradle.kts (1)

37-37: Expose kotlinx-datetime via API — LGTM.

Matches the public Instant type usage in commonMain.

buildSrc/src/main/kotlin/mcp.multiplatform.gradle.kts (2)

49-51: Revisit JVM target level.

You’re compiling with JDK 21 but emitting Java 8 bytecode. If consumers and dependencies allow, bumping to 11 or 17 can unlock better inlining and APIs. If 1.8 is required, keep as-is.


69-71: Generated LibVersion source wiring — LGTM.

Task outputs are correctly added as a sources dir.

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

4-4: Switch to kotlinx.datetime.Instant — LGTM; confirm JSON module setup.

kotlinx.datetime types are @serializable; typically no extra serializersModule is needed. Ensure McpJson doesn’t override it in a way that drops Instant’s serializer.


1495-1501: Enum casing suppression — LGTM.

Suppressing EnumEntryName aligns with the wire format.


1743-1744: Action enum suppression — LGTM.

Matches lower-case protocol values.

Comment on lines +35 to +46
compilerOptions {
languageVersion = KOTLIN_2_1
apiVersion = KOTLIN_2_1
// TODO: allWarningsAsErrors = true
extraWarnings = true
freeCompilerArgs =
listOf(
"-Xwhen-guards",
)
}
coreLibrariesVersion = "2.1.21"

Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Compiler config for Kotlin 2.1 — LGTM; consider enabling Werror.

Settings look correct for 2.1. Consider turning on allWarningsAsErrors once CI is green.

-        // TODO: allWarningsAsErrors = true
+        // Enable once the tree is clean
+        // allWarningsAsErrors = true
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
compilerOptions {
languageVersion = KOTLIN_2_1
apiVersion = KOTLIN_2_1
// TODO: allWarningsAsErrors = true
extraWarnings = true
freeCompilerArgs =
listOf(
"-Xwhen-guards",
)
}
coreLibrariesVersion = "2.1.21"
compilerOptions {
languageVersion = KOTLIN_2_1
apiVersion = KOTLIN_2_1
// Enable once the tree is clean
// allWarningsAsErrors = true
extraWarnings = true
freeCompilerArgs =
listOf(
"-Xwhen-guards",
)
}
coreLibrariesVersion = "2.1.21"
🤖 Prompt for AI Agents
In buildSrc/src/main/kotlin/mcp.multiplatform.gradle.kts around lines 35 to 46,
the TODO for Werror remains; enable allWarningsAsErrors by setting
allWarningsAsErrors = true (or, if you want safer rollout, read a Gradle/project
property like "enableWerror" and set allWarningsAsErrors =
project.findProperty("enableWerror") == "true") so warnings are promoted to
errors once CI is verified; ensure the property default is false in CI until you
flip it.

Comment on lines 62 to 63
js { nodejs() }
wasmJs { nodejs() }
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

JS/Wasm target setup: ensure consistency with module-level kotlin blocks.

This plugin sets js/wasm nodejs; kotlin-sdk-core also configures js { browser(); nodejs() }. Double-configuration is usually fine, but avoid divergent target declarations across plugin and module.

-    js { nodejs() }
-    wasmJs { nodejs() }
+    // Consider centralizing target declarations either here or per-module to prevent drift.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In buildSrc/src/main/kotlin/mcp.multiplatform.gradle.kts around lines 62-63, the
plugin declares js { nodejs() } and wasmJs { nodejs() } which diverges from
module-level kotlin blocks that use js { browser(); nodejs() }; update the
plugin to match the module-level targets so declarations stay consistent —
either add browser() to the plugin's js target (js { browser(); nodejs() }) or
remove the js nodejs() from the plugin and let modules declare both browser()
and nodejs(); pick one approach and apply it consistently across plugin and
modules, remove duplicate/conflicting declarations, and add a short comment
explaining the chosen centralization.

Comment on lines +76 to 78
* To build for MacOS/iOS targets, Xcode/Command Line Tools should be installed. See Apple Developer [documentation](https://developer.apple.com/documentation/xcode/downloading-and-installing-additional-xcode-components) for details.
* To build JS/Wasm targets, [Node.js](https://nodejs.org/) must be installed.
* The project can be opened in IntelliJ IDEA without additional prerequisites.
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Specify minimum toolchain versions and quick install hints.

Add minimum versions (e.g., Xcode ≥ 15.x for current Kotlin/Native, Node.js ≥ LTS 18/20) and brief install commands to reduce setup friction.

What minimum versions are you targeting for:

  • Kotlin/Native toolchains on macOS/iOS (Xcode/CLT)?
  • Node.js for JS/Wasm builds?
🤖 Prompt for AI Agents
CONTRIBUTING.md lines 76-78: add explicit minimum toolchain versions and quick
install hints — target Xcode/Command Line Tools >= 15.x for Kotlin/Native on
macOS/iOS and Node.js LTS (preferably 18.x or 20.x) for JS/Wasm; update the
three bullets to include these minimum versions and a one-line install hint each
(e.g., obtain Xcode from the App Store and install the Command Line Tools, or
install Xcode via Homebrew Cask if preferred; use nvm or your package manager to
install the Node.js LTS version) and include a short note referencing where to
verify installed versions (xcodebuild -version / node -v) so contributors can
confirm they meet the minimums.

Comment on lines +14 to +15
# Build JS targets using npm package manager https://kotlinlang.org/docs/js-project-setup.html#npm-dependencies
kotlin.js.yarn=false
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Switching Kotlin/JS to npm: document Node/NPM expectations.

With yarn disabled, ensure Node and npm are available in CI and optionally pin Node via a tool (e.g., actions/setup-node) to avoid non-reproducible builds.

🤖 Prompt for AI Agents
In gradle.properties around lines 14-15, you're switching Kotlin/JS to npm
(kotlin.js.yarn=false) but haven't documented or enforced Node/npm in CI; add a
short comment in gradle.properties stating the required Node version and that
npm must be available, and then update CI workflows (e.g., GitHub Actions) to
install and pin Node by adding actions/setup-node with a specific semver (or
exact) version and ensure npm is present before the build; verify the pipeline
runs npm --version and npm ci (or npm install) as part of the job to guarantee
reproducible builds.

package io.modelcontextprotocol.kotlin.sdk

import io.modelcontextprotocol.kotlin.sdk.shared.McpJson
import kotlinx.datetime.Instant
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Remove unused ExperimentalTime opt-in.

After migrating to kotlinx.datetime.Instant, the ExperimentalTime annotation/import are unnecessary.

-import kotlin.time.ExperimentalTime
@@
-    @OptIn(ExperimentalTime::class)
     @Test
     fun `should serialize and deserialize annotations correctly`() {

Also applies to: 10-10, 241-241

🤖 Prompt for AI Agents
In
kotlin-sdk-core/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/TypesTest.kt
around line 4 (also apply same change at lines 10 and 241), remove the
now-unused ExperimentalTime opt-in import/annotation introduced before migration
to kotlinx.datetime.Instant; delete the import and any
@OptIn(ExperimentalTime::class) usages or annotations at those lines so the file
no longer references ExperimentalTime.

@@ -1,7 +1,8 @@
# MCP Kotlin SDK

[![Kotlin](https://img.shields.io/badge/kotlin-2.1-blue.svg?logo=kotlin)](http://kotlinlang.org)
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Align Kotlin badge with actual version (2.1.21).

Badge shows "2.1"; suggest "2.1.21" to match libs.versions.toml and avoid drift.

-[![Kotlin](https://img.shields.io/badge/kotlin-2.1-blue.svg?logo=kotlin)](http://kotlinlang.org)
+[![Kotlin](https://img.shields.io/badge/kotlin-2.1.21-blue.svg?logo=kotlin)](http://kotlinlang.org)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
[![Kotlin](https://img.shields.io/badge/kotlin-2.1-blue.svg?logo=kotlin)](http://kotlinlang.org)
[![Kotlin](https://img.shields.io/badge/kotlin-2.1.21-blue.svg?logo=kotlin)](http://kotlinlang.org)
🤖 Prompt for AI Agents
In README.md around line 3, the Kotlin version displayed in the shields.io badge
is "2.1" but should match libs.versions.toml ("2.1.21"); update the badge text
and URL segment from "kotlin-2.1-blue.svg" to "kotlin-2.1.21-blue.svg" (and any
other occurrences of 2.1 in the badge markup) so the badge displays 2.1.21 and
stays in sync with project versions.

[![Kotlin](https://img.shields.io/badge/kotlin-2.1-blue.svg?logo=kotlin)](http://kotlinlang.org)
[![Kotlin Multiplatform](https://img.shields.io/badge/Kotlin-Multiplatform-blueviolet?logo=kotlin)](https://kotlinlang.org/docs/multiplatform.html)
[![Platforms](https://img.shields.io/badge/Platforms-JVM%20%7C%20Wasm%2FJS%20%7C%20Native%20(iOS%2FiOS%20Simulator)-blue)](https://kotlinlang.org/docs/multiplatform.html)
[![Platforms](https://img.shields.io/badge/Platforms-JVM%20%7C%20Wasm%2FJS%20%7C%20Native-blue)](https://kotlinlang.org/docs/multiplatform.html)
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Clarify “Native” scope or list targets.

Consider mentioning the concrete KMP native targets (iOS/tvOS/watchOS/macOS, Linux, Windows) to set expectations, or link to a section that enumerates them.

🤖 Prompt for AI Agents
In README.md around line 5, the "Native" badge is ambiguous; update the badge
text or nearby sentence to either list the concrete Kotlin Multiplatform native
targets (iOS, tvOS, watchOS, macOS, Linux, Windows) or add a short parenthetical
or link to a section that enumerates supported native targets so readers know
the exact scope; keep wording concise and consistent with existing badge/link
style.

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.

2 participants