fix conformance tests (#483)

# Fix conformance tests.

1. fix node version to workaround
https://github.com/nodejs/node/issues/56645
2. use `@argfile` to handle long classpaths
3. specify extension for npx for windows
4. Install `@modelcontextprotocol/conformance@0.1.8` GitHub Actions
workflow.
5. Centralize logging for process streams in conformance tests: Add
`startLogging` utility for InputStream logging with `KotlinLogging`.
Replace inline process stream handling with `startLogging` calls

Note: Currently tests pass using
`@modelcontextprotocol/conformance@0.1.8`/ But changing to 0.1.9 will
fail client scenarios (it is not related to this PR).

## Motivation and Context
Before fix conformance tests are broken on Windows

## How Has This Been Tested?
Run test locally and in github actions

## Breaking Changes
No

## Types of changes

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update

## 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
- [x] I have added appropriate error handling
- [x] I have added or updated documentation as needed

## Additional context
May be we should update `CONTRIBUTING.md/Building/Requirements`. But
currently it does not mention at all: node, android, etc.

---------

Co-authored-by: f.bobin <f.bobin@vk.team>
Co-authored-by: Konstantin Pavlov <1517853+kpavlov@users.noreply.github.com>
This commit is contained in:
Fedor Bobin 2026-01-19 16:45:54 +03:00 • committed by GitHub
commit c73507b96a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 119 additions and 52 deletions

View file

@ -1,3 +1,5 @@
package io.modelcontextprotocol.kotlin.test.utils
public val isWindows: Boolean = System.getProperty("os.name").lowercase().contains("windows")
public val NPX: String = if (isWindows) "npx.cmd" else "npx"

View file

@ -1,5 +1,10 @@
package io.modelcontextprotocol.kotlin.test.utils
import io.github.oshai.kotlinlogging.KLogger
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
public fun createTeeProcessBuilder(): ProcessBuilder = if (isWindows) {
ProcessBuilder("cmd", "/c", "findstr", "^")
} else {
@ -11,3 +16,30 @@ public fun createSleepyProcessBuilder(): ProcessBuilder = if (isWindows) {
} else {
ProcessBuilder("sh", "-c", "sleep 1 && echo 'simulated error' >&2 && exit 1")
}
/**
* Starts logging the lines from this InputStream to a specified logger.
* Each line from the InputStream is read and logged using the provided logger
* at the debug level, optionally with an additional prefix string appended
* to each logged line. The method runs the logging process in a separate daemon thread.
*
* @param logger The logger used to log the lines from the InputStream.
* @param name The name to assign to the daemon thread handling the logging process.
*/
public fun InputStream.startLogging(logger: KLogger, name: String) {
val stream = this
Thread {
try {
BufferedReader(InputStreamReader(stream)).use { reader ->
reader.lineSequence().forEach { line ->
logger.debug { line }
}
}
} catch (e: Exception) {
logger.trace(e) { "Error reading server test stdout" }
}
}.apply {
this.name = name
isDaemon = true
}.start()
}