feat: add URL mode elicitation and typed schema definitions per MCP (#660)
Add URL mode elicitation support and typed `PrimitiveSchemaDefinition` hierarchy to align with MCP specification 2025-11-25 closes #540 ## How Has This Been Tested? unit/integration/conformance ## Breaking Changes - `ElicitRequestParams` changed from `data class` to `sealed interface`. A deprecated factory function preserves source compatibility for `ElicitRequestParams(message, requestedSchema)`. - `RequestedSchema.properties` changed from `JsonObject` to `Map<String, PrimitiveSchemaDefinition>`. - `ElicitRequest.requestedSchema` is deprecated, use `(params as ElicitRequestFormParams).requestedSchema`. ## Types of changes - [ ] 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
This commit is contained in:
parent
ad072325c9
commit
fdecf6bdf5
1 changed files with 1838 additions and 384 deletions
|
|
@ -10,6 +10,7 @@ import io.modelcontextprotocol.kotlin.sdk.shared.TransportSendOptions
|
|||
import io.modelcontextprotocol.kotlin.sdk.types.ClientCapabilities
|
||||
import io.modelcontextprotocol.kotlin.sdk.types.CreateMessageRequest
|
||||
import io.modelcontextprotocol.kotlin.sdk.types.CreateMessageResult
|
||||
import io.modelcontextprotocol.kotlin.sdk.types.ElicitRequestFormParams
|
||||
import io.modelcontextprotocol.kotlin.sdk.types.ElicitRequestParams
|
||||
import io.modelcontextprotocol.kotlin.sdk.types.ElicitResult
|
||||
import io.modelcontextprotocol.kotlin.sdk.types.EmptyJsonObject
|
||||
|
|
@ -35,6 +36,7 @@ import io.modelcontextprotocol.kotlin.sdk.types.Root
|
|||
import io.modelcontextprotocol.kotlin.sdk.types.RootsListChangedNotification
|
||||
import io.modelcontextprotocol.kotlin.sdk.types.SUPPORTED_PROTOCOL_VERSIONS
|
||||
import io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities
|
||||
import io.modelcontextprotocol.kotlin.sdk.types.StringSchema
|
||||
import io.modelcontextprotocol.kotlin.sdk.types.TextContent
|
||||
import io.modelcontextprotocol.kotlin.sdk.types.Tool
|
||||
import io.modelcontextprotocol.kotlin.sdk.types.ToolSchema
|
||||
|
|
@ -48,7 +50,6 @@ import kotlinx.coroutines.test.runTest
|
|||
import kotlinx.coroutines.withTimeout
|
||||
import kotlinx.serialization.json.buildJsonObject
|
||||
import kotlinx.serialization.json.put
|
||||
import kotlinx.serialization.json.putJsonObject
|
||||
import kotlin.coroutines.cancellation.CancellationException
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
|
@ -953,11 +954,7 @@ class ClientTest {
|
|||
serverSession.createElicitation(
|
||||
message = "Please provide your GitHub username",
|
||||
requestedSchema = ElicitRequestParams.RequestedSchema(
|
||||
properties = buildJsonObject {
|
||||
putJsonObject("name") {
|
||||
put("type", "string")
|
||||
}
|
||||
},
|
||||
properties = mapOf("name" to StringSchema()),
|
||||
required = listOf("name"),
|
||||
),
|
||||
)
|
||||
|
|
@ -1061,11 +1058,7 @@ class ClientTest {
|
|||
|
||||
val elicitationMessage = "Please provide your GitHub username"
|
||||
val requestedSchema = ElicitRequestParams.RequestedSchema(
|
||||
properties = buildJsonObject {
|
||||
putJsonObject("name") {
|
||||
put("type", "string")
|
||||
}
|
||||
},
|
||||
properties = mapOf("name" to StringSchema()),
|
||||
required = listOf("name"),
|
||||
)
|
||||
|
||||
|
|
@ -1076,7 +1069,8 @@ class ClientTest {
|
|||
|
||||
client.setElicitationHandler { request ->
|
||||
assertEquals(elicitationMessage, request.params.message)
|
||||
assertEquals(requestedSchema, request.params.requestedSchema)
|
||||
val formParams = request.params as ElicitRequestFormParams
|
||||
assertEquals(requestedSchema, formParams.requestedSchema)
|
||||
|
||||
ElicitResult(
|
||||
action = elicitationResultAction,
|
||||
|
|
|
|||
Loading…
Reference in a new issue