Skip to content

Commit 60646bd

Browse files
authored
Merge branch 'main' into n500/add-receiver-mcp-dsl
2 parents dfee1b6 + b19d9f1 commit 60646bd

File tree

8 files changed

+104
-32
lines changed

8 files changed

+104
-32
lines changed

.github/workflows/gradle-publish.yml

Lines changed: 76 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name: Release
99

1010
on:
1111
release:
12-
types: [created]
12+
types: [ created ]
1313

1414
jobs:
1515
build:
@@ -27,12 +27,9 @@ jobs:
2727
with:
2828
java-version: '21'
2929
distribution: 'temurin'
30-
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
31-
server-username: JRELEASER_MAVENCENTRAL_USERNAME
32-
server-password: JRELEASER_MAVENCENTRAL_PASSWORD
3330

3431
- name: Setup Gradle
35-
uses: gradle/actions/setup-gradle@ac638b010cf58a27ee6c972d7336334ccaf61c96 # v4.4.1
32+
uses: gradle/actions/setup-gradle@v4
3633

3734
- name: Verify publication configuration
3835
run: ./gradlew jreleaserConfig
@@ -52,13 +49,85 @@ jobs:
5249
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
5350
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
5451
JRELEASER_GPG_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
52+
GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
53+
SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
5554

56-
- name: Publish to OSSRH repository
57-
run: ./gradlew publish jreleaserFullRelease
55+
- name: Publish to Maven Central Portal
56+
id: publish
57+
run: ./gradlew publish jreleaserFullRelease --info --stacktrace -Djreleaser.verbose=true
5858
env:
5959
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.OSSRH_USERNAME }}
6060
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
6161
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
6262
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
6363
JRELEASER_GPG_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
6464
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
66+
SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
67+
68+
- name: Query Central Portal for validation errors
69+
if: failure()
70+
shell: bash
71+
env:
72+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
73+
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
74+
run: |
75+
set -euo pipefail
76+
77+
OUTPUT_PROPS="build/jreleaser/output.properties"
78+
79+
if [[ ! -f "$OUTPUT_PROPS" ]]; then
80+
echo "::error title=File Missing::The file '$OUTPUT_PROPS' does not exist."
81+
exit 1
82+
fi
83+
84+
DEPLOY_ID=$(grep '^deploymentId=' "$OUTPUT_PROPS" | cut -d= -f2 || true)
85+
if [[ -z "$DEPLOY_ID" ]]; then
86+
echo "::error title=Missing Deployment ID::The 'deploymentId' key was not found in '$OUTPUT_PROPS'."
87+
exit 1
88+
fi
89+
90+
echo "Portal deploymentId: $DEPLOY_ID"
91+
92+
if [ -z "$OSSRH_USERNAME" ]; then
93+
echo "::error title='OSSRH_USERNAME' is not set."
94+
exit 1
95+
fi
96+
97+
if [ -z "$OSSRH_TOKEN" ]; then
98+
echo "::error title='OSSRH_TOKEN' is not set."
99+
exit 1
100+
fi
101+
102+
AUTH=$(printf "%s:%s" "$OSSRH_USERNAME" "$OSSRH_TOKEN" | base64)
103+
echo "::add-mask::$AUTH"
104+
105+
STATUS_JSON=$(curl -sS \
106+
-H "Authorization: Bearer $AUTH" \
107+
-H "Content-Type: application/json" \
108+
-X POST \
109+
"https://central.sonatype.com/api/v1/publisher/status?id=$DEPLOY_ID")
110+
111+
echo "$STATUS_JSON" | jq .
112+
113+
echo "$STATUS_JSON" | jq -r '.errors[]?.message' |
114+
while read -r MSG; do
115+
echo "::error title=Sonatype validation::$MSG"
116+
done
117+
118+
{
119+
echo "### Sonatype Central Portal validation result"
120+
echo
121+
echo '```json'
122+
echo "$STATUS_JSON"
123+
echo '```'
124+
} >> "$GITHUB_STEP_SUMMARY"
125+
126+
- name: Upload JReleaser artefacts
127+
if: always()
128+
uses: actions/upload-artifact@v4
129+
with:
130+
name: jreleaser-logs
131+
path: |
132+
build/jreleaser/trace.log
133+
build/jreleaser/output.properties

build.gradle.kts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ publishing {
4040

4141
jreleaser {
4242
gitRootSearch = true
43-
strict.set(true)
43+
strict = true
4444

4545
signing {
46-
active.set(Active.ALWAYS)
47-
armored.set(true)
48-
artifacts.set(true)
46+
active = Active.ALWAYS
47+
armored = true
48+
artifacts = true
49+
files = true
4950
}
5051

5152
deploy {
@@ -93,6 +94,7 @@ jreleaser {
9394

9495
release {
9596
github {
97+
changelog.enabled = false
9698
skipRelease = true
9799
skipTag = true
98100
overwrite = false
@@ -137,13 +139,12 @@ fun MavenPom.configureMavenCentralMetadata() {
137139
}
138140

139141
fun MavenPublication.signPublicationIfKeyPresent() {
140-
val keyId = project.getSensitiveProperty("SIGNING_KEY_ID")
141-
val signingKey = project.getSensitiveProperty("SIGNING_KEY_PRIVATE")
142+
val signingKey = project.getSensitiveProperty("GPG_SECRET_KEY")
142143
val signingKeyPassphrase = project.getSensitiveProperty("SIGNING_PASSPHRASE")
143144

144145
if (!signingKey.isNullOrBlank()) {
145146
the<SigningExtension>().apply {
146-
useInMemoryPgpKeys(keyId, signingKey, signingKeyPassphrase)
147+
useInMemoryPgpKeys(signingKey, signingKeyPassphrase)
147148

148149
sign(this@signPublicationIfKeyPresent)
149150
}

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
kotlin.code.style=official
2-
org.gradle.jvmargs=-XX:+UseParallelGC
2+
org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8
33
org.gradle.parallel=true
4-
org.gradle.configuration-cache.parallel=true
4+
org.gradle.caching=true
55

66
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
77
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
88

9-
kotlin.daemon.jvmargs=-Xmx2G
9+
kotlin.daemon.jvmargs=-Xmx4G

gradle/wrapper/gradle-wrapper.jar

59 Bytes
Binary file not shown.

gradlew

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ case "$( uname )" in #(
114114
NONSTOP* ) nonstop=true ;;
115115
esac
116116

117-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
117+
CLASSPATH="\\\"\\\""
118118

119119

120120
# Determine the Java command to use to start the JVM.
@@ -213,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
213213
set -- \
214214
"-Dorg.gradle.appname=$APP_BASE_NAME" \
215215
-classpath "$CLASSPATH" \
216-
org.gradle.wrapper.GradleWrapperMain \
216+
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
217217
"$@"
218218

219219
# Stop when "xargs" is not available.

gradlew.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ goto fail
7070
:execute
7171
@rem Setup the command line
7272

73-
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73+
set CLASSPATH=
7474

7575

7676
@rem Execute Gradle
77-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
77+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
7878

7979
:end
8080
@rem End local scope for the variables with windows NT shell

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,7 @@ public abstract class Protocol(
465465
val transport = this.transport ?: error("Not connected")
466466
assertNotificationCapability(notification.method)
467467

468-
val message = JSONRPCNotification(
469-
notification.method.value,
470-
params = McpJson.encodeToJsonElement<Notification>(notification) as JsonObject,
471-
)
468+
val message = notification.toJSON()
472469
transport.send(message)
473470
}
474471

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import kotlinx.serialization.ExperimentalSerializationApi
88
import kotlinx.serialization.Serializable
99
import kotlinx.serialization.json.JsonElement
1010
import kotlinx.serialization.json.JsonObject
11+
import kotlinx.serialization.json.JsonPrimitive
1112
import kotlinx.serialization.json.decodeFromJsonElement
1213
import kotlinx.serialization.json.encodeToJsonElement
14+
import kotlinx.serialization.json.jsonObject
1315
import kotlin.concurrent.atomics.AtomicLong
1416
import kotlin.concurrent.atomics.ExperimentalAtomicApi
1517
import kotlin.concurrent.atomics.incrementAndFetch
@@ -123,9 +125,10 @@ public sealed interface Request {
123125
* @return The JSON-RPC request representation.
124126
*/
125127
internal fun Request.toJSON(): JSONRPCRequest {
128+
val encoded = JsonObject(McpJson.encodeToJsonElement(this).jsonObject.minus("method"))
126129
return JSONRPCRequest(
127130
method = method.value,
128-
params = McpJson.encodeToJsonElement(this),
131+
params = encoded,
129132
jsonrpc = JSONRPC_VERSION,
130133
)
131134
}
@@ -135,10 +138,11 @@ internal fun Request.toJSON(): JSONRPCRequest {
135138
*
136139
* @return The decoded [Request] or null
137140
*/
138-
internal fun JSONRPCRequest.fromJSON(): Request? {
139-
val serializer = selectRequestDeserializer(method)
140-
val params = params
141-
return McpJson.decodeFromJsonElement<Request>(serializer, params)
141+
internal fun JSONRPCRequest.fromJSON(): Request {
142+
val requestData = JsonObject(params.jsonObject.plus("method" to JsonPrimitive(method)))
143+
144+
val deserializer = selectRequestDeserializer(method)
145+
return McpJson.decodeFromJsonElement(deserializer, requestData)
142146
}
143147

144148
/**
@@ -163,7 +167,7 @@ public sealed interface Notification {
163167
* @return The JSON-RPC notification representation.
164168
*/
165169
internal fun Notification.toJSON(): JSONRPCNotification {
166-
val encoded = McpJson.encodeToJsonElement<Notification>(this)
170+
val encoded = JsonObject(McpJson.encodeToJsonElement<Notification>(this).jsonObject.minus("method"))
167171
return JSONRPCNotification(
168172
method.value,
169173
params = encoded
@@ -176,7 +180,8 @@ internal fun Notification.toJSON(): JSONRPCNotification {
176180
* @return The decoded [Notification].
177181
*/
178182
internal fun JSONRPCNotification.fromJSON(): Notification {
179-
return McpJson.decodeFromJsonElement<Notification>(params)
183+
val data = JsonObject(params.jsonObject.plus("method" to JsonPrimitive(method)))
184+
return McpJson.decodeFromJsonElement<Notification>(data)
180185
}
181186

182187
/**

0 commit comments

Comments
 (0)