File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/server Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change 11package io.modelcontextprotocol.kotlin.sdk.server
22
3+ import io.ktor.util.rootCause
34import io.modelcontextprotocol.kotlin.sdk.CallToolRequest
45import io.modelcontextprotocol.kotlin.sdk.CallToolResult
56import io.modelcontextprotocol.kotlin.sdk.TextContent
@@ -9,6 +10,7 @@ import kotlinx.serialization.json.JsonPrimitive
910import kotlinx.serialization.json.buildJsonObject
1011import kotlinx.serialization.json.put
1112import kotlinx.serialization.json.putJsonObject
13+ import java.lang.reflect.InvocationTargetException
1214import kotlin.reflect.KCallable
1315import kotlin.reflect.KClass
1416import kotlin.reflect.KFunction
@@ -127,8 +129,10 @@ public fun <T : Any> Server.registerToolFromAnnotatedFunction(
127129
128130 // Call the function using callBy
129131 function.callBy(arguments)
130- } catch (e: Exception ) {
132+ } catch (e: IllegalArgumentException ) {
131133 throw IllegalArgumentException (" Error invoking function ${function.name} : ${e.message} " , e)
134+ } catch (e: InvocationTargetException ) {
135+ throw e.targetException
132136 }
133137
134138 // Handle the result
You can’t perform that action at this time.
0 commit comments