xemantic-ai-tool-schema-mdc

xemantic/xemantic-ai-tool-schema-mdc Checked 17 hours ago

Adapting xemantic-ai-tool-schema to Model Context Protocol kotlin-sdk Tool input

xemantic-ai-tool-schema-mdc 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.

Summary extracted from the README.

xemantic-ai-tool-schema-mdc

Adapting xemantic-ai-tool-schema to Model Context Protocol kotlin-sdk Tool input.

Why?

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.

Usage

Setting up Gradle

In your build.gradle.kts:

dependencies {
    implementation("com.xemantic.ai:xemantic-ai-tool-schema-mdc:0.1.1")
}

Getting Tool.Input instance

@Serializable
data class Foo(
    val bar: String
)

// ...

val inputSchema: Tool.Input = mdcToolInput<Foo>()

See ObjectSchemaToMdcToolInputTest for details.

Development

Clone this project, and then run:

./gradlew build