Skip to content

Commit 7e361ad

Browse files
committed
removed the Tool builder
1 parent 8b679ad commit 7e361ad

File tree

6 files changed

+36
-80
lines changed

6 files changed

+36
-80
lines changed

kotlin-sdk-client/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client/StreamableHttpClientTest.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ internal class StreamableHttpClientTest : AbstractStreamableHttpClientTest() {
125125

126126
val listToolsResult = client.listTools()
127127

128-
listToolsResult.tools shouldContain Tool.build {
129-
name = "get_weather"
130-
title = "Weather Information Provider"
131-
description = "Get current weather information for a location"
128+
listToolsResult.tools shouldContain Tool(
129+
name = "get_weather",
130+
title = "Weather Information Provider",
131+
description = "Get current weather information for a location",
132132
inputSchema = Tool.Input(
133133
properties = buildJsonObject {
134134
putJsonObject("location") {
@@ -137,7 +137,7 @@ internal class StreamableHttpClientTest : AbstractStreamableHttpClientTest() {
137137
}
138138
},
139139
required = listOf("location"),
140-
)
140+
),
141141
outputSchema = Tool.Output(
142142
properties = buildJsonObject {
143143
putJsonObject("temperature") {
@@ -146,8 +146,9 @@ internal class StreamableHttpClientTest : AbstractStreamableHttpClientTest() {
146146
}
147147
},
148148
required = listOf("temperature"),
149-
)
150-
}
149+
),
150+
annotations = null,
151+
)
151152

152153
mockMcp.mockUnsubscribeRequest(sessionId = sessionId)
153154

kotlin-sdk-core/api/kotlin-sdk-core.api

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2925,27 +2925,7 @@ public final synthetic class io/modelcontextprotocol/kotlin/sdk/Tool$$serializer
29252925
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
29262926
}
29272927

2928-
public final class io/modelcontextprotocol/kotlin/sdk/Tool$Builder {
2929-
public fun <init> ()V
2930-
public final fun build ()Lio/modelcontextprotocol/kotlin/sdk/Tool;
2931-
public final fun getAnnotations ()Lio/modelcontextprotocol/kotlin/sdk/ToolAnnotations;
2932-
public final fun getDescription ()Ljava/lang/String;
2933-
public final fun getInputSchema ()Lio/modelcontextprotocol/kotlin/sdk/Tool$Input;
2934-
public final fun getName ()Ljava/lang/String;
2935-
public final fun getOutputSchema ()Lio/modelcontextprotocol/kotlin/sdk/Tool$Output;
2936-
public final fun getTitle ()Ljava/lang/String;
2937-
public final fun get_meta ()Lkotlinx/serialization/json/JsonObject;
2938-
public final fun setAnnotations (Lio/modelcontextprotocol/kotlin/sdk/ToolAnnotations;)V
2939-
public final fun setDescription (Ljava/lang/String;)V
2940-
public final fun setInputSchema (Lio/modelcontextprotocol/kotlin/sdk/Tool$Input;)V
2941-
public final fun setName (Ljava/lang/String;)V
2942-
public final fun setOutputSchema (Lio/modelcontextprotocol/kotlin/sdk/Tool$Output;)V
2943-
public final fun setTitle (Ljava/lang/String;)V
2944-
public final fun set_meta (Lkotlinx/serialization/json/JsonObject;)V
2945-
}
2946-
29472928
public final class io/modelcontextprotocol/kotlin/sdk/Tool$Companion {
2948-
public final fun build (Lkotlin/jvm/functions/Function1;)Lio/modelcontextprotocol/kotlin/sdk/Tool;
29492929
public final fun serializer ()Lkotlinx/serialization/KSerializer;
29502930
}
29512931

