Skip to content

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

License

Notifications You must be signed in to change notification settings

xemantic/xemantic-ai-tool-schema-mdc

Repository files navigation

xemantic-ai-tool-schema-mdc

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

Maven Central Version GitHub Release Date license

GitHub Actions Workflow Status GitHub branch check runs GitHub commits since latest release GitHub last commit

GitHub contributors GitHub commit activity GitHub code size in bytes GitHub Created At kotlin version

discord server discord users online X (formerly Twitter) Follow

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