-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,083 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# These are supported funding model platforms | ||
|
||
github: xemantic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Copyright 2025 Kazimierz Pogoda / Xemantic | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# Ensure VERSION environment variable is set | ||
if [ -z "$VERSION" ]; then | ||
echo "Error: VERSION environment variable is not set" | ||
exit 1 | ||
fi | ||
|
||
# Check if settings.gradle.kts exists | ||
if [ ! -f "settings.gradle.kts" ]; then | ||
echo "Error: settings.gradle.kts not found" | ||
exit 1 | ||
fi | ||
|
||
# Extract groupId and name from settings.gradle.kts | ||
GROUP_ID=$(grep "val groupId = " settings.gradle.kts | sed -n 's/.*groupId = "\(.*\)".*/\1/p') | ||
ARTIFACT_ID=$(grep "val name = " settings.gradle.kts | sed -n 's/.*name = "\(.*\)".*/\1/p') | ||
|
||
if [ -z "$GROUP_ID" ] || [ -z "$ARTIFACT_ID" ]; then | ||
echo "Error: Could not extract groupId or name from settings.gradle.kts" | ||
exit 1 | ||
fi | ||
|
||
# Check if README.md exists | ||
if [ ! -f "README.md" ]; then | ||
echo "Error: README.md not found" | ||
exit 1 | ||
fi | ||
|
||
# Escape special characters in the group ID for sed | ||
ESCAPED_GROUP_ID=$(echo "$GROUP_ID" | sed 's/\./\\./g') | ||
|
||
# Create the pattern to match | ||
PATTERN="\"$ESCAPED_GROUP_ID:$ARTIFACT_ID:[0-9]+(\.[0-9]+){0,2}\"" | ||
|
||
# Create the replacement string | ||
REPLACEMENT="\"$GROUP_ID:$ARTIFACT_ID:$VERSION\"" | ||
|
||
# Check if the pattern exists in the file | ||
if ! grep -Eq "$GROUP_ID:$ARTIFACT_ID:[0-9]+(\.[0-9]+){0,2}" README.md; then | ||
echo "Error: Dependency pattern not found in README.md" | ||
exit 1 | ||
fi | ||
|
||
# Perform the replacement and save to a temporary file | ||
sed -E "s|$PATTERN|$REPLACEMENT|g" README.md > README.md.tmp | ||
|
||
# Check if sed made any changes | ||
if cmp -s README.md README.md.tmp; then | ||
echo "No version updates were needed" | ||
rm README.md.tmp | ||
exit 0 | ||
fi | ||
|
||
# Move the temporary file back to the original | ||
mv README.md.tmp README.md | ||
|
||
echo "Successfully updated version to $VERSION in README.md" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Build branch | ||
on: | ||
push: | ||
branches-ignore: | ||
- main | ||
pull_request: | ||
branches-ignore: | ||
- main | ||
|
||
jobs: | ||
build_branch: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/[email protected] | ||
|
||
- name: Setup Java | ||
uses: actions/[email protected] | ||
with: | ||
distribution: 'temurin' | ||
java-version: 23 | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/[email protected] | ||
|
||
- name: Build | ||
run: ./gradlew build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Build main | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
build_main: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/[email protected] | ||
|
||
- name: Setup Java | ||
uses: actions/[email protected] | ||
with: | ||
distribution: 'temurin' | ||
java-version: 23 | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/[email protected] | ||
|
||
- name: Build | ||
run: ./gradlew build sourcesJar dokkaGeneratePublicationHtml publish | ||
env: | ||
ORG_GRADLE_PROJECT_githubActor: ${{ secrets.GITHUBACTOR }} | ||
ORG_GRADLE_PROJECT_githubToken: ${{ secrets.GITHUBTOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Build release | ||
on: | ||
release: | ||
types: [ published ] | ||
jobs: | ||
build_release: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
# Give the default GITHUB_TOKEN write permission to commit and push the | ||
# added or changed files to the repository. | ||
contents: write | ||
steps: | ||
- name: Write release version | ||
run: | | ||
VERSION=${GITHUB_REF_NAME#v} | ||
echo Version: $VERSION | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
- name: Checkout sources | ||
uses: actions/[email protected] | ||
with: | ||
ref: ${{ github.head_ref }} | ||
fetch-depth: 0 | ||
|
||
- name: Setup Java | ||
uses: actions/[email protected] | ||
with: | ||
distribution: 'temurin' | ||
java-version: 23 | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/[email protected] | ||
|
||
- name: Build | ||
env: | ||
ORG_GRADLE_PROJECT_githubActor: ${{ secrets.GITHUBACTOR }} | ||
ORG_GRADLE_PROJECT_githubToken: ${{ secrets.GITHUBTOKEN }} | ||
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }} | ||
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} | ||
ORG_GRADLE_PROJECT_sonatypeUser: ${{ secrets.SONATYPE_USER }} | ||
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} | ||
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | ||
run: ./gradlew -Pversion=$VERSION build sourcesJar dokkaGeneratePublicationHtml publishToSonatype closeAndReleaseSonatypeStagingRepository | ||
|
||
- name: Checkout main branch | ||
uses: actions/[email protected] | ||
with: | ||
ref: main | ||
fetch-depth: 0 | ||
|
||
- name: Update README | ||
run: sh .github/scripts/update-readme-version.sh | ||
|
||
- name: Create Pull Request | ||
uses: stefanzweifel/[email protected] | ||
with: | ||
commit_message: Dependency version in README.md updated to ${{ env.VERSION }} | ||
file_pattern: 'README.md' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: GitHub Actions Version Updater | ||
|
||
# Controls when the action will run. | ||
on: | ||
schedule: | ||
# Automatically run on every Sunday | ||
- cron: '0 0 * * 0' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Git checkout | ||
uses: actions/[email protected] | ||
with: | ||
# [Required] Access token with `workflow` scope. | ||
token: ${{ secrets.WORKFLOW_SECRET }} | ||
|
||
- name: Run GitHub Actions Version Updater | ||
uses: saadmk11/[email protected] | ||
with: | ||
# [Required] Access token with `workflow` scope. | ||
token: ${{ secrets.WORKFLOW_SECRET }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,45 @@ | ||
.gradle | ||
**/build/ | ||
!src/**/build/ | ||
build/ | ||
!gradle/wrapper/gradle-wrapper.jar | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
# Ignore Gradle GUI config | ||
gradle-app.setting | ||
### IntelliJ IDEA ### | ||
/.idea/ | ||
!/.idea/copyright/ | ||
*.iws | ||
*.iml | ||
*.ipr | ||
out/ | ||
!**/src/main/**/out/ | ||
!**/src/test/**/out/ | ||
|
||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) | ||
!gradle-wrapper.jar | ||
### Kotlin ### | ||
.kotlin | ||
|
||
# Avoid ignore Gradle wrappper properties | ||
!gradle-wrapper.properties | ||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
bin/ | ||
!**/src/main/**/bin/ | ||
!**/src/test/**/bin/ | ||
|
||
# Cache of project | ||
.gradletasknamecache | ||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
# Eclipse Gradle plugin generated files | ||
# Eclipse Core | ||
.project | ||
# JDT-specific (Eclipse Java Development Tools) | ||
.classpath | ||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store | ||
|
||
/*.hprof |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,63 @@ | ||
# xemantic-ai-tool-schema-mdc | ||
An adapter from xemantic-ai-tool-schema to Model Context Protocol kotlin-sdk | ||
Adapting [xemantic-ai-tool-schema](https://github.com/xemantic/xemantic-ai-tool-schema) to Model Context Protocol kotlin-sdk Tool input. | ||
|
||
[<img alt="Maven Central Version" src="https://img.shields.io/maven-central/v/com.xemantic.ai/xemantic-ai-tool-schema-mdc">](https://central.sonatype.com/namespace/com.xemantic.ai) | ||
[<img alt="GitHub Release Date" src="https://img.shields.io/github/release-date/xemantic/xemantic-ai-tool-schema-mdc">](https://github.com/xemantic/xemantic-ai-tool-schema-mdc/releases) | ||
[<img alt="license" src="https://img.shields.io/github/license/xemantic/xemantic-ai-tool-schema-mdc?color=blue">](https://github.com/xemantic/xemantic-ai-tool-schema-mdc/blob/main/LICENSE) | ||
|
||
[<img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/xemantic/xemantic-ai-tool-schema-mdc/build-main.yml">](https://github.com/xemantic/xemantic-ai-tool-schema-mdc/actions/workflows/build-main.yml) | ||
[<img alt="GitHub branch check runs" src="https://img.shields.io/github/check-runs/xemantic/xemantic-ai-tool-schema-mdc/main">](https://github.com/xemantic/xemantic-ai-tool-schema-mdc/actions/workflows/build-main.yml) | ||
[<img alt="GitHub commits since latest release" src="https://img.shields.io/github/commits-since/xemantic/xemantic-ai-tool-schema-mdc/latest">](https://github.com/xemantic/xemantic-ai-tool-schema-mdc/commits/main/) | ||
[<img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/xemantic/xemantic-ai-tool-schema-mdc">](https://github.com/xemantic/xemantic-ai-tool-schema-mdc/commits/main/) | ||
|
||
[<img alt="GitHub contributors" src="https://img.shields.io/github/contributors/xemantic/xemantic-ai-tool-schema-mdc">](https://github.com/xemantic/xemantic-ai-tool-schema-mdc/graphs/contributors) | ||
[<img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/t/xemantic/xemantic-ai-tool-schema-mdc">](https://github.com/xemantic/xemantic-ai-tool-schema-mdc/commits/main/) | ||
[<img alt="GitHub code size in bytes" src="https://img.shields.io/github/languages/code-size/xemantic/xemantic-ai-tool-schema-mdc">]() | ||
[<img alt="GitHub Created At" src="https://img.shields.io/github/created-at/xemantic/xemantic-ai-tool-schema-mdc">](https://github.com/xemantic/xemantic-ai-tool-schema-mdc/commit/39c1fa4c138d4c671868c973e2ad37b262ae03c2) | ||
[<img alt="kotlin version" src="https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2Fxemantic%2Fxemantic-ai-tool-schema-mdc%2Fmain%2Fgradle%2Flibs.versions.toml&query=versions.kotlin&label=kotlin">](https://kotlinlang.org/docs/releases.html) | ||
|
||
[<img alt="discord server" src="https://dcbadge.limes.pink/api/server/https://discord.gg/vQktqqN2Vn?style=flat">](https://discord.gg/vQktqqN2Vn) | ||
[<img alt="discord users online" src="https://img.shields.io/discord/811561179280965673">](https://discord.gg/vQktqqN2Vn) | ||
[<img alt="X (formerly Twitter) Follow" src="https://img.shields.io/twitter/follow/KazikPogoda">](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") | ||
} | ||
``` | ||
|
||
### | ||
|
||
Getting `Tool.Input` instance: | ||
|
||
```kotlin | ||
@Serializable | ||
data class Foo( | ||
val bar: String | ||
) | ||
|
||
// ... | ||
|
||
val inputSchema: Tool.Input = mdcToolInput<Foo>() | ||
``` | ||
|
||
## Development | ||
|
||
Clone this project, and then run: | ||
|
||
```shell | ||
./gradlew build | ||
``` |
Oops, something went wrong.