kotlin-sdk-core/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types.kt

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,32 +1261,6 @@ public data class Tool(
12611261
@EncodeDefault
12621262
val type: String = "object"
12631263
}
1264-
1265-
public class Builder {
1266-
public var name: String? = null
1267-
public var title: String? = null
1268-
public var description: String? = null
1269-
public var inputSchema: Input = Input()
1270-
public var outputSchema: Output? = null
1271-
public var annotations: ToolAnnotations? = null
1272-
1273-
@Suppress("PropertyName")
1274-
public var _meta: JsonObject = EmptyJsonObject
1275-
1276-
public fun build(): Tool = Tool(
1277-
name = requireNotNull(name) { "Tool name is required" },
1278-
title = title,
1279-
description = description,
1280-
inputSchema = inputSchema,
1281-
outputSchema = outputSchema,
1282-
annotations = annotations,
1283-
_meta = _meta,
1284-
)
1285-
}
1286-
1287-
public companion object {
1288-
public fun build(builder: Builder.() -> Unit): Tool = Builder().apply(builder).build()
1289-
}
12901264
}
12911265

12921266
/**

kotlin-sdk-core/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/ToolSerializationTest.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -481,12 +481,12 @@ class ToolSerializationTest {
481481
title: String? = null,
482482
outputSchema: Tool.Output? = null,
483483
@Suppress("LocalVariableName") _meta: JsonObject? = null,
484-
): Tool = Tool.build {
485-
this.name = name
486-
title?.let { this.title = it }
487-
this.description = "Get the current weather in a given location"
488-
this.annotations = null
489-
this.inputSchema = Tool.Input(
484+
): Tool = Tool(
485+
name = name,
486+
title = title,
487+
description = "Get the current weather in a given location",
488+
annotations = null,
489+
inputSchema = Tool.Input(
490490
properties = buildJsonObject {
491491
put(
492492
"location",
@@ -497,10 +497,10 @@ class ToolSerializationTest {
497497
)
498498
},
499499
required = listOf("location"),
500-
)
501-
outputSchema?.let { this.outputSchema = it }
502-
_meta?.let { this._meta = it }
503-
}
500+
),
501+
outputSchema = outputSchema,
502+
_meta = _meta ?: EmptyJsonObject,
503+
)
504504

505505
//endregion Private Methods
506506
}

kotlin-sdk-server/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/server/Server.kt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package io.modelcontextprotocol.kotlin.sdk.server
33
import io.github.oshai.kotlinlogging.KotlinLogging
44
import io.modelcontextprotocol.kotlin.sdk.CallToolRequest
55
import io.modelcontextprotocol.kotlin.sdk.CallToolResult
6+
import io.modelcontextprotocol.kotlin.sdk.EmptyJsonObject
67
import io.modelcontextprotocol.kotlin.sdk.GetPromptRequest
78
import io.modelcontextprotocol.kotlin.sdk.GetPromptResult
89
import io.modelcontextprotocol.kotlin.sdk.Implementation
@@ -234,15 +235,15 @@ public open class Server(
234235
@Suppress("LocalVariableName") _meta: JsonObject? = null,
235236
handler: suspend (CallToolRequest) -> CallToolResult,
236237
) {
237-
val tool = Tool.build {
238-
this.name = name
239-
this.description = description
240-
this.inputSchema = inputSchema
241-
title?.let { this.title = it }
242-
outputSchema?.let { this.outputSchema = it }
243-
toolAnnotations?.let { this.annotations = it }
244-
_meta?.let { this._meta = it }
245-
}
238+
val tool = Tool(
239+
name = name,
240+
title = title,
241+
description = description,
242+
inputSchema = inputSchema,
243+
outputSchema = outputSchema,
244+
annotations = toolAnnotations,
245+
_meta = _meta ?: EmptyJsonObject,
246+
)
246247
addTool(tool, handler)
247248
}
248249

kotlin-sdk-test/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client/ClientTest.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -614,14 +614,14 @@ class ClientTest {
614614

615615
val serverListToolsResult = ListToolsResult(
616616
tools = listOf(
617-
Tool.build {
618-
name = "testTool"
619-
title = "testTool title"
620-
description = "testTool description"
621-
annotations = null
622-
inputSchema = Tool.Input()
623-
outputSchema = null
624-
},
617+
Tool(
618+
name = "testTool",
619+
title = "testTool title",
620+
description = "testTool description",
621+
annotations = null,
622+
inputSchema = Tool.Input(),
623+
outputSchema = null,
624+
),
625625
),
626626
nextCursor = null,
627627
)

0 commit comments

Comments
 (0)