New MCP Schema types (#386)

Implement the last version of the mcp schema and complete restructuring
of the mcp schema implementation from a monolithic `types.kt` file into
separate files.

- #158 
- #185 
- #353 
- #298 
- #248 

## Motivation and Context
The previous implementation of the mcp schema was outdated and contained
several issues. In addition, it stored all mcp types in a single large
file, which made maintenance and further development more difficult

## How Has This Been Tested?
All tests passed

## Breaking Changes
Yes. The new types are now located in a separate package. Additionally,
many types have new parameters and modified constructors

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

## Checklist
- [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
to adopt the new structure:
**Before:**
```kotlin
  import io.modelcontextprotocol.kotlin.sdk.InitializeRequest
  import io.modelcontextprotocol.kotlin.sdk.Resource
```

**After:**
```kotlin
  import io.modelcontextprotocol.kotlin.sdk.types.InitializeRequest
  import io.modelcontextprotocol.kotlin.sdk.types.Resource
```
This commit is contained in:
Pavel Gorgulov 2025-11-11 12:25:23 +01:00 • committed by GitHub
commit 21393e7ce3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13048 additions and 4230 deletions

View file

@ -64,7 +64,6 @@ fun configureServer(): Server {
),
) { request ->
GetPromptResult(
"Description for ${request.name}",
messages = listOf(
PromptMessage(
role = Role.user,
@ -73,6 +72,7 @@ fun configureServer(): Server {
),
),
),
description = "Description for ${request.name}",
)
}

View file

@ -2,7 +2,6 @@ import io.modelcontextprotocol.kotlin.sdk.EmptyJsonObject
import io.modelcontextprotocol.kotlin.sdk.TextContent
import io.modelcontextprotocol.kotlin.sdk.client.Client
import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.TestInstance
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertIs
@ -39,6 +38,6 @@ class SseServerIntegrationTest {
assertIs<TextContent>(content, "Tool result should be a text content")
assertEquals(expected = "Hello, world!", actual = content.text)
assertEquals(expected = "text", actual = content.type)
assertEquals(expected = "text", actual = "${content.type}".lowercase())
}
}