Skip to content

Commit a263071

Browse files
authored
Merge branch 'main' into dependabot/gradle/io.github.oshai-kotlin-logging-7.0.11
2 parents 53f0d60 + be22708 commit a263071

File tree

41 files changed

+5401
-118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+5401
-118
lines changed

.github/workflows/build.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: [ main ]
7+
push:
8+
branches: [ main ]
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
# Cancel only when the run is NOT on `main` branch
13+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
14+
15+
jobs:
16+
validate-pr:
17+
runs-on: macos-latest-xlarge
18+
name: Validate PR
19+
steps:
20+
- uses: actions/checkout@v5
21+
22+
- name: Set up JDK 21
23+
uses: actions/setup-java@v5
24+
with:
25+
java-version: '21'
26+
distribution: 'temurin'
27+
28+
- name: Setup Gradle
29+
uses: gradle/actions/setup-gradle@v4
30+
with:
31+
add-job-summary: 'always'
32+
cache-read-only: true
33+
34+
- name: Build with Gradle
35+
run: ./gradlew clean ktlintCheck build koverLog koverHtmlReport
36+
env:
37+
JAVA_OPTS: "-Xmx8g -Dfile.encoding=UTF-8 -Djava.awt.headless=true -Dkotlin.daemon.jvm.options=-Xmx6g"
38+
39+
- name: Upload Reports
40+
if: always()
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: junit-results
44+
path: |
45+
**/build/test-results/test/*.xml
46+
build/reports
47+
48+
- name: Disable Auto-Merge on Fail
49+
if: failure() && github.event_name == 'pull_request'
50+
run: gh pr merge --disable-auto "$PR_URL"
51+
env:
52+
PR_URL: ${{github.event.pull_request.html_url}}
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/codeql.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ jobs:
2929

3030
steps:
3131
- name: Checkout repository
32-
uses: actions/checkout@v4
32+
uses: actions/checkout@v5
33+
with:
34+
fetch-depth: 0
3335

34-
- uses: actions/setup-java@v4
36+
- uses: actions/setup-java@v5
3537
with:
3638
distribution: temurin
3739
java-version: '21'
@@ -52,14 +54,14 @@ jobs:
5254

5355
- name: Build Kotlin sources
5456
run: |
55-
./gradlew \
57+
./gradlew \
5658
:kotlin-sdk-core:compileKotlinJvm \
5759
:kotlin-sdk-client:compileKotlinJvm \
5860
:kotlin-sdk-server:compileKotlinJvm \
5961
:kotlin-sdk:compileKotlinJvm \
6062
:kotlin-sdk-test:compileKotlinJvm \
6163
-Pkotlin.incremental=false \
62-
--no-daemon --stacktrace
64+
--no-daemon --stacktrace --rerun-tasks
6365
6466
- name: Analyze
6567
uses: github/codeql-action/analyze@v3

.github/workflows/gradle-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ jobs:
2121
packages: write
2222

2323
steps:
24-
- uses: actions/checkout@v4
24+
- uses: actions/checkout@v5
2525
- name: Set up JDK 21
26-
uses: actions/setup-java@v4
26+
uses: actions/setup-java@v5
2727
with:
2828
java-version: '21'
2929
distribution: 'temurin'

.github/workflows/validate-pr.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

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

build.gradle.kts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,38 @@
11
plugins {
22
alias(libs.plugins.ktlint)
3+
alias(libs.plugins.kover)
34
}
45

56
allprojects {
67
group = "io.modelcontextprotocol"
7-
version = "0.6.0"
8+
version = "0.7.0"
9+
}
10+
11+
dependencies {
12+
kover(project(":kotlin-sdk-core"))
13+
kover(project(":kotlin-sdk-client"))
14+
kover(project(":kotlin-sdk-server"))
15+
kover(project(":kotlin-sdk-test"))
816
}
917

1018
subprojects {
1119
apply(plugin = "org.jlleitschuh.gradle.ktlint")
20+
apply(plugin = "org.jetbrains.kotlinx.kover")
21+
}
22+
23+
kover {
24+
reports {
25+
filters {
26+
includes.classes("io.modelcontextprotocol.kotlin.sdk.*")
27+
}
28+
total {
29+
log {
30+
}
31+
verify {
32+
rule {
33+
minBound(65)
34+
}
35+
}
36+
}
37+
}
1238
}

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ kotlin.code.style=official
99
kotlin.daemon.jvmargs=-Xmx4G
1010
# MPP
1111
kotlin.mpp.enableCInteropCommonization=true
12+
kotlin.native.ignoreDisabledTargets=true

gradle/libs.versions.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ kotlin = "2.2.0"
44
dokka = "2.0.0"
55
atomicfu = "0.29.0"
66
ktlint = "13.0.0"
7+
kover = "0.9.1"
78

89
# libraries version
910
serialization = "1.9.0"
@@ -18,7 +19,7 @@ slf4j = "2.0.17"
1819
kotest = "5.9.1"
1920

2021
# Samples
21-
mcp-kotlin = "0.6.0"
22+
mcp-kotlin = "0.7.0"
2223
anthropic = "0.8.0"
2324
shadow = "8.1.1"
2425

@@ -38,10 +39,10 @@ kotlinx-collections-immutable = { group = "org.jetbrains.kotlinx", name = "kotli
3839
kotlin-logging = { group = "io.github.oshai", name = "kotlin-logging", version.ref = "logging" }
3940

4041
# Ktor
41-
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" }
4243
ktor-server-sse = { group = "io.ktor", name = "ktor-server-sse", version.ref = "ktor" }
4344
ktor-server-websockets = { group = "io.ktor", name = "ktor-server-websockets", version.ref = "ktor" }
44-
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" }
4546

4647
# Testing
4748
kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "coroutines" }
@@ -51,6 +52,8 @@ slf4j-simple = { group = "org.slf4j", name = "slf4j-simple", version.ref = "slf4
5152
kotest-assertions-json = { group = "io.kotest", name = "kotest-assertions-json", version.ref = "kotest" }
5253

5354
# 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" }
5457
mcp-kotlin = { group = "io.modelcontextprotocol", name = "kotlin-sdk", version.ref = "mcp-kotlin" }
5558
anthropic-java = { group = "com.anthropic", name = "anthropic-java", version.ref = "anthropic" }
5659
ktor-client-content-negotiation = { group = "io.ktor", name = "ktor-client-content-negotiation", version.ref = "ktor" }
@@ -59,6 +62,7 @@ ktor-serialization-kotlinx-json = { group = "io.ktor", name = "ktor-serializatio
5962
[plugins]
6063
kotlinx-binary-compatibility-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binaryCompatibilityValidatorPlugin" }
6164
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
65+
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
6266

6367
# Samples
6468
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }

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-client/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/client/StreamableHttpClientTransport.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package io.modelcontextprotocol.kotlin.sdk.client
22

33
import io.github.oshai.kotlinlogging.KotlinLogging
44
import io.ktor.client.HttpClient
5-
import io.ktor.client.plugins.ClientRequestException
65
import io.ktor.client.plugins.sse.ClientSSESession
6+
import io.ktor.client.plugins.sse.SSEClientException
77
import io.ktor.client.plugins.sse.sseSession
88
import io.ktor.client.request.HttpRequestBuilder
99
import io.ktor.client.request.accept
@@ -230,8 +230,8 @@ public class StreamableHttpClientTransport(
230230
requestBuilder()
231231
}
232232
logger.debug { "Client SSE session started successfully." }
233-
} catch (e: ClientRequestException) {
234-
if (e.response.status == HttpStatusCode.MethodNotAllowed) {
233+
} catch (e: SSEClientException) {
234+
if (e.response?.status == HttpStatusCode.MethodNotAllowed) {
235235
logger.info { "Server returned 405 for GET/SSE, stream disabled." }
236236
return
237237
}

0 commit comments

Comments
 (0)