refactor(test): add centralized TypeScript server factory for integration tests (#477)
# refactor(test): add centralized TypeScript server factory for integration tests - Create TypeScriptServer class for managing TypeScript MCP servers - Add dedicated typescript/ directory with server infrastructure - Refactor TsTestBase to use TypeScriptServer for stdio transport - Extract TypeScript test tools (greet, multi-greet, prompts, resources) - Use npx tsx for direct execution (better performance than npm run) - Install TypeScript dependencies automatically in test setup The TypeScriptServer factory provides: - startSse(port): Start SSE transport server - startStdio(): Start STDIO transport server - stop(): Graceful server shutdown - installDependencies(): npm install automation <!-- Provide a brief summary of your changes --> ## Motivation and Context To resurrect typescript tests ## How Has This Been Tested? Locally, CI ## Breaking Changes <!-- Will users need to update their code or configurations? --> ## Types of changes - [x] Bug fix (non-breaking change which fixes an issue) - [x] Test fix ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [ ] I have added appropriate error handling - [ ] I have added or updated documentation as needed ## Additional context #475
This commit is contained in:
parent
29d34b8e48
commit
658b370c87
2 changed files with 2848 additions and 1119 deletions
|
|
@ -6,8 +6,8 @@ plugins {
|
|||
|
||||
dependencies {
|
||||
testImplementation(project(":kotlin-sdk"))
|
||||
testImplementation(kotlin("test"))
|
||||
testImplementation(project(":test-utils"))
|
||||
testImplementation(kotlin("test"))
|
||||
testImplementation(libs.kotlin.logging)
|
||||
testImplementation(libs.ktor.client.cio)
|
||||
testImplementation(libs.ktor.server.cio)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package io.modelcontextprotocol.kotlin.sdk.conformance
|
||||
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import io.modelcontextprotocol.kotlin.test.utils.findFreePort
|
||||
import org.junit.jupiter.api.AfterAll
|
||||
import org.junit.jupiter.api.BeforeAll
|
||||
import org.junit.jupiter.api.DynamicTest
|
||||
|
|
@ -10,7 +11,6 @@ import java.io.BufferedReader
|
|||
import java.io.InputStreamReader
|
||||
import java.lang.management.ManagementFactory
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.ServerSocket
|
||||
import java.net.URI
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.properties.Delegates
|
||||
|
|
@ -70,8 +70,6 @@ class ConformanceTest {
|
|||
private const val GRACEFUL_SHUTDOWN_SECONDS = 5L
|
||||
private const val FORCE_SHUTDOWN_SECONDS = 2L
|
||||
|
||||
private fun findFreePort(): Int = ServerSocket(0).use { it.localPort }
|
||||
|
||||
private fun getRuntimeClasspath(): String = ManagementFactory.getRuntimeMXBean().classPath
|
||||
|
||||
private fun getTestClasspath(): String = System.getProperty("test.classpath") ?: getRuntimeClasspath()
|
||||
|
|
|
|||
Loading…
Reference in a new issue