Skip to content

Conversation

tiginamaria
Copy link
Contributor

@tiginamaria tiginamaria commented Aug 25, 2025

Motivation and Context

Fixes: #233

The issue appeared due to fallback-style RequestResultPolymorphicSerializer implementation:

internal object ServerResultPolymorphicSerializer :
    JsonContentPolymorphicSerializer<ServerResult>(ServerResult::class) {
    override fun selectDeserializer(element: JsonElement): DeserializationStrategy<ServerResult> =
        selectServerResultDeserializer(element)
            ?: EmptyRequestResult.serializer()
}

internal object ClientResultPolymorphicSerializer :
    JsonContentPolymorphicSerializer<ClientResult>(ClientResult::class) {
    override fun selectDeserializer(element: JsonElement): DeserializationStrategy<ClientResult> =
        selectClientResultDeserializer(element)
            ?: EmptyRequestResult.serializer()
}

internal object RequestResultPolymorphicSerializer :
    JsonContentPolymorphicSerializer<RequestResult>(RequestResult::class) {
    override fun selectDeserializer(element: JsonElement): DeserializationStrategy<RequestResult> =
        selectClientResultDeserializer(element)
            ?: selectServerResultDeserializer(element)
            ?: EmptyRequestResult.serializer()
}
  1. CreateElicitationResult is a ClientResult with an action field https://modelcontextprotocol.io/specification/draft/client/elicitation
  2. The selectClientResultDeserializer function was missing a case for the action field
  3. Since it wasn't found in the client results, the system fell back to server result deserialization
  4. The selectServerResultDeserializer found the content field and incorrectly mapped it to CallToolResult.serializer()

How Has This Been Tested?

Breaking Changes

Types of changes

  • 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

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@tiginamaria tiginamaria requested a review from devcrocod August 25, 2025 15:24
@tiginamaria tiginamaria force-pushed the tigina/elicitation-response branch from a0a1a44 to 8b2fb73 Compare August 25, 2025 16:01
Copy link
Contributor

@devcrocod devcrocod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@devcrocod devcrocod merged commit b37a0f6 into main Aug 25, 2025
4 checks passed
@devcrocod devcrocod deleted the tigina/elicitation-response branch August 25, 2025 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Elicitation response fails on deserialization
2 participants