Skip to content

Conversation

sdelamo
Copy link
Contributor

@sdelamo sdelamo commented Oct 6, 2025

This pull-request removes the name member from the @JsonSubTypes.Type annotations when using JsonTypeInfo.Id.DEDUCTION.

With DEDUCTION, Jackson ignores the name entirely because it's inferring the type from the structure.

Motivation and Context

The incorrect usage of name was causing serialization issues downstream.

How Has This Been Tested?

Existing tests in the project still pass

Breaking Changes

No

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

This pull-request removes the name member from the @JsonSubTypes.Type annotations when using JsonTypeInfo.Id.DEDUCTION.

With DEDUCTION, Jackson ignores the name entirely because it's inferring the type from the structure.
@sdelamo sdelamo changed the title fix remove name when using deduction fix remove name when using @JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) Oct 6, 2025
Copy link
Contributor

@tzolov tzolov left a comment

Choose a reason for hiding this comment

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

It is nice that Jackson can infers the subtype with no discriminator meta field.
As long as the ResourceContents have distinct, non-overlapping properties for Jackson to reliably deduce the correct type. It is the case for TextResourceContents, BlobResourceContents

@tzolov tzolov merged commit 94a8b53 into modelcontextprotocol:main Oct 6, 2025
1 check passed
tzolov pushed a commit that referenced this pull request Oct 6, 2025
This pull-request removes the name member from the @JsonSubTypes.Type annotations when using JsonTypeInfo.Id.DEDUCTION.

With DEDUCTION, Jackson ignores the name entirely because it's inferring the type from the structure.
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.

2 participants