Skip to content

Commit b1ba0cd

Browse files
Remove dependency on CIO engine (#223)
<!-- Provide a brief summary of your changes --> Replace the CIO dependency with only server/client core dependency. ## Motivation and Context <!-- Why is this change needed? What problem does it solve? --> In order to minimize the size of package. There are probably other existing engines like Netty/Tomcat(server) or Java/OkHttp/Apache(client) in the classpath. So we can reuse existing infrastructure. ## How Has This Been Tested? <!-- Have you tested this in a real application? Which scenarios were tested? --> I have run: - kotlin-sdk-client: jvmTest, jsTest - kotlin-sdk-test: jvmTest, jsTest - kotlin-sdk-server: allTests - All `build` of samples I have an issue about `samples/kotlin-mcp-server`. `io.modelcontextprotocol` is not found in `commonMain`. ## Breaking Changes <!-- Will users need to update their code or configurations? --> Yes. They need to `implementation` CIO engine manually if they use it in their app. ## 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) - [x] Breaking change (fix or feature that would cause existing functionality to change) - [x] Documentation update ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [ ] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [ ] My code follows the repository's style guidelines - [x] 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 --> closes #111 --------- Co-authored-by: Konstantin Pavlov <[email protected]>
1 parent 6b5f7a7 commit b1ba0cd

File tree

9 files changed

+47
-15
lines changed

9 files changed

+47
-15
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,23 @@ Add the dependency:
4040

4141
```kotlin
4242
dependencies {
43-
// Use the badge above for the latest version
43+
// See the badge above for the latest version
4444
implementation("io.modelcontextprotocol:kotlin-sdk:$mcpVersion")
4545
}
4646
```
47+
MCP SDK uses [Ktor](https://ktor.io/), but does not come with a specific engine dependency.
48+
You should add [Ktor client](https://ktor.io/docs/client-dependencies.html#engine-dependency)
49+
and/or [Ktor server](https://ktor.io/docs/client-dependencies.html#engine-dependency) dependency
50+
to your project yourself, e.g.:
51+
```kotlin
52+
dependencies {
53+
// for client:
54+
implementation("io.ktor:ktor-client-cio:$ktorVersion")
55+
// for server:
56+
implementation("io.ktor:ktor-server-netty:$ktorVersion")
57+
58+
}
59+
```
4760

4861
## Quick Start
4962

gradle/libs.versions.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ kotlinx-collections-immutable = { group = "org.jetbrains.kotlinx", name = "kotli
3939
kotlin-logging = { group = "io.github.oshai", name = "kotlin-logging", version.ref = "logging" }
4040

4141
# Ktor
42-
ktor-client-cio = { group = "io.ktor", name = "ktor-client-cio", version.ref = "ktor" }
42+
ktor-client-core = { group = "io.ktor", name = "ktor-client-core", version.ref = "ktor" }
4343
ktor-server-sse = { group = "io.ktor", name = "ktor-server-sse", version.ref = "ktor" }
4444
ktor-server-websockets = { group = "io.ktor", name = "ktor-server-websockets", version.ref = "ktor" }
45-
ktor-server-cio = { group = "io.ktor", name = "ktor-server-cio", version.ref = "ktor" }
45+
ktor-server-core = { group = "io.ktor", name = "ktor-server-core", version.ref = "ktor" }
4646

4747
# Testing
4848
kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "coroutines" }
@@ -52,6 +52,8 @@ slf4j-simple = { group = "org.slf4j", name = "slf4j-simple", version.ref = "slf4
5252
kotest-assertions-json = { group = "io.kotest", name = "kotest-assertions-json", version.ref = "kotest" }
5353

5454
# Samples
55+
ktor-client-cio = { group = "io.ktor", name = "ktor-client-cio", version.ref = "ktor" }
56+
ktor-server-cio = { group = "io.ktor", name = "ktor-server-cio", version.ref = "ktor" }
5557
mcp-kotlin = { group = "io.modelcontextprotocol", name = "kotlin-sdk", version.ref = "mcp-kotlin" }
5658
anthropic-java = { group = "com.anthropic", name = "anthropic-java", version.ref = "anthropic" }
5759
ktor-client-content-negotiation = { group = "io.ktor", name = "ktor-client-content-negotiation", version.ref = "ktor" }

kotlin-sdk-client/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ kotlin {
3333
commonMain {
3434
dependencies {
3535
api(project(":kotlin-sdk-core"))
36-
api(libs.ktor.client.cio)
36+
api(libs.ktor.client.core)
3737
implementation(libs.kotlin.logging)
3838
}
3939
}
@@ -43,6 +43,7 @@ kotlin {
4343
implementation(kotlin("test"))
4444
implementation(libs.ktor.client.mock)
4545
implementation(libs.kotlinx.coroutines.test)
46+
runtimeOnly(libs.slf4j.simple)
4647
}
4748
}
4849
}

kotlin-sdk-core/build.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,11 @@ kotlin {
4747
implementation(libs.kotest.assertions.json)
4848
}
4949
}
50+
51+
jvmTest {
52+
dependencies {
53+
runtimeOnly(libs.slf4j.simple)
54+
}
55+
}
5056
}
5157
}

kotlin-sdk-server/build.gradle.kts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ kotlin {
1111
commonMain {
1212
dependencies {
1313
api(project(":kotlin-sdk-core"))
14-
api(libs.ktor.server.cio)
14+
api(libs.ktor.server.core)
1515
api(libs.ktor.server.sse)
1616
implementation(libs.kotlin.logging)
1717
}
@@ -21,7 +21,12 @@ kotlin {
2121
dependencies {
2222
implementation(kotlin("test"))
2323
implementation(libs.kotlinx.coroutines.test)
24-
implementation(libs.slf4j.simple)
24+
}
25+
}
26+
27+
jvmTest {
28+
dependencies {
29+
runtimeOnly(libs.slf4j.simple)
2530
}
2631
}
2732
}

kotlin-sdk-test/build.gradle.kts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@ kotlin {
1313
dependencies {
1414
implementation(project(":kotlin-sdk"))
1515
implementation(kotlin("test"))
16-
implementation(libs.ktor.server.test.host)
17-
implementation(libs.kotlinx.coroutines.test)
1816
implementation(libs.kotest.assertions.json)
17+
implementation(libs.kotlin.logging)
18+
implementation(libs.kotlinx.coroutines.test)
19+
implementation(libs.ktor.client.cio)
20+
implementation(libs.ktor.server.cio)
21+
implementation(libs.ktor.server.test.host)
1922
}
2023
}
2124
jvmTest {
2225
dependencies {
2326
implementation(kotlin("test-junit5"))
24-
implementation(libs.kotlin.logging)
25-
implementation(libs.ktor.server.cio)
26-
implementation(libs.ktor.client.cio)
27+
runtimeOnly(libs.slf4j.simple)
2728
}
2829
}
2930
}

samples/kotlin-mcp-client/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ version = "0.1.0"
1313

1414
dependencies {
1515
implementation(libs.mcp.kotlin)
16-
implementation(libs.slf4j.simple)
16+
implementation(libs.ktor.client.cio)
1717
implementation(libs.anthropic.java)
18+
implementation(libs.slf4j.simple)
1819
}
1920

2021
tasks.test {

samples/kotlin-mcp-server/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ kotlin {
4444
sourceSets {
4545
commonMain.dependencies {
4646
implementation(libs.mcp.kotlin)
47+
implementation(libs.ktor.server.cio)
4748
}
4849
jvmMain.dependencies {
4950
implementation(libs.slf4j.simple)

samples/weather-stdio-server/build.gradle.kts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ repositories {
1313
mavenCentral()
1414
}
1515

16-
1716
group = "org.example"
1817
version = "0.1.0"
1918

2019
dependencies {
21-
implementation(libs.mcp.kotlin)
22-
implementation(libs.slf4j.simple)
2320
implementation(libs.ktor.client.content.negotiation)
2421
implementation(libs.ktor.serialization.kotlinx.json)
22+
implementation(libs.mcp.kotlin)
23+
implementation(libs.ktor.server.cio)
24+
implementation(libs.ktor.client.cio)
25+
implementation(libs.slf4j.simple)
26+
2527
testImplementation(kotlin("test"))
2628
testImplementation(libs.kotlinx.coroutines.test)
2729
}

0 commit comments

Comments
 (0)