@@ -417,23 +417,17 @@ public open class Client(private val clientInfo: Implementation, options: Client
417417 public suspend fun callTool (
418418 name : String ,
419419 arguments : Map <String , Any ?>,
420+ meta : Map <String , Any ?> = emptyMap(),
420421 compatibility : Boolean = false,
421422 options : RequestOptions ? = null,
422423 ): CallToolResultBase ? {
423- val jsonArguments = arguments.mapValues { (_, value) ->
424- when (value) {
425- is String -> JsonPrimitive (value)
426- is Number -> JsonPrimitive (value)
427- is Boolean -> JsonPrimitive (value)
428- is JsonElement -> value
429- null -> JsonNull
430- else -> JsonPrimitive (value.toString())
431- }
432- }
424+ val jsonArguments = convertToJsonMap(arguments)
425+ val jsonMeta = convertToJsonMap(meta)
433426
434427 val request = CallToolRequest (
435428 name = name,
436429 arguments = JsonObject (jsonArguments),
430+ _meta = JsonObject (jsonMeta),
437431 )
438432 return callTool(request, compatibility, options)
439433 }
@@ -588,4 +582,16 @@ public open class Client(private val clientInfo: Implementation, options: Client
588582 val rootList = roots.value.values.toList()
589583 return ListRootsResult (rootList)
590584 }
585+
586+ private fun convertToJsonMap (map : Map <String , Any ?>): Map <String , JsonElement > =
587+ map.mapValues { (_, value) ->
588+ when (value) {
589+ is String -> JsonPrimitive (value)
590+ is Number -> JsonPrimitive (value)
591+ is Boolean -> JsonPrimitive (value)
592+ is JsonElement -> value
593+ null -> JsonNull
594+ else -> JsonPrimitive (value.toString())
595+ }
596+ }
591597}
0 commit comments