Skip to content

Commit b785490

Browse files
committed
Refactor integration tests
- Remove unused `TestUtils` utility class. - Replace `runTest` with `runBlocking` in test cases. - Adjust imports and formatting for consistency. - Add `Awaitility` dependency for dynamic server setup. - Update `Duration` usage from milliseconds to seconds. - Minor configuration and code formatting updates.
1 parent be22708 commit b785490

File tree

34 files changed

+274
-266
lines changed

34 files changed

+274
-266
lines changed

buildSrc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ dependencies {
1313
implementation(libs.kotlinx.atomicfu.gradle)
1414
implementation(libs.dokka.gradle)
1515
implementation(libs.jreleaser.gradle)
16-
}
16+
}

buildSrc/settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ dependencyResolutionManagement {
44
from(files("../gradle/libs.versions.toml"))
55
}
66
}
7-
}
7+
}

buildSrc/src/main/kotlin/mcp.dokka.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ dokka {
2020
dokkaPublications.html {
2121
outputDirectory = rootProject.layout.projectDirectory.dir("docs/${project.name}")
2222
}
23-
}
23+
}

buildSrc/src/main/kotlin/mcp.jreleaser.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ jreleaser {
3434
if (publication is MavenPublication) {
3535
val pubName = publication.name
3636

37-
if (!pubName.contains("jvm", ignoreCase = true)
38-
&& !pubName.contains("metadata", ignoreCase = true)
39-
&& !pubName.contains("kotlinMultiplatform", ignoreCase = true)
37+
if (!pubName.contains("jvm", ignoreCase = true) &&
38+
!pubName.contains("metadata", ignoreCase = true) &&
39+
!pubName.contains("kotlinMultiplatform", ignoreCase = true)
4040
) {
4141
artifactOverride {
4242
artifactId = when {

buildSrc/src/main/kotlin/mcp.multiplatform.gradle.kts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ val generateLibVersion by tasks.registering {
2424
2525
public const val LIB_VERSION: String = "${project.version}"
2626
27-
""".trimIndent()
27+
""".trimIndent(),
2828
)
2929
}
3030
}
@@ -33,8 +33,10 @@ kotlin {
3333
jvm {
3434
compilerOptions.jvmTarget = JvmTarget.JVM_1_8
3535
}
36-
macosX64(); macosArm64()
37-
linuxX64(); linuxArm64()
36+
macosX64()
37+
macosArm64()
38+
linuxX64()
39+
linuxArm64()
3840
mingwX64()
3941
js { nodejs() }
4042
wasmJs { nodejs() }

buildSrc/src/main/kotlin/mcp.publishing.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ signing {
6868
useInMemoryPgpKeys(signingKey.get(), signingPassphrase.get())
6969
sign(publishing.publications)
7070
}
71-
}
71+
}

gradle/libs.versions.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jreleaser = "1.19.0"
1717
binaryCompatibilityValidatorPlugin = "0.18.1"
1818
slf4j = "2.0.17"
1919
kotest = "5.9.1"
20+
awaitility = "4.3.0"
2021

2122
# Samples
2223
mcp-kotlin = "0.7.0"
@@ -45,11 +46,12 @@ ktor-server-websockets = { group = "io.ktor", name = "ktor-server-websockets", v
4546
ktor-server-core = { group = "io.ktor", name = "ktor-server-core", version.ref = "ktor" }
4647

4748
# Testing
49+
awaitility = { group = "org.awaitility", name = "awaitility-kotlin", version.ref = "awaitility" }
50+
kotest-assertions-json = { group = "io.kotest", name = "kotest-assertions-json", version.ref = "kotest" }
4851
kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "coroutines" }
49-
ktor-server-test-host = { group = "io.ktor", name = "ktor-server-test-host", version.ref = "ktor" }
5052
ktor-client-mock = { group = "io.ktor", name = "ktor-client-mock", version.ref = "ktor" }
53+
ktor-server-test-host = { group = "io.ktor", name = "ktor-server-test-host", version.ref = "ktor" }
5154
slf4j-simple = { group = "org.slf4j", name = "slf4j-simple", version.ref = "slf4j" }
52-
kotest-assertions-json = { group = "io.kotest", name = "kotest-assertions-json", version.ref = "kotest" }
5355

5456
# Samples
5557
ktor-client-cio = { group = "io.ktor", name = "ktor-client-cio", version.ref = "ktor" }

kotlin-sdk-core/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/shared/Protocol.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@ import kotlinx.serialization.json.JsonObject
3636
import kotlinx.serialization.json.JsonPrimitive
3737
import kotlinx.serialization.json.encodeToJsonElement
3838
import kotlinx.serialization.serializer
39-
import kotlin.collections.get
4039
import kotlin.reflect.KType
4140
import kotlin.reflect.typeOf
4241
import kotlin.time.Duration
43-
import kotlin.time.Duration.Companion.milliseconds
42+
import kotlin.time.Duration.Companion.seconds
4443

4544
private val LOGGER = KotlinLogging.logger { }
4645

@@ -85,7 +84,7 @@ public open class ProtocolOptions(
8584
/**
8685
* The default request timeout.
8786
*/
88-
public val DEFAULT_REQUEST_TIMEOUT: Duration = 60000.milliseconds
87+
public val DEFAULT_REQUEST_TIMEOUT: Duration = 60.seconds
8988

9089
/**
9190
* Options that can be given per request.

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ public data class JSONRPCError(val code: ErrorCode, val message: String, val dat
302302
public sealed interface NotificationParams : WithMeta
303303

304304
/* Cancellation */
305+
305306
/**
306307
* This notification can be sent by either side to indicate that it is cancelling a previously issued request.
307308
*
@@ -334,6 +335,7 @@ public data class CancelledNotification(override val params: Params) :
334335
}
335336

336337
/* Initialization */
338+
337339
/**
338340
* Describes the name and version of an MCP implementation.
339341
*/
@@ -527,6 +529,7 @@ public data class InitializedNotification(override val params: Params = Params()
527529
}
528530

529531
/* Ping */
532+
530533
/**
531534
* A ping, issued by either the server or the client, to check that the other party is still alive.
532535
* The receiver must promptly respond, or else it may be disconnected.
@@ -560,6 +563,7 @@ public sealed interface ProgressBase {
560563
}
561564

562565
/* Progress notifications */
566+
563567
/**
564568
* Represents a progress notification.
565569
*
@@ -619,6 +623,7 @@ public data class ProgressNotification(override val params: Params) :
619623
}
620624

621625
/* Pagination */
626+
622627
/**
623628
* Represents a request supporting pagination.
624629
*/
@@ -646,6 +651,7 @@ public sealed interface PaginatedResult : RequestResult {
646651
}
647652

648653
/* Resources */
654+
649655
/**
650656
* The contents of a specific resource or sub-resource.
651657
*/
@@ -888,6 +894,7 @@ public data class ResourceUpdatedNotification(override val params: Params) : Ser
888894
}
889895

890896
/* Prompts */
897+
891898
/**
892899
* Describes an argument that a prompt can accept.
893900
*/
@@ -1158,6 +1165,7 @@ public data class PromptListChangedNotification(override val params: Params = Pa
11581165
}
11591166

11601167
/* Tools */
1168+
11611169
/**
11621170
* Additional properties describing a Tool to clients.
11631171
*
@@ -1336,6 +1344,7 @@ public data class ToolListChangedNotification(override val params: Params = Para
13361344
}
13371345

13381346
/* Logging */
1347+
13391348
/**
13401349
* The severity of a log message.
13411350
*/
@@ -1395,6 +1404,7 @@ public data class LoggingMessageNotification(override val params: Params) : Serv
13951404
}
13961405

13971406
/* Sampling */
1407+
13981408
/**
13991409
* Hints to use for model selection.
14001410
*/
@@ -1639,6 +1649,7 @@ public data class CompleteResult(val completion: Completion, override val _meta:
16391649
}
16401650

16411651
/* Roots */
1652+
16421653
/**
16431654
* Represents a root directory or file that the server can operate on.
16441655
*/

kotlin-sdk-test/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ kotlin {
2424
jvmTest {
2525
dependencies {
2626
implementation(kotlin("test-junit5"))
27+
implementation(libs.awaitility)
2728
runtimeOnly(libs.slf4j.simple)
2829
}
2930
}

0 commit comments

Comments
 (0)