fix: Support string enum for elicitation #1563
Open
+40
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add support for string Enum types in elicitation schemas
Related PR: modelcontextprotocol/inspector#902
Changes Made
StrEnumto_ELICITATION_PRIMITIVE_TYPEStuple_is_primitive_field()to detect string enum types usingissubclass()checksMotivation and Context
Per https://modelcontextprotocol.io/specification/2025-06-18/client/elicitation#supported-schema-types, elicitation schemas support enum types.
Currently,
python-sdkonly supported basic primitive types (str,int,float,bool) in elicitation schemas, but did not recognize Enum types.How Has This Been Tested?
Added test cases in
test_elicitation_schema_validation()to verify enum schemasManual test with
Results
Breaking Changes
Types of changes
Checklist
Additional context
The documentation doesn't explicitly specify that enums must be string enums. Should we add that clarification since both the TypeScript and Rust SDKs only support string enums?
https://github.com/modelcontextprotocol/typescript-sdk/blob/783d53be1049041cc1f0a23c070c3400208a94ff/src/types.ts#L1221-L1229
https://github.com/modelcontextprotocol/rust-sdk/blob/04e0590652d029e2cdfadee6f4c7255280dfba0e/crates/rmcp/src/model/elicitation_schema.rs#L479-L481