Added Space Packages Publication (#9)
This commit is contained in:
parent
4922c2cd5c
commit
5d1854723b
10 changed files with 137 additions and 22 deletions
|
|
@ -17,11 +17,11 @@ The Model Context Protocol allows applications to provide context for LLMs in a
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Add the JitPack repository to your build file:
|
Add the new repository to your build file:
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
repositories {
|
repositories {
|
||||||
maven { url = uri("https://jitpack.io") }
|
maven(url = "https://maven.pkg.jetbrains.space/public/p/kotlin-mcp-sdk/sdk")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -29,7 +29,7 @@ Add the dependency:
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("com.github.JetBrains:mcp-kotlin-sdk:main-SNAPSHOT")
|
implementation("org.jetbrains.kotlinx:kotlinx-mcp-sdk:0.1.0")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
133
build.gradle.kts
133
build.gradle.kts
|
|
@ -7,8 +7,16 @@ plugins {
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "org.jetbrains.kotlinx.mcp"
|
if (project.getSensitiveProperty("libs.sign.key.private") != null) {
|
||||||
version = "1.0-SNAPSHOT"
|
apply(plugin = "signing")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<PublishToMavenRepository>().configureEach {
|
||||||
|
dependsOn(tasks.withType<Sign>())
|
||||||
|
}
|
||||||
|
|
||||||
|
group = "org.jetbrains.kotlinx"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
@ -30,7 +38,29 @@ dependencies {
|
||||||
testImplementation(libs.kotlinx.coroutines.debug)
|
testImplementation(libs.kotlinx.coroutines.debug)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val spaceUsername = System.getenv("SPACE_PACKAGES_USERNAME")
|
||||||
|
?: project.findProperty("kotlin.mcp.sdk.packages.username") as String?
|
||||||
|
|
||||||
|
val spacePassword = System.getenv("SPACE_PACKAGES_PASSWORD")
|
||||||
|
?: project.findProperty("kotlin.mcp.sdk.packages.password") as String?
|
||||||
|
|
||||||
|
val sources = tasks.create<Jar>("sourcesJar") {
|
||||||
|
from(sourceSets["main"].allSource)
|
||||||
|
archiveClassifier.set("sources")
|
||||||
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
url = uri("https://maven.pkg.jetbrains.space/public/p/kotlin-mcp-sdk/sdk")
|
||||||
|
name = "Space"
|
||||||
|
credentials {
|
||||||
|
username = spaceUsername
|
||||||
|
password = spacePassword
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
publications {
|
publications {
|
||||||
create<MavenPublication>("maven") {
|
create<MavenPublication>("maven") {
|
||||||
groupId = project.group.toString()
|
groupId = project.group.toString()
|
||||||
|
|
@ -40,11 +70,91 @@ publishing {
|
||||||
from(components["java"])
|
from(components["java"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val javadocJar = configureEmptyJavadocArtifact()
|
||||||
|
|
||||||
|
publications.withType(MavenPublication::class).all {
|
||||||
|
pom.configureMavenCentralMetadata()
|
||||||
|
signPublicationIfKeyPresent()
|
||||||
|
artifact(javadocJar)
|
||||||
|
artifact(sources)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.create<Jar>("sourcesJar") {
|
fun MavenPom.configureMavenCentralMetadata() {
|
||||||
from(sourceSets["main"].allSource)
|
name by project.name
|
||||||
archiveClassifier.set("sources")
|
description by "Kotlin implementation of the Model Context Protocol (MCP)"
|
||||||
|
url by "https://github.com/JetBrains/mcp-kotlin-sdk"
|
||||||
|
|
||||||
|
licenses {
|
||||||
|
license {
|
||||||
|
name by "The Apache Software License, Version 2.0"
|
||||||
|
url by "https://www.apache.org/licenses/LICENSE-2.0.txt"
|
||||||
|
distribution by "repo"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
developers {
|
||||||
|
developer {
|
||||||
|
id by "JetBrains"
|
||||||
|
name by "JetBrains Team"
|
||||||
|
organization by "JetBrains"
|
||||||
|
organizationUrl by "https://www.jetbrains.com"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scm {
|
||||||
|
url by "https://github.com/JetBrains/mcp-kotlin-sdk"
|
||||||
|
connection by "scm:git:git://github.com/JetBrains/mcp-kotlin-sdk.git"
|
||||||
|
developerConnection by "scm:git:git@github.com:JetBrains/mcp-kotlin-sdk.git"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun configureEmptyJavadocArtifact(): org.gradle.jvm.tasks.Jar {
|
||||||
|
val javadocJar by project.tasks.creating(Jar::class) {
|
||||||
|
archiveClassifier.set("javadoc")
|
||||||
|
// contents are deliberately left empty
|
||||||
|
// https://central.sonatype.org/publish/requirements/#supply-javadoc-and-sources
|
||||||
|
}
|
||||||
|
return javadocJar
|
||||||
|
}
|
||||||
|
|
||||||
|
fun MavenPublication.signPublicationIfKeyPresent() {
|
||||||
|
val keyId = project.getSensitiveProperty("libs.sign.key.id")
|
||||||
|
val signingKey = project.getSensitiveProperty("libs.sign.key.private")
|
||||||
|
val signingKeyPassphrase = project.getSensitiveProperty("libs.sign.passphrase")
|
||||||
|
|
||||||
|
if (!signingKey.isNullOrBlank()) {
|
||||||
|
the<SigningExtension>().apply {
|
||||||
|
useInMemoryPgpKeys(keyId, signingKey, signingKeyPassphrase)
|
||||||
|
|
||||||
|
sign(this@signPublicationIfKeyPresent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.getSensitiveProperty(name: String?): String? {
|
||||||
|
if (name == null) {
|
||||||
|
error("Expected not null property '$name' for publication repository config")
|
||||||
|
}
|
||||||
|
|
||||||
|
return project.findProperty(name) as? String
|
||||||
|
?: System.getenv(name)
|
||||||
|
?: System.getProperty(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
infix fun <T> Property<T>.by(value: T) {
|
||||||
|
set(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.create<Jar>("localJar") {
|
||||||
|
dependsOn(tasks.jar)
|
||||||
|
|
||||||
|
archiveFileName = "kotlinx-mcp-sdk.jar"
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
|
from(configurations.runtimeClasspath.map {
|
||||||
|
it.map { if (it.isDirectory) it else zipTree(it) }
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.test {
|
tasks.test {
|
||||||
|
|
@ -53,15 +163,20 @@ tasks.test {
|
||||||
|
|
||||||
abstract class GenerateLibVersionTask @Inject constructor(
|
abstract class GenerateLibVersionTask @Inject constructor(
|
||||||
@get:Input val libVersion: String,
|
@get:Input val libVersion: String,
|
||||||
@get:OutputDirectory val sourcesDir: File
|
@get:OutputDirectory val sourcesDir: File,
|
||||||
) : DefaultTask() {
|
) : DefaultTask() {
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun generate() {
|
fun generate() {
|
||||||
val sourceFile = File(sourcesDir, "LibVersion.kt")
|
val sourceFile = File(sourcesDir.resolve("org/jetbrains/kotlinx/mcp"), "LibVersion.kt")
|
||||||
|
|
||||||
|
if (!sourceFile.exists()) {
|
||||||
|
sourceFile.parentFile.mkdirs()
|
||||||
|
sourceFile.createNewFile()
|
||||||
|
}
|
||||||
|
|
||||||
sourceFile.writeText(
|
sourceFile.writeText(
|
||||||
"""
|
"""
|
||||||
package shared
|
package org.jetbrains.kotlinx.mcp
|
||||||
|
|
||||||
const val LIB_VERSION = "$libVersion"
|
const val LIB_VERSION = "$libVersion"
|
||||||
|
|
||||||
|
|
@ -76,7 +191,7 @@ dokka {
|
||||||
dokkaSourceSets.main {
|
dokkaSourceSets.main {
|
||||||
sourceLink {
|
sourceLink {
|
||||||
localDirectory.set(file("src/main/kotlin"))
|
localDirectory.set(file("src/main/kotlin"))
|
||||||
remoteUrl("https://github.com/e5l/mcp-kotlin-sdk")
|
remoteUrl("https://github.com/JetBrains/mcp-kotlin-sdk")
|
||||||
remoteLineSuffix.set("#L")
|
remoteLineSuffix.set("#L")
|
||||||
documentedVisibilities(VisibilityModifier.Public)
|
documentedVisibilities(VisibilityModifier.Public)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
../gradlew clean jar; java -jar ../build/libs/mcp-kotlin-sdk-1.0-SNAPSHOT.jar --demo
|
../gradlew clean localJar; java -jar ../build/libs/kotlinx-mcp-sdk.jar --demo
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
../gradlew clean jar && npx @modelcontextprotocol/inspector java -jar ../build/libs/mcp-kotlin-sdk-1.0-SNAPSHOT.jar --server
|
../gradlew clean localJar && npx @modelcontextprotocol/inspector java -jar ../build/libs/kotlinx-mcp-sdk.jar --server
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@ application {
|
||||||
|
|
||||||
|
|
||||||
group = "org.example"
|
group = "org.example"
|
||||||
version = "1.0-SNAPSHOT"
|
version = "0.1.0"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("com.github.JetBrains:mcp-kotlin-sdk:b1b0238")
|
implementation("org.jetbrains.kotlinx:kotlinx-mcp-sdk:0.1.0")
|
||||||
implementation("org.slf4j:slf4j-nop:2.0.9")
|
implementation("org.slf4j:slf4j-nop:2.0.9")
|
||||||
|
|
||||||
testImplementation(kotlin("test"))
|
testImplementation(kotlin("test"))
|
||||||
|
|
@ -24,4 +24,4 @@ tasks.test {
|
||||||
}
|
}
|
||||||
kotlin {
|
kotlin {
|
||||||
jvmToolchain(21)
|
jvmToolchain(21)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,6 @@ dependencyResolutionManagement {
|
||||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven("https://jitpack.io")
|
maven("https://maven.pkg.jetbrains.space/public/p/kotlin-mcp-sdk/sdk")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
plugins {
|
plugins {
|
||||||
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
|
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
|
||||||
}
|
}
|
||||||
rootProject.name = "mcp-kotlin-sdk"
|
rootProject.name = "kotlinx-mcp-sdk"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ package org.jetbrains.kotlinx.mcp.client
|
||||||
import org.jetbrains.kotlinx.mcp.Implementation
|
import org.jetbrains.kotlinx.mcp.Implementation
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.request.HttpRequestBuilder
|
import io.ktor.client.request.HttpRequestBuilder
|
||||||
|
import org.jetbrains.kotlinx.mcp.LIB_VERSION
|
||||||
import org.jetbrains.kotlinx.mcp.shared.IMPLEMENTATION_NAME
|
import org.jetbrains.kotlinx.mcp.shared.IMPLEMENTATION_NAME
|
||||||
import shared.LIB_VERSION
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new WebSocket transport for the Model Context Protocol using the provided HttpClient.
|
* Returns a new WebSocket transport for the Model Context Protocol using the provided HttpClient.
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ package org.jetbrains.kotlinx.mcp.client
|
||||||
import org.jetbrains.kotlinx.mcp.Implementation
|
import org.jetbrains.kotlinx.mcp.Implementation
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.request.HttpRequestBuilder
|
import io.ktor.client.request.HttpRequestBuilder
|
||||||
|
import org.jetbrains.kotlinx.mcp.LIB_VERSION
|
||||||
import org.jetbrains.kotlinx.mcp.shared.IMPLEMENTATION_NAME
|
import org.jetbrains.kotlinx.mcp.shared.IMPLEMENTATION_NAME
|
||||||
import shared.LIB_VERSION
|
|
||||||
import kotlin.time.Duration
|
import kotlin.time.Duration
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ import org.jetbrains.kotlinx.mcp.Implementation
|
||||||
import org.jetbrains.kotlinx.mcp.ServerCapabilities
|
import org.jetbrains.kotlinx.mcp.ServerCapabilities
|
||||||
import io.ktor.server.routing.*
|
import io.ktor.server.routing.*
|
||||||
import io.ktor.server.websocket.*
|
import io.ktor.server.websocket.*
|
||||||
|
import org.jetbrains.kotlinx.mcp.LIB_VERSION
|
||||||
import org.jetbrains.kotlinx.mcp.shared.IMPLEMENTATION_NAME
|
import org.jetbrains.kotlinx.mcp.shared.IMPLEMENTATION_NAME
|
||||||
import shared.LIB_VERSION
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a WebSocket route that establishes an MCP (Model Context Protocol) server session.
|
* Registers a WebSocket route that establishes an MCP (Model Context Protocol) server session.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue