Skip to content

Commit 0c49cf0

Browse files
committed
Fix samples with new changes
1 parent a20b0fe commit 0c49cf0

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

samples/kotlin-mcp-client/src/main/kotlin/io/modelcontextprotocol/sample/client/MCPClient.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.anthropic.models.messages.Tool
99
import com.anthropic.models.messages.ToolUnion
1010
import com.fasterxml.jackson.core.type.TypeReference
1111
import com.fasterxml.jackson.databind.ObjectMapper
12+
import io.modelcontextprotocol.kotlin.sdk.EmptyJsonObject
1213
import io.modelcontextprotocol.kotlin.sdk.Implementation
1314
import io.modelcontextprotocol.kotlin.sdk.TextContent
1415
import io.modelcontextprotocol.kotlin.sdk.client.Client
@@ -76,7 +77,7 @@ class MCPClient : AutoCloseable {
7677
.inputSchema(
7778
Tool.InputSchema.builder()
7879
.type(JsonValue.from(tool.inputSchema.type))
79-
.properties(tool.inputSchema.properties.toJsonValue())
80+
.properties(tool.inputSchema.properties?.toJsonValue() ?: EmptyJsonObject.toJsonValue())
8081
.putAdditionalProperty("required", JsonValue.from(tool.inputSchema.required))
8182
.build(),
8283
)
@@ -135,9 +136,11 @@ class MCPClient : AutoCloseable {
135136
"""
136137
"type": "tool_result",
137138
"tool_name": $toolName,
138-
"result": ${result?.content?.joinToString("\n") {
139-
(it as TextContent).text ?: ""
140-
}}
139+
"result": ${
140+
result?.content?.joinToString("\n") {
141+
(it as TextContent).text ?: ""
142+
}
143+
}
141144
""".trimIndent(),
142145
)
143146
.build(),

samples/kotlin-mcp-server/src/main/kotlin/io/modelcontextprotocol/sample/server/server.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ fun configureServer(): Server {
6464
),
6565
) { request ->
6666
GetPromptResult(
67-
"Description for ${request.name}",
6867
messages = listOf(
6968
PromptMessage(
7069
role = Role.user,
7170
content = TextContent(
72-
"Develop a kotlin project named <name>${request.arguments?.get("Project Name")}</name>",
71+
"Develop a kotlin project named <name>${request.params.arguments?.get("Project Name")}</name>",
7372
),
7473
),
7574
),
75+
description = "Description for ${request.params.name}",
7676
)
7777
}
7878

@@ -96,7 +96,7 @@ fun configureServer(): Server {
9696
) { request ->
9797
ReadResourceResult(
9898
contents = listOf(
99-
TextResourceContents("Placeholder content for ${request.uri}", request.uri, "text/html"),
99+
TextResourceContents("Placeholder content for ${request.params.uri}", request.params.uri, "text/html"),
100100
),
101101
)
102102
}

samples/kotlin-mcp-server/src/test/kotlin/SseServerIntegrationTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import io.modelcontextprotocol.kotlin.sdk.EmptyJsonObject
22
import io.modelcontextprotocol.kotlin.sdk.TextContent
33
import io.modelcontextprotocol.kotlin.sdk.client.Client
4+
import io.modelcontextprotocol.kotlin.sdk.types.ContentTypes
45
import kotlinx.coroutines.runBlocking
5-
import org.junit.jupiter.api.TestInstance
66
import kotlin.test.Test
77
import kotlin.test.assertEquals
88
import kotlin.test.assertIs
@@ -39,6 +39,6 @@ class SseServerIntegrationTest {
3939
assertIs<TextContent>(content, "Tool result should be a text content")
4040

4141
assertEquals(expected = "Hello, world!", actual = content.text)
42-
assertEquals(expected = "text", actual = content.type)
42+
assertEquals(expected = ContentTypes.TEXT, actual = content.type)
4343
}
4444
}

0 commit comments

Comments
 (0)