Skip to content

Conversation

@Edison-A-N
Copy link

Summary

Fix $ref resolution and enum handling in anyOf schemas. Resolves issue #897 where enum types defined via $ref in anyOf were not properly resolved.

Motivation and Context

Addresses issue #897: anyOf=[$ref, null] patterns were not resolved, causing enum properties to be lost and preventing dropdown rendering.

How Has This Been Tested?

  • All existing tests pass (392 unit tests, 16 E2E tests)
  • Prettier and ESLint checks passed
  • Tested with schemas containing anyOf=[{$ref: "#/$defs/UserRole"}, {type: "null"}]

Breaking Changes

None. Bug fix maintaining backward compatibility.

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

  • Enhanced resolveRef: Added circular reference detection, recursively resolves $ref in anyOf
  • Optimized normalizeUnionType: Unified handling for anyOf=[type, null], preserves enum properties
  • Integrated in ToolsTab: Uses resolveRef before normalization to ensure complete schema info

Fixes #897

Copy link
Member

@olaservo olaservo left a comment

Choose a reason for hiding this comment

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

Hi @Edison-A-N thanks for your PR! There's a spicy take about supporting refs in tool schemas here: #755

So think that this would apply to elicitation schemas as well. I'll drop a comment there since I hadn't responded there yet. Please feel free to share your thoughts as well.

@olaservo olaservo mentioned this pull request Nov 4, 2025
@cliffhall
Copy link
Member

Hi @Edison-A-N!

This looks like it builds upon #889 from last week, I see you are calling the resolveRef function it added. I also see it replaces some changes from #895 which I also made last week for nullable arrays, rolling up all the nullable type checks into a new block, which will be nice if it didn't break anything. I need to test that out and make sure nullable items still work correctly first.

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.

ToolsTab: anyOf/$ref enum not resolved; optional enum fields not clearable (appear required)

3 participants