John O'Reilly
06/10/2025, 5:36 PMai.koog.agents.mcp.McpToolRegistryProvider - Failed to parse descriptor parameters for tool: get-emissions
java.lang.IllegalArgumentException: Parameter countryCode must be a JSON object
John O'Reilly
06/10/2025, 5:36 PMserver.addTool(
name = "get-emissions",
description = "List emission info for a particular country",
inputSchema = Tool.Input(
properties = JsonObject(
mapOf(
"countryCode" to JsonPrimitive("string"),
"year" to JsonPrimitive("date"),
)
),
required = listOf("countryCode", "year")
)
Didier Villevalois
06/10/2025, 6:59 PM{ "type": "string" }
.
So the whole thing should look like:
properties = JsonObject(
mapOf(
"countryCode" to JsonObject(
mapOf("type" to "string")
),
"year" to JsonObject(
mapOf("type" to "date")
),
)
),
(the "required" part looks correct to me)
It would appear that Claude can accept invalid schema definitions...John O'Reilly
06/10/2025, 7:01 PMJohn O'Reilly
06/10/2025, 7:30 PMproperties = buildJsonObject {
putJsonObject("countryCode") {
put("type", JsonPrimitive("string"))
}
putJsonObject("year") {
put("type", JsonPrimitive("string"))
}
},
John O'Reilly
06/10/2025, 7:30 PMJohn O'Reilly
06/10/2025, 7:32 PMDidier Villevalois
06/10/2025, 7:34 PM"date": {
"type": "string",
"format": "date"
}
Though it appears this is really not stable yet (https://json-schema.org/draft/2020-12/json-schema-validation#name-dates-times-and-duration)John O'Reilly
06/10/2025, 7:41 PMJohn O'Reilly
06/10/2025, 7:41 PMDidier Villevalois
06/10/2025, 7:44 PM@Serializable
classes and let it generate the schema...
You can see an examples of its uses here https://github.com/ptitjes/konvo/blob/main/konvo-mcp-web-tools/src/commonMain/kotlin/io/github/ptitjes/konvo/mcp/web/utils/ServerOps.kt#L31, here https://github.com/ptitjes/konvo/blob/main/konvo-mcp-web-tools/src/commonMain/kotlin/io/github/ptitjes/konvo/mcp/web/utils/JsonSchemaOf.kt and here https://github.com/ptitjes/konvo/blob/main/konvo-mcp-web-tools/src/commonMain/kotlin/io/github/ptitjes/konvo/mcp/web/KonvoWebTools.kt#L31John O'Reilly
06/10/2025, 7:46 PMJohn O'Reilly
06/10/2025, 8:17 PMDidier Villevalois
06/10/2025, 8:34 PMjsonSchemaOf
to call the Server.addTool
with a simple Kotlin method reference and reified type parameters. All the typing info is already contained in the KSerializer. jsonSchemaOf
is using that to produce a JSON schema. Then I simply wrap the Server.addTool
call in a inline fun <reified I, reified O> Server.addJsonTool(name: String, description: String, crossinline handler: suspend (I) -> O)
.kaeawc
06/12/2025, 3:03 PM