Skip to content

Commit 5c38234

Browse files
committed
fixup! Introduce Kotlin integration tests
1 parent 0fbc113 commit 5c38234

File tree

2 files changed

+681
-639
lines changed

2 files changed

+681
-639
lines changed

kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/typescript/TypeScriptTestBase.kt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,23 +179,35 @@ abstract class TypeScriptTestBase {
179179
}
180180

181181
val isWindows = System.getProperty("os.name").lowercase().contains("windows")
182+
val localServerPath = File(tsClientDir, "simpleStreamableHttp.ts").absolutePath
182183
val processBuilder = if (isWindows) {
183184
ProcessBuilder()
184-
.command("cmd.exe", "/c", "set MCP_PORT=$port && npx tsx src/examples/server/simpleStreamableHttp.ts")
185+
.command(
186+
"cmd.exe",
187+
"/c",
188+
"set MCP_PORT=$port && set NODE_PATH=${sdkDir.absolutePath}\\node_modules && npx --prefix \"${sdkDir.absolutePath}\" tsx \"$localServerPath\""
189+
)
185190
} else {
186191
ProcessBuilder()
187-
.command("bash", "-c", "MCP_PORT=$port npx tsx src/examples/server/simpleStreamableHttp.ts")
192+
.command(
193+
"bash",
194+
"-c",
195+
"MCP_PORT=$port NODE_PATH='${sdkDir.absolutePath}/node_modules' npx --prefix '${sdkDir.absolutePath}' tsx \"$localServerPath\""
196+
)
188197
}
189198

199+
processBuilder.environment()["TYPESCRIPT_SDK_DIR"] = sdkDir.absolutePath
200+
190201
val process = processBuilder
191-
.directory(sdkDir)
202+
.directory(tsClientDir)
192203
.redirectErrorStream(true)
193204
.start()
194205

195-
if (!waitForPort(port = port)) {
206+
createProcessOutputReader(process).start()
207+
208+
if (!waitForPort(port = port, timeoutSeconds = 20)) {
196209
throw IllegalStateException("TypeScript server did not become ready on localhost:$port within timeout")
197210
}
198-
createProcessOutputReader(process).start()
199211
return process
200212
}
201213

0 commit comments

Comments
 (0)