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 https://github.com/modelcontextprotocol/kotlin-sdk/issues/111 --------- Co-authored-by: Konstantin Pavlov <1517853+kpavlov@users.noreply.github.com>
This commit is contained in:
parent
6b5f7a7345
commit
b1ba0cd371
9 changed files with 47 additions and 15 deletions
15
README.md
15
README.md
|
|
@ -40,10 +40,23 @@ Add the dependency:
|
|||
|
||||
```kotlin
|
||||
dependencies {
|
||||
// Use the badge above for the latest version
|
||||
// See the badge above for the latest version
|
||||
implementation("io.modelcontextprotocol:kotlin-sdk:$mcpVersion")
|
||||
}
|
||||
```
|
||||
MCP SDK uses [Ktor](https://ktor.io/), but does not come with a specific engine dependency.
|
||||
You should add [Ktor client](https://ktor.io/docs/client-dependencies.html#engine-dependency)
|
||||
and/or [Ktor server](https://ktor.io/docs/client-dependencies.html#engine-dependency) dependency
|
||||
to your project yourself, e.g.:
|
||||
```kotlin
|
||||
dependencies {
|
||||
// for client:
|
||||
implementation("io.ktor:ktor-client-cio:$ktorVersion")
|
||||
// for server:
|
||||
implementation("io.ktor:ktor-server-netty:$ktorVersion")
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ kotlinx-collections-immutable = { group = "org.jetbrains.kotlinx", name = "kotli
|
|||
kotlin-logging = { group = "io.github.oshai", name = "kotlin-logging", version.ref = "logging" }
|
||||
|
||||
# Ktor
|
||||
ktor-client-cio = { group = "io.ktor", name = "ktor-client-cio", version.ref = "ktor" }
|
||||
ktor-client-core = { group = "io.ktor", name = "ktor-client-core", version.ref = "ktor" }
|
||||
ktor-server-sse = { group = "io.ktor", name = "ktor-server-sse", version.ref = "ktor" }
|
||||
ktor-server-websockets = { group = "io.ktor", name = "ktor-server-websockets", version.ref = "ktor" }
|
||||
ktor-server-cio = { group = "io.ktor", name = "ktor-server-cio", version.ref = "ktor" }
|
||||
ktor-server-core = { group = "io.ktor", name = "ktor-server-core", version.ref = "ktor" }
|
||||
|
||||
# Testing
|
||||
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
|
|||
kotest-assertions-json = { group = "io.kotest", name = "kotest-assertions-json", version.ref = "kotest" }
|
||||
|
||||
# Samples
|
||||
ktor-client-cio = { group = "io.ktor", name = "ktor-client-cio", version.ref = "ktor" }
|
||||
ktor-server-cio = { group = "io.ktor", name = "ktor-server-cio", version.ref = "ktor" }
|
||||
mcp-kotlin = { group = "io.modelcontextprotocol", name = "kotlin-sdk", version.ref = "mcp-kotlin" }
|
||||
anthropic-java = { group = "com.anthropic", name = "anthropic-java", version.ref = "anthropic" }
|
||||
ktor-client-content-negotiation = { group = "io.ktor", name = "ktor-client-content-negotiation", version.ref = "ktor" }
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ kotlin {
|
|||
commonMain {
|
||||
dependencies {
|
||||
api(project(":kotlin-sdk-core"))
|
||||
api(libs.ktor.client.cio)
|
||||
api(libs.ktor.client.core)
|
||||
implementation(libs.kotlin.logging)
|
||||
}
|
||||
}
|
||||
|
|
@ -43,6 +43,7 @@ kotlin {
|
|||
implementation(kotlin("test"))
|
||||
implementation(libs.ktor.client.mock)
|
||||
implementation(libs.kotlinx.coroutines.test)
|
||||
runtimeOnly(libs.slf4j.simple)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,5 +47,11 @@ kotlin {
|
|||
implementation(libs.kotest.assertions.json)
|
||||
}
|
||||
}
|
||||
|
||||
jvmTest {
|
||||
dependencies {
|
||||
runtimeOnly(libs.slf4j.simple)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ kotlin {
|
|||
commonMain {
|
||||
dependencies {
|
||||
api(project(":kotlin-sdk-core"))
|
||||
api(libs.ktor.server.cio)
|
||||
api(libs.ktor.server.core)
|
||||
api(libs.ktor.server.sse)
|
||||
implementation(libs.kotlin.logging)
|
||||
}
|
||||
|
|
@ -21,7 +21,12 @@ kotlin {
|
|||
dependencies {
|
||||
implementation(kotlin("test"))
|
||||
implementation(libs.kotlinx.coroutines.test)
|
||||
implementation(libs.slf4j.simple)
|
||||
}
|
||||
}
|
||||
|
||||
jvmTest {
|
||||
dependencies {
|
||||
runtimeOnly(libs.slf4j.simple)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,17 +13,18 @@ kotlin {
|
|||
dependencies {
|
||||
implementation(project(":kotlin-sdk"))
|
||||
implementation(kotlin("test"))
|
||||
implementation(libs.ktor.server.test.host)
|
||||
implementation(libs.kotlinx.coroutines.test)
|
||||
implementation(libs.kotest.assertions.json)
|
||||
implementation(libs.kotlin.logging)
|
||||
implementation(libs.kotlinx.coroutines.test)
|
||||
implementation(libs.ktor.client.cio)
|
||||
implementation(libs.ktor.server.cio)
|
||||
implementation(libs.ktor.server.test.host)
|
||||
}
|
||||
}
|
||||
jvmTest {
|
||||
dependencies {
|
||||
implementation(kotlin("test-junit5"))
|
||||
implementation(libs.kotlin.logging)
|
||||
implementation(libs.ktor.server.cio)
|
||||
implementation(libs.ktor.client.cio)
|
||||
runtimeOnly(libs.slf4j.simple)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,9 @@ version = "0.1.0"
|
|||
|
||||
dependencies {
|
||||
implementation(libs.mcp.kotlin)
|
||||
implementation(libs.slf4j.simple)
|
||||
implementation(libs.ktor.client.cio)
|
||||
implementation(libs.anthropic.java)
|
||||
implementation(libs.slf4j.simple)
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ kotlin {
|
|||
sourceSets {
|
||||
commonMain.dependencies {
|
||||
implementation(libs.mcp.kotlin)
|
||||
implementation(libs.ktor.server.cio)
|
||||
}
|
||||
jvmMain.dependencies {
|
||||
implementation(libs.slf4j.simple)
|
||||
|
|
|
|||
|
|
@ -13,15 +13,17 @@ repositories {
|
|||
mavenCentral()
|
||||
}
|
||||
|
||||
|
||||
group = "org.example"
|
||||
version = "0.1.0"
|
||||
|
||||
dependencies {
|
||||
implementation(libs.mcp.kotlin)
|
||||
implementation(libs.slf4j.simple)
|
||||
implementation(libs.ktor.client.content.negotiation)
|
||||
implementation(libs.ktor.serialization.kotlinx.json)
|
||||
implementation(libs.mcp.kotlin)
|
||||
implementation(libs.ktor.server.cio)
|
||||
implementation(libs.ktor.client.cio)
|
||||
implementation(libs.slf4j.simple)
|
||||
|
||||
testImplementation(kotlin("test"))
|
||||
testImplementation(libs.kotlinx.coroutines.test)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue