Update Kotlin-MCP-Server with STDIO support, logging & CORS ### Summary - Added support for STDIO transport mode (default behavior). - Configured CORS and migrated SSE server to Ktor's Netty engine. - Redirected logs to `./build/stdout.log` and updated log levels. - New `TestEnvironment` setup for integration testing. - Enhanced documentation with examples for server execution and MCP Inspector usage. - Introduced shadow JAR plugin for building runnable artifacts. ### Motivation and Context Improves server versatility and developer experience by enabling STDIO and refining setup. ## How Has This Been Tested? Unit tests, tested locally (see README.md in sample) **NB! sse plain configuration is not working at the moment** ## Breaking Changes No ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [ ] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [ ] My code follows the repository's style guidelines - [ ] New and existing tests pass locally - [ ] I have added appropriate error handling - [ ] I have added or updated documentation as needed ## Additional context <!-- Add any other context, implementation notes, or design decisions -->
39 lines
830 B
Kotlin
39 lines
830 B
Kotlin
plugins {
|
|
alias(libs.plugins.kotlin.jvm)
|
|
alias(libs.plugins.kotlin.serialization)
|
|
alias(libs.plugins.shadow)
|
|
application
|
|
}
|
|
|
|
group = "org.example"
|
|
version = "0.1.0"
|
|
|
|
application {
|
|
mainClass.set("io.modelcontextprotocol.sample.server.MainKt")
|
|
}
|
|
|
|
dependencies {
|
|
implementation(dependencies.platform(libs.ktor.bom))
|
|
implementation(libs.mcp.kotlin.server)
|
|
implementation(libs.ktor.server.cio)
|
|
implementation(libs.ktor.server.cors)
|
|
implementation(libs.slf4j.simple)
|
|
|
|
testImplementation(libs.mcp.kotlin.client)
|
|
testImplementation(libs.ktor.client.cio)
|
|
testImplementation(kotlin("test"))
|
|
}
|
|
|
|
tasks.test {
|
|
useJUnitPlatform()
|
|
}
|
|
|
|
kotlin {
|
|
jvmToolchain(17)
|
|
compilerOptions {
|
|
javaParameters = true
|
|
freeCompilerArgs.addAll(
|
|
"-Xdebug",
|
|
)
|
|
}
|
|
}
|