Adapting xemantic-ai-tool-schema to Model Context Protocol kotlin-sdk Tool input.
The kotlin-sdk variant of the Model Context Protocol is expressing JSON Schema as Tool.Input class, which offers limited flexibility comparing
to JsonSchema delivered by the xemantic-ai-tool-schema project.
In particular definitions of types cannot be expressed.
I hope kotlin-sdk will embrace something more versatile soon. Meanwhile, this adapter library can be used for automatic MDC-compatible JSON Schema generation out of serializable Kotlin classes.
In your build.gradle.kts:
dependencies {
implementation("com.xemantic.ai:xemantic-ai-tool-schema-mdc:0.1.1")
}@Serializable
data class Foo(
val bar: String
)
// ...
val inputSchema: Tool.Input = mdcToolInput<Foo>()See ObjectSchemaToMdcToolInputTest for details.
Clone this project, and then run:
./gradlew build