An open API service indexing awesome lists of open source software.

https://github.com/xemantic/xemantic-ai-tool-schema-mdc

Adapting xemantic-ai-tool-schema to Model Context Protocol kotlin-sdk Tool input
https://github.com/xemantic/xemantic-ai-tool-schema-mdc

agentic agentic-ai agents ai anthropic artificial-intelligence artificialintelligence function-calling json-schema kotlin kotlin-library kotlin-multiplatform large-language-models llm mdc model-context-protocol schema tool tool-use

Last synced: 5 months ago
JSON representation

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

Awesome Lists containing this project

README

          

# xemantic-ai-tool-schema-mdc
Adapting [xemantic-ai-tool-schema](https://github.com/xemantic/xemantic-ai-tool-schema) to Model Context Protocol kotlin-sdk Tool input.

[Maven Central Version](https://central.sonatype.com/namespace/com.xemantic.ai)
[GitHub Release Date](https://github.com/xemantic/xemantic-ai-tool-schema-mdc/releases)
[license](https://github.com/xemantic/xemantic-ai-tool-schema-mdc/blob/main/LICENSE)

[GitHub Actions Workflow Status](https://github.com/xemantic/xemantic-ai-tool-schema-mdc/actions/workflows/build-main.yml)
[GitHub branch check runs](https://github.com/xemantic/xemantic-ai-tool-schema-mdc/actions/workflows/build-main.yml)
[GitHub commits since latest release](https://github.com/xemantic/xemantic-ai-tool-schema-mdc/commits/main/)
[GitHub last commit](https://github.com/xemantic/xemantic-ai-tool-schema-mdc/commits/main/)

[GitHub contributors](https://github.com/xemantic/xemantic-ai-tool-schema-mdc/graphs/contributors)
[GitHub commit activity](https://github.com/xemantic/xemantic-ai-tool-schema-mdc/commits/main/)
[GitHub code size in bytes]()
[GitHub Created At](https://github.com/xemantic/xemantic-ai-tool-schema-mdc/commit/39c1fa4c138d4c671868c973e2ad37b262ae03c2)
[kotlin version](https://kotlinlang.org/docs/releases.html)

[discord server](https://discord.gg/vQktqqN2Vn)
[discord users online](https://discord.gg/vQktqqN2Vn)
[X (formerly Twitter) Follow](https://x.com/KazikPogoda)

## Why?

The [kotlin-sdk](https://github.com/modelcontextprotocol/kotlin-sdk) variant of the [Model Context Protocol](https://modelcontextprotocol.io/) is expressing [JSON Schema](https://json-schema.org/) as `Tool.Input` class, which offers limited flexibility comparing
to [JsonSchema](https://github.com/xemantic/xemantic-ai-tool-schema/blob/main/src/commonMain/kotlin/JsonSchema.kt) delivered by the [xemantic-ai-tool-schema](https://github.com/xemantic/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`:

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

### Getting `Tool.Input` instance

```kotlin
@Serializable
data class Foo(
val bar: String
)

// ...

val inputSchema: Tool.Input = mdcToolInput()
```

See [ObjectSchemaToMdcToolInputTest](src/commonTest/kotlin/ObjectSchemaToMdcToolInputTest.kt) for details.

## Development

Clone this project, and then run:

```shell
./gradlew build
```