Skip to content

Conversation

@chughtapan
Copy link
Contributor

@chughtapan chughtapan commented Aug 7, 2025

Motivation and Context

This PR implements the changes required to implement multi-select enums in modelcontextprotocol/modelcontextprotocol#1330

How Has This Been Tested?

All new and existing tests 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

Additional context

Copy link
Contributor

@felixweinberger felixweinberger left a comment

Choose a reason for hiding this comment

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

Hi @chughtapan thanks for this - I notice you've marked this as a SEP, those are generally for enhancements to the protocol itself i.e. at github.com/mode

Is this meant as an attachment to a SEP or do you plan on creating one?

@chughtapan
Copy link
Contributor Author

Is this meant as an attachment to a SEP or do you plan on creating one?

Its an attachment for modelcontextprotocol/modelcontextprotocol#1330
Edited the PR description with the SEP link

@chughtapan
Copy link
Contributor Author

@felixweinberger the SEP was accepted, so this is ready for review now.

@felixweinberger felixweinberger added needs maintainer action Potentially serious issue - needs proactive fix and maintainer attention and removed needs SEP labels Oct 16, 2025
@felixweinberger felixweinberger self-assigned this Oct 16, 2025
@chughtapan chughtapan changed the title SEP: Elicitation Enum Schema Improvements and Standards Compliance SEP-1330: Elicitation Enum Schema Improvements and Standards Compliance Oct 22, 2025
@felixweinberger
Copy link
Contributor

@felixweinberger the SEP was accepted, so this is ready for review now.

Picking this up as #1542 is part of the November spec release and will be pushing to the branch here - thanks @chughtapan for starting on this!

@felixweinberger felixweinberger added enhancement Request for a new feature that's not currently supported and removed enhancement deprecated labels Nov 12, 2025
Tapan Chugh and others added 7 commits November 21, 2025 19:43
The merge commit 6dc50e2 accidentally removed two test sections:
- Valid list[str] multi-select test in test_elicitation_with_optional_fields
- Complete test_elicitation_with_enum_titles test function

This commit restores both deleted tests.
Fix bug where Union types containing string sequences (like list[str] | None)
were incorrectly rejected by elicitation schema validation.

Changes:
- Updated _is_primitive_field() to check for string sequences in Union types
- Added try-except wrapper to _is_string_sequence() to handle non-class origins
- Added test case for Optional[list[str]] validation

This ensures that optional multi-select enum fields work correctly with the
SEP-1330 implementation.
Add test_elicitation_sep1330_enum_schemas tool that demonstrates all 5
enum schema patterns introduced in SEP-1330:

- Untitled single-select (simple enum array)
- Titled single-select (oneOf with const/title)
- Untitled multi-select (array with items.enum)
- Titled multi-select (array with items.oneOf)
- Legacy format (enum + enumNames for backward compatibility)

This enables conformance testing of the SEP-1330 implementation in the
Python SDK, matching the TypeScript server implementation.
@felixweinberger felixweinberger linked an issue Nov 23, 2025 that may be closed by this pull request
Add coverage pragmas to defensive code paths that are difficult to
test but necessary for completeness:

- elicitation.py: None/NoneType annotation handling (line 48)
- elicitation.py: TypeError exception in _is_string_sequence (lines 72-74)
- test_elicitation.py: fallback return statements in test tools

These paths handle edge cases that don't occur in normal execution
but provide safety for unexpected inputs.
- Rename test_elicitation_sep1330_enum_schemas to
  test_elicitation_sep1330_enums to match conformance test expectation
- Add missing type: "string" to untitledMulti items schema for
  conformance test validation
Copy link
Contributor

@felixweinberger felixweinberger left a comment

Choose a reason for hiding this comment

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

Confirmed that passes conformance tests

@felixweinberger felixweinberger merged commit b19fa6f into modelcontextprotocol:main Nov 23, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Request for a new feature that's not currently supported needs maintainer action Potentially serious issue - needs proactive fix and maintainer attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement SEP-1330: Elicitation Enum Schema Improvements

2 participants