Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
java-version: 21

- name: Build iOS app
run: xcodebuild -allowProvisioningUpdates -allowProvisioningUpdates -workspace iosApp/iosApp.xcodeproj/project.xcworkspace -configuration Debug -scheme iosApp -sdk iphoneos -destination name='iPhone 15'
run: xcodebuild -allowProvisioningUpdates -allowProvisioningUpdates -workspace iosApp/iosApp.xcodeproj/project.xcworkspace -configuration Debug -scheme iosApp -sdk iphoneos -destination name='iPhone 16'



1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ plugins {
alias(libs.plugins.jetbrainsCompose) apply false
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.kmpNativeCoroutines) apply false
alias(libs.plugins.jib) apply false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GET https://api.climatetrace.org/v6/definitions/countries
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import dev.johnoreilly.climatetrace.remote.Country
import io.github.xxfast.kstore.KStore
import io.github.xxfast.kstore.file.storeOf
import kotlinx.io.files.Path
import kotlinx.io.files.SystemFileSystem
import net.harawata.appdirs.AppDirsFactory
import org.koin.core.module.Module
import org.koin.dsl.module
Expand All @@ -15,7 +16,9 @@ private const val AUTHOR = "johnoreilly"
actual fun dataModule(): Module = module {
single<KStore<List<Country>>> {
val filesDir: String = AppDirsFactory.getInstance()
.getUserDataDir(PACKAGE_NAME, VERSION, AUTHOR)
.getUserCacheDir(PACKAGE_NAME, VERSION, AUTHOR)
val files = Path(filesDir)
with(SystemFileSystem) { if(!exists(files)) createDirectories(files) }
storeOf(file = Path(path = "$filesDir/countries.json"), default = emptyList())
}
}
12 changes: 8 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
kotlin = "2.2.0"
ksp = "2.2.0-2.0.2"
kotlinx-coroutines = "1.10.2"

kotlinxSerialization = "1.9.0"

agp = "8.11.1"
android-compileSdk = "36"
Expand All @@ -24,8 +24,8 @@ treemapChart = "0.1.3"
voyager= "1.1.0-beta03"
molecule = "2.1.0"
mcp = "0.6.0"
shadowPlugin = "8.1.1"

shadowPlugin = "9.0.0-rc2"
jib = "3.4.5"

[libraries]
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
Expand All @@ -41,6 +41,7 @@ koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" }


kotlinx-coroutines = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
kotlinx-serialization = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-core", version.ref = "kotlinxSerialization" }
kmpObservableViewModel = { module = "com.rickclephas.kmp:kmp-observableviewmodel-core", version.ref = "kmpObservableViewModel" }

kstore = { module = "io.github.xxfast:kstore", version.ref = "kstore" }
Expand Down Expand Up @@ -80,4 +81,7 @@ kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", vers
kmpNativeCoroutines = { id = "com.rickclephas.kmp.nativecoroutines", version.ref = "kmpNativeCoroutines" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
kotlinJvm = { id = "org.jetbrains.kotlin.jvm" }
shadowPlugin = { id = "com.github.johnrengelman.shadow", version.ref = "shadowPlugin" }
shadowPlugin = { id = "com.gradleup.shadow", version.ref = "shadowPlugin" }
jib = { id = "com.google.cloud.tools.jib", version.ref = "jib" }


17 changes: 15 additions & 2 deletions mcp-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ plugins {
alias(libs.plugins.kotlinJvm)
alias(libs.plugins.kotlinx.serialization)
alias(libs.plugins.shadowPlugin)
alias(libs.plugins.jib)
application
}

dependencies {
implementation(libs.mcp.kotlin)
implementation(libs.koin.core)
implementation("ch.qos.logback:logback-classic:1.5.8")
implementation(projects.composeApp)
}

Expand All @@ -18,14 +20,25 @@ java {
}

application {
mainClass = "MainKt"
mainClass = "McpServerKt"
}

tasks.shadowJar {
archiveFileName.set("serverAll.jar")
archiveClassifier.set("")
manifest {
attributes["Main-Class"] = "MainKt"
attributes["Main-Class"] = "McpServerKt"
}
}

jib {
from.image = "docker.io/library/eclipse-temurin:21"

to {
image = "gcr.io/climatetrace-mcp/climatetrace-mcp-server"
}
container {
ports = listOf("8080")
mainClass = "McpServerKt"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,31 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.runBlocking
import kotlinx.io.asSink
import kotlinx.io.buffered
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonPrimitive
import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonPrimitive
import kotlinx.serialization.json.putJsonObject




fun main(args: Array<String>) {
val command = args.firstOrNull() ?: "--sse-server"
val port = args.getOrNull(1)?.toIntOrNull() ?: 8080
when (command) {
"--sse-server" -> `run sse mcp server`(port)
"--stdio" -> `run mcp server using stdio`()
else -> {
System.err.println("Unknown command: $command")
}
}
}


private val koin = initKoin(enableNetworkLogs = true).koin

fun configureServer(): Server {
fun configureMcpServer(): Server {
val climateTraceRepository = koin.get<ClimateTraceRepository>()

val server = Server(
Expand All @@ -34,7 +48,6 @@ fun configureServer(): Server {
)
)


server.addTool(
name = "get-countries",
description = "List of countries"
Expand Down Expand Up @@ -68,7 +81,6 @@ fun configureServer(): Server {
content = listOf(TextContent("The 'countryCodeList' parameters are required."))
)
}

val countryAssetEmissionInfo = climateTraceRepository.fetchCountryAssetEmissionsInfo(
countryCodeList = countryCodeList
.jsonArray
Expand Down Expand Up @@ -130,7 +142,7 @@ fun configureServer(): Server {
* a close event.
*/
fun `run mcp server using stdio`() {
val server = configureServer()
val server = configureMcpServer()
val transport = StdioServerTransport(
System.`in`.asInput(),
System.out.asSink().buffered()
Expand All @@ -154,7 +166,7 @@ fun `run mcp server using stdio`() {
* @param port The port number on which the SSE server should be started.
*/
fun `run sse mcp server`(port: Int): Unit = runBlocking {
val server = configureServer()
val server = configureMcpServer()
embeddedServer(CIO, host = "0.0.0.0", port = port) {
mcp {
server
Expand Down
24 changes: 0 additions & 24 deletions mcp-server/src/main/kotlin/main.kt

This file was deleted.

Loading