refactor(core): Fix Kotlin language and api version to 2.1 in build config (#620)

## Fix Kotlin language and api version to 2.1

- Remove language constructs not supported in Kotlin 2.1

<!-- Provide a brief summary of your changes -->

## Motivation and Context
To ensure binary compatibility

## How Has This Been Tested?
Regression tests

## Breaking Changes
<!-- Will users need to update their code or configurations? -->

## Types of changes
<!-- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [ ] 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
- [x] Build 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
- [ ] I have added appropriate error handling
- [ ] I have added or updated documentation as needed

## Additional context
<!-- Add any other context, implementation notes, or design decisions
-->
This commit is contained in:
Konstantin Pavlov 2026-03-26 17:36:01 +02:00 • committed by GitHub
commit c77ebe0c00
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -148,18 +148,17 @@ class StreamableHttpClientTransportTest {
)
val transport = createTransport { request ->
when (
val msg = McpJson.decodeFromString<JSONRPCMessage>(
(request.body as TextContent).text,
)
) {
is JSONRPCRequest if msg.method == "initialize" -> respond(
val msg = McpJson.decodeFromString<JSONRPCMessage>(
(request.body as TextContent).text,
)
when {
msg is JSONRPCRequest && msg.method == "initialize" -> respond(
content = "",
status = HttpStatusCode.OK,
headers = headersOf("mcp-session-id", "test-session-id"),
)
is JSONRPCNotification if msg.method == "test" -> {
msg is JSONRPCNotification && msg.method == "test" -> {
assertEquals("test-session-id", request.headers["mcp-session-id"])
respond(
content = "",
@ -246,8 +245,8 @@ class StreamableHttpClientTransportTest {
var sseStarted = false
val transport = createTransport { request ->
when (request.method) {
HttpMethod.Post if request.body.toString().contains("notifications/initialized") -> {
when {
request.method == HttpMethod.Post && request.body.toString().contains("notifications/initialized") -> {
respond(
content = "",
status = HttpStatusCode.Accepted,
@ -256,7 +255,7 @@ class StreamableHttpClientTransportTest {
}
// Handle SSE connection
HttpMethod.Get -> {
request.method == HttpMethod.Get -> {
sseStarted = true
val sseContent = buildString {
// Server sends various notifications
@ -288,7 +287,7 @@ class StreamableHttpClientTransportTest {
}
// Handle regular notifications
HttpMethod.Post -> {
request.method == HttpMethod.Post -> {
respond(
content = "",
status = HttpStatusCode.Accepted,