fix: enhance resolution and enum handling in anyOf schemas
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
- [x] 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
- [x] I have read the MCP Documentation
- [x] My code follows the repository's style guidelines
- [x] New and existing tests pass locally
- [x] I have added appropriate error handling
- [ ] I have added or updated documentation as needed
Additional context
- Enhanced
resolveRef: Added circular reference detection, recursively resolves$refinanyOf - Optimized
normalizeUnionType: Unified handling foranyOf=[type, null], preserves enum properties - Integrated in ToolsTab: Uses
resolveRefbefore normalization to ensure complete schema info
Fixes #897
Hi @Edison-A-N!
This looks like it builds upon https://github.com/modelcontextprotocol/inspector/pull/889 from last week, I see you are calling the resolveRef function it added. I also see it replaces some changes from https://github.com/modelcontextprotocol/inspector/pull/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